#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);
int /*<<< orphan*/ useGlobal();
int /*<<< orphan*/ useLocal();
int /*<<< orphan*/ useStaticLocal();
int main(void) {
  int x = 5;
  printf("local x in outer scope of main is %d\n", x);
  {
    int x = 7;
    printf("local x in inner scope of main is %d\n", x);
  }
  printf("local x in outer scope of main is %d\n", x);
  useLocal();
  useStaticLocal();
  useGlobal();
  useLocal();
  useStaticLocal();
  useGlobal();
  printf("\nlocal x in main is %d\n", x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x7,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <useLocal@plt>
mov    $0x0,%al
call   1040 <useStaticLocal@plt>
mov    $0x0,%al
call   1050 <useGlobal@plt>
mov    $0x0,%al
call   1060 <useLocal@plt>
mov    $0x0,%al
call   1040 <useStaticLocal@plt>
mov    $0x0,%al
call   1050 <useGlobal@plt>
mov    -0x8(%rbp),%esi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x7,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <useLocal@plt>
xor    %eax,%eax
call   1040 <useStaticLocal@plt>
xor    %eax,%eax
call   1050 <useGlobal@plt>
xor    %eax,%eax
call   1060 <useLocal@plt>
xor    %eax,%eax
call   1040 <useStaticLocal@plt>
xor    %eax,%eax
call   1050 <useGlobal@plt>
lea    0xea8(%rip),%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"local x in outer scope of main is %d\0A\00"
@.str.1 = [38 x i8] c"local x in inner scope of main is %d\0A\00"
@.str.2 = [24 x i8] c"\0Alocal x in main is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 7, i32* %3
%6 = load i32, i32* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
%9 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 (...) @useLocal()
%11 = call i32 (...) @useStaticLocal()
%12 = call i32 (...) @useGlobal()
%13 = call i32 (...) @useLocal()
%14 = call i32 (...) @useStaticLocal()
%15 = call i32 (...) @useGlobal()
%16 = load i32, i32* %2
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"local x in outer scope of main is %d\0A\00"
@.str.1 = [38 x i8] c"local x in inner scope of main is %d\0A\00"
@.str.2 = [24 x i8] c"\0Alocal x in main is %d\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 5)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 7)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 5)
%4 = tail call i32 (...) @useLocal()
%5 = tail call i32 (...) @useStaticLocal()
%6 = tail call i32 (...) @useGlobal()
%7 = tail call i32 (...) @useLocal()
%8 = tail call i32 (...) @useStaticLocal()
%9 = tail call i32 (...) @useGlobal()
%10 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 5)
ret i32 0
}