Why GCC compiler omitting some code?
You could try making the loop actually do something.  As it stands the compiler is quite rightly saying "This loop is doing nothing - I'll get rid of it".

So you could try a construct I use frequently:

int i;
for (i = 0; i &lt; 10; i++) {
    asm volatile ("nop");
}


Note: not all targets for the gcc compiler use the same inline assembly syntax - you may need to tweak it for your target.