In my opinion, the easiest way to do something like this is to decompose the assembly of functions back into some higher level form, where there are constructs (for example, for , while , function calls, etc.), and then the structure of these constructions corresponds more high level.
This will prevent reordering of commands, loop loops, unwinding loops, and any other optimizations that interact with the comparison, you can even (de) optimize these higher-level structures to the maximum at both ends to make sure they are at the same point, therefore, the comparison between the non-optimized debugging code and -O3 will not fail due to lack of time / absence of spills in the register, etc.
You can use something like boomerang as the basis for decompilation (except that you won't spit out C code).
Necrolis
source share