Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I'll be glad if you propose something more efficient and more accurate to decompile this (directed to the beginning of the first procedure). Would you prefer to start your decompilation from binary ?
A more useful answer could have been two orders of magnitude shorter : "Represent your abstract assembly code as a C program with basic blocks as externally defined procedures, variables in conditions as externally defined functions, and as many gotos as you like, compile it to an optimized x86 binary, then pass it through an existing x86 decompiler." This is a little circuitous, but is likely to serve the purpose.
What I'm asking for is a substantial subset of the actions performed by a decompiler, therefore the tag is appropriate; the desired functionality is clearly defined: given a CFG as input, produce its reduction into loops and conditionals using break and continue when necessary, minimizing remaining unstructured gotos if the original CFG was irreducible. What exactly was your answer intended to serve?
Apparently I need the control flow structuring algorithm from the dream decompiler, but a few tools claiming to use it that I could find take x86 ELF as input.
My question is even narrower: I don't need a framework, I need a single tool with text input and text output. Its complexity would likely be at the level of a research thesis rather than an industrial product.
My point is that reconstructing control flow structures is virtually independent on the architecture. I could bring the input one step higher: If one has a graph of opaque basic blocks connected by "if (condition) goto" and "goto", it should be possible to restore the original if-then-else statements and loops, and a tool that could do it won't need any disassembler capability.