private static LFunction file_to_function(String fn, Configuration config) throws IOException {
RandomAccessFile file = new RandomAccessFile(fn, "r");
ByteBuffer buffer = ByteBuffer.allocate((int)file.length());
buffer.order(ByteOrder.LITTLE_ENDIAN);
int len = (int)file.length();
for(FileChannel in = file.getChannel(); len > 0; len -= in.read(buffer)) {
;
}
buffer.rewind();
BHeader header = new BHeader(buffer, config);
return header.main;
}
public static void decompile(String in, String out) throws IOException {
LFunction lmain = file_to_function(in, new Configuration());
Decompiler d = new Decompiler(lmain);
d.decompile();
PrintStream pout = new PrintStream(out);
d.print(new Output(new 1(pout)));
pout.flush();
pout.close();
}
}