The following code is x64 compiled by g++ 5.4.0. The left is the compiled output. The stuff on the right is what I expected it to look like. Granted the stuf on the right may not be syntactically correct. This code is supposed to essentially do :
if(i % 3 == 0) do_stuff
400512 would take u to the space after the if block
mov -0x4(%rbp),%ecx mov -0x4(%rbp), %eax
mov $0x55555556,%edx idvq $0x3
mov %ecx,%eax cmp %edx, 0x0
imul %edx jnz 400512 <main+0x3c>
mov %ecx,%eax
sar $0x1f,%eax
sub %eax,%edx
mov %edx,%eax
mov %eax,%edx
add %edx,%edx
add %eax,%edx
mov %ecx,%eax
sub %edx,%eax
test %eax,%eax
jne 400512 <main+0x3c>
My question for those who are a lot smarter then me: Why the heck do g++ have so much more to calculate modulus, and can someone explain to me what it is doing.