#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*/ function();
int /*<<< orphan*/ printf(char *, void *, int);
int main() {
  int i;
  static int static_var = 1337;
  for (i = 0; i < 5; i++) {
    printf("[in main] static_var @ %p = %d\n", (void *)&static_var, static_var);
    function();
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    116e <main+0x4e>
mov    0x2eea(%rip),%edx
lea    0xeb3(%rip),%rdi
lea    0x2edc(%rip),%rsi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <function@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2f06(%rip),%edx
lea    0x2eff(%rip),%r14
lea    0xec8(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <function@plt>
mov    0x2ee0(%rip),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <function@plt>
mov    0x2ec8(%rip),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <function@plt>
mov    0x2eb0(%rip),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <function@plt>
mov    0x2e98(%rip),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <function@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@main.static_var = internal global i32 1337
@.str = [32 x i8] c"[in main] static_var @ %p = %d\0A\00"
define i32 @main() {
%1 = load i32, i32* @main.static_var
%2 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* bitcast (i32* @main.static_var to i8*), i32 %1)
%3 = tail call i32 (...) @function()
%4 = load i32, i32* @main.static_var
%5 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* bitcast (i32* @main.static_var to i8*), i32 %4)
%6 = tail call i32 (...) @function()
%7 = load i32, i32* @main.static_var
%8 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* bitcast (i32* @main.static_var to i8*), i32 %7)
%9 = tail call i32 (...) @function()
%10 = load i32, i32* @main.static_var
%11 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* bitcast (i32* @main.static_var to i8*), i32 %10)
%12 = tail call i32 (...) @function()
%13 = load i32, i32* @main.static_var
%14 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* bitcast (i32* @main.static_var to i8*), i32 %13)
%15 = tail call i32 (...) @function()
ret i32 0
}