I am reverse engineering a piece of assembly. I am trying to write the equivalent code in C, however, when I compile my code, gcc prefers to use simple instructions instead of the complex ones that are used in my assembly. I was wondering if I can suggest or force gcc to use more complex instructions.
EDIT: I have already tried using the
-O options but they will change lots of other variables and therefore, don't look like a good solution.
You can find examples here:
// original assembly lea rdx, [rax+0x20] // generated by gcc add rax, 0x20 mov rdx, rax // C code 0x20+((uint8_t *)lParm1) // long lParm1
// original assembly test eax, eax // generated by gcc mov [rbp-0x10], eax cmp [rbp-0x10], 0x0 // C code if (!iVar) // int iVar
// original assembly mov eax, [rax+0x40] // generated by gcc add rax, 0x40 mov eax, [rax] // C code (float)*(int *)(lParm1 + 0x40)