Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r2dec generates if-else-else block #134

Open
mytbk opened this issue Dec 19, 2018 · 1 comment
Open

r2dec generates if-else-else block #134

mytbk opened this issue Dec 19, 2018 · 1 comment
Assignees

Comments

@mytbk
Copy link
Contributor

mytbk commented Dec 19, 2018

The following assembly code can make r2dec generate a if-else-else block:

L0:
test esi, esi
jne L2
cmp eax, 1
jne short L3
jmp short L4

L3:
cmp eax, 2
jne short L2
jmp L6

L2:
inc eax

L4:
xor eax, eax
L6:
ret
$ nasm -f elf test.asm; r2 -q -c 'aa;pdd' test.o
WARNING: Cannot initialize program headers
WARNING: Cannot initialize dynamic strings
WARNING: Cannot initialize dynamic section
Warning: run r2 with -e io.cache=true to fix relocations in disassembly
/* r2dec pseudo C output */
#include <stdint.h>
 
int32_t entry0 (void) {
    /* [01] -r-x section size 22 named .text */
    if (esi == 0) {
        if (eax == 1) {
        } else {
            if (eax == 2) {
            }
        } else {
            eax++;
        }
        eax = 0;
    }
    return eax;
}
@wargio
Copy link
Owner

wargio commented Dec 19, 2018

oh :(
i'll try to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants