The answer is yes, the compiler can optimize out the loop.
Use the volatile qualifier to avoid the optimization:
int loop = us * 32;
volatile int x;
for (x = 0; x < loop; x++)
{
/*do nothing*/
}
If you are programming in the embedded world read the documentation of your compiler as they usually provide delay functions that wait for a certain number of cycles or microseconds passed in parameter.
For example, avr-gcc has the following function in util/delay.h:
void _delay_us(double __us);