#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
void fun(int i5) {
  int i6 = 60;
  static int i7 = 70;
  const int i8 = 80;
  char *str1 = "ABCDE";
  char str2[] = "ABCDE";
  int *pi = malloc(sizeof(int));
  for (int i = 0; i < 10; i++) {
    printf("&i5=%p\n", &i5);
    printf("&i6=%p\n", &i6);
    printf("&i7=%p\n", &i7);
    printf("&i8=%p\n", &i8);
    printf("str1=%p\n", str1);
    printf("str2=%p\n", str2);
    printf("pi=%p\n", pi);
  }
  free(pi);
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x3c,-0x8(%rbp)
movl   $0x50,-0xc(%rbp)
lea    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea6(%rip),%eax
mov    %eax,-0x1e(%rbp)
mov    0xea0(%rip),%ax
mov    %ax,-0x1a(%rbp)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xa,-0x2c(%rbp)
jge    1216 <fun+0xe6>
lea    0xe78(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe64(%rip),%rdi
lea    0x2e7f(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe57(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1e(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    117d <fun+0x4d>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,0x14(%rsp)
movl   $0x3c,0x10(%rsp)
movl   $0x50,0xc(%rsp)
movw   $0x45,0x8(%rsp)
movl   $0x44434241,0x4(%rsp)
44
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0xa,%r13d
lea    0xe85(%rip),%rbp
lea    0xead(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xeaa(%rip),%r12
xchg   %ax,%ax
lea    0xe6f(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe64(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
lea    0x2e74(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4c(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe41(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%r13d
jne    1190 <fun+0x60>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@fun.i7 = internal global i32 70
@.str = [6 x i8] c"ABCDE\00"
@__const.fun.str2 = [6 x i8] c"ABCDE\00"
@.str.1 = [8 x i8] c"&i5=%p\0A\00"
@.str.2 = [8 x i8] c"&i6=%p\0A\00"
@.str.3 = [8 x i8] c"&i7=%p\0A\00"
@.str.4 = [8 x i8] c"&i8=%p\0A\00"
@.str.5 = [9 x i8] c"str1=%p\0A\00"
@.str.6 = [9 x i8] c"str2=%p\0A\00"
@.str.7 = [7 x i8] c"pi=%p\0A\00"
define void @fun(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [6 x i8]
%7 = alloca i32*
%8 = alloca i32
store i32 %0, i32* %2
store i32 60, i32* %3
store i32 80, i32* %4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %5
%9 = bitcast [6 x i8]* %6 to i8*
%10 = call i32* @malloc(i32 4)
store i32* %10, i32** %7
store i32 0, i32* %8
br label %11
11: ; preds = %25, %1
%12 = load i32, i32* %8
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32* @fun.i7)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%19 = load i8*, i8** %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %21)
%23 = load i32*, i32** %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32* %23)
br label %25
25: ; preds = %14
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %11
28: ; preds = %11
%29 = load i32*, i32** %7
%30 = call i32 @free(i32* %29)
ret void
}

LLVM IR (-O2):
@fun.i7 = internal global i32 70
@__const.fun.str2 = [6 x i8] c"ABCDE\00"
@.str.1 = [8 x i8] c"&i5=%p\0A\00"
@.str.2 = [8 x i8] c"&i6=%p\0A\00"
@.str.3 = [8 x i8] c"&i7=%p\0A\00"
@.str.4 = [8 x i8] c"&i8=%p\0A\00"
@.str.5 = [9 x i8] c"str1=%p\0A\00"
@.str.6 = [9 x i8] c"str2=%p\0A\00"
@.str.7 = [7 x i8] c"pi=%p\0A\00"
define void @fun(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [6 x i8]
store i32 %0, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 60, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 80, i32* %4
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%9 = tail call i32* @malloc(i32 4)
br label %12
10: ; preds = %12
%11 = call i32 @free(i32* %9)
ret void
12: ; preds = %1, %12
%13 = phi i32 [ 0, %1 ], [ %21, %12 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32* @fun.i7)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__const.fun.str2, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32* %9)
%21 = add nuw nsw i32 %13, 1
%22 = icmp eq i32 %21, 10
br i1 %22, label %10, label %12
}