BoomerangDecompiler / boomerang

Boomerang Decompiler - Fighting the code-rot :)
Other
374 stars 59 forks source link

Do not output "~(!x || !y)" but "x && y" #116

Closed rfalke closed 5 years ago

rfalke commented 6 years ago

Version: ed7a3e1 Exe: https://github.com/rfalke/decompiler-subjects/blob/master/from_holdec/dmi/cfg/ia32_elf/subject.exe Output:

void intermediate_1_short_circuit_and(int param1, int param2)
{
    int eax;            // r24

    eax = rand();
    if ( ~(param1 == 0 || eax != param2)) {
        puts("both true");
    }
    return;
}

which should be:

...
    if (param1 != 0 && eax == param2) {
...
ceeac commented 6 years ago

As of ce71635ba, the condition should now read if (!(param1 == 0 || eax != param2)). To fully resolve this, it should be sufficient to add simplification rules for DeMorgan's laws to ExpSimplifier::postModify.