#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
void fn() {
  int i;
  for (i = 0; i < 10; i++) {
    static int count = 0;
    printf("%d\n", count++);
  }
}


x86 assembly (clang, -O0):
<fn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    1154 <fn+0x44>
mov    0x2efd(%rip),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,0x2ef2(%rip)
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <fn+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn>:
push   %rbx
mov    0x2f15(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2f0c(%rip)
lea    0xed9(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2ef7(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2eee(%rip)
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2ee0(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2ed7(%rip)
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2ec9(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2ec0(%rip)
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2eb2(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2ea9(%rip)
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2e9b(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2e92(%rip)
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2e84(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2e7b(%rip)
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2e6d(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2e64(%rip)
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2e56(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2e4d(%rip)
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2e3f(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2e36(%rip)
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@fn.count = internal global i32 0
@.str = [4 x i8] c"%d\0A\00"
define void @fn() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %9, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 10
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = load i32, i32* @fn.count
%7 = add nsw i32 %6, 1
store i32 %7, i32* @fn.count
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %9
9: ; preds = %5
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
br label %2
12: ; preds = %2
ret void
}

LLVM IR (-O2):
@fn.count = internal unnamed_addr global i32 0
@.str = [4 x i8] c"%d\0A\00"
define void @fn() {
%1 = load i32, i32* @fn.count
%2 = add nsw i32 %1, 1
store i32 %2, i32* @fn.count
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %1)
%4 = load i32, i32* @fn.count
%5 = add nsw i32 %4, 1
store i32 %5, i32* @fn.count
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%7 = load i32, i32* @fn.count
%8 = add nsw i32 %7, 1
store i32 %8, i32* @fn.count
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%10 = load i32, i32* @fn.count
%11 = add nsw i32 %10, 1
store i32 %11, i32* @fn.count
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%13 = load i32, i32* @fn.count
%14 = add nsw i32 %13, 1
store i32 %14, i32* @fn.count
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%16 = load i32, i32* @fn.count
%17 = add nsw i32 %16, 1
store i32 %17, i32* @fn.count
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%19 = load i32, i32* @fn.count
%20 = add nsw i32 %19, 1
store i32 %20, i32* @fn.count
%21 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%22 = load i32, i32* @fn.count
%23 = add nsw i32 %22, 1
store i32 %23, i32* @fn.count
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%25 = load i32, i32* @fn.count
%26 = add nsw i32 %25, 1
store i32 %26, i32* @fn.count
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%28 = load i32, i32* @fn.count
%29 = add nsw i32 %28, 1
store i32 %29, i32* @fn.count
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
ret void
}