Frank Yonamine
Nov 7 · 1 min read

This text looks like a click bait.

The choice between i++ or ++i in your loop can done during programming but the result should be the same. What you have to take care is accessing elements in arrays.

Compiler used: x86–64 gcc 9.1

C++:

while(i < 10) {

// Some code

i++;

}

Asm:

.L3:

cmp DWORD PTR [rbp-4], 9

jg .L2

add DWORD PTR [rbp-4], 1

jmp .L3

.L2:

C++:

while(i < 10) {

// Some code

++i;

}

Asm:

.L5:

cmp DWORD PTR [rbp-4], 9

jg .L4

add DWORD PTR [rbp-4], 1

jmp .L5

.L4:

Thanks

    Frank Yonamine

    Written by