void waste_time(void) {
  int i;
  volatile int x;
  for (i = 0; i < 50; i++) {
    x = i;
  }
  (void)x;
}


x86 assembly (clang, -O0):
<waste_time>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
cmpl   $0x32,-0x4(%rbp)
jge    1129 <waste_time+0x29>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    110b <waste_time+0xb>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<waste_time>:
movl   $0x0,-0x4(%rsp)
movl   $0x1,-0x4(%rsp)
movl   $0x2,-0x4(%rsp)
movl   $0x3,-0x4(%rsp)
movl   $0x4,-0x4(%rsp)
movl   $0x5,-0x4(%rsp)
movl   $0x6,-0x4(%rsp)
movl   $0x7,-0x4(%rsp)
movl   $0x8,-0x4(%rsp)
movl   $0x9,-0x4(%rsp)
movl   $0xa,-0x4(%rsp)
movl   $0xb,-0x4(%rsp)
movl   $0xc,-0x4(%rsp)
movl   $0xd,-0x4(%rsp)
movl   $0xe,-0x4(%rsp)
movl   $0xf,-0x4(%rsp)
movl   $0x10,-0x4(%rsp)
movl   $0x11,-0x4(%rsp)
movl   $0x12,-0x4(%rsp)
movl   $0x13,-0x4(%rsp)
movl   $0x14,-0x4(%rsp)
movl   $0x15,-0x4(%rsp)
movl   $0x16,-0x4(%rsp)
movl   $0x17,-0x4(%rsp)
movl   $0x18,-0x4(%rsp)
movl   $0x19,-0x4(%rsp)
movl   $0x1a,-0x4(%rsp)
movl   $0x1b,-0x4(%rsp)
movl   $0x1c,-0x4(%rsp)
movl   $0x1d,-0x4(%rsp)
movl   $0x1e,-0x4(%rsp)
movl   $0x1f,-0x4(%rsp)
movl   $0x20,-0x4(%rsp)
movl   $0x21,-0x4(%rsp)
movl   $0x22,-0x4(%rsp)
movl   $0x23,-0x4(%rsp)
movl   $0x24,-0x4(%rsp)
movl   $0x25,-0x4(%rsp)
movl   $0x26,-0x4(%rsp)
movl   $0x27,-0x4(%rsp)
movl   $0x28,-0x4(%rsp)
movl   $0x29,-0x4(%rsp)
movl   $0x2a,-0x4(%rsp)
movl   $0x2b,-0x4(%rsp)
movl   $0x2c,-0x4(%rsp)
movl   $0x2d,-0x4(%rsp)
movl   $0x2e,-0x4(%rsp)
movl   $0x2f,-0x4(%rsp)
movl   $0x30,-0x4(%rsp)
movl   $0x31,-0x4(%rsp)
mov    -0x4(%rsp),%eax
ret

LLVM IR (-O0):
define void @waste_time() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %8, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 50
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = load i32, i32* %1
store volatile i32 %7, i32* %2
br label %8
8: ; preds = %6
%9 = load i32, i32* %1
%10 = add nsw i32 %9, 1
store i32 %10, i32* %1
br label %3
11: ; preds = %3
%12 = load volatile i32, i32* %2
ret void
}

LLVM IR (-O2):
define void @waste_time() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store volatile i32 0, i32* %1
store volatile i32 1, i32* %1
store volatile i32 2, i32* %1
store volatile i32 3, i32* %1
store volatile i32 4, i32* %1
store volatile i32 5, i32* %1
store volatile i32 6, i32* %1
store volatile i32 7, i32* %1
store volatile i32 8, i32* %1
store volatile i32 9, i32* %1
store volatile i32 10, i32* %1
store volatile i32 11, i32* %1
store volatile i32 12, i32* %1
store volatile i32 13, i32* %1
store volatile i32 14, i32* %1
store volatile i32 15, i32* %1
store volatile i32 16, i32* %1
store volatile i32 17, i32* %1
store volatile i32 18, i32* %1
store volatile i32 19, i32* %1
store volatile i32 20, i32* %1
store volatile i32 21, i32* %1
store volatile i32 22, i32* %1
store volatile i32 23, i32* %1
store volatile i32 24, i32* %1
store volatile i32 25, i32* %1
store volatile i32 26, i32* %1
store volatile i32 27, i32* %1
store volatile i32 28, i32* %1
store volatile i32 29, i32* %1
store volatile i32 30, i32* %1
store volatile i32 31, i32* %1
store volatile i32 32, i32* %1
store volatile i32 33, i32* %1
store volatile i32 34, i32* %1
store volatile i32 35, i32* %1
store volatile i32 36, i32* %1
store volatile i32 37, i32* %1
store volatile i32 38, i32* %1
store volatile i32 39, i32* %1
store volatile i32 40, i32* %1
store volatile i32 41, i32* %1
store volatile i32 42, i32* %1
store volatile i32 43, i32* %1
store volatile i32 44, i32* %1
store volatile i32 45, i32* %1
store volatile i32 46, i32* %1
store volatile i32 47, i32* %1
store volatile i32 48, i32* %1
store volatile i32 49, i32* %1
%3 = load volatile i32, i32* %1
ret void
}