This code was basically directly translated from C# to C, and is incredibly dirty.
(A lot of unneeded allocations / copying / reading).
This should probably be completely rewritten.
Wii (U) NAND Extractor written in C
./extractor-linux <nand> [output]
keys.bin or otp.bin needs to be in the same folder.