#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 */
void *malloc(int);
int /*<<< orphan*/ printf(char *, void *);
void recurse(int n) {
  int a[4000];
  int x;
  void *q = malloc(128);
  printf("Address of a is %p\n", &a[0]);
  printf("Address of x is %p\n", &x);
  printf("Address of q is %p\n", q);
  if (n > 0)
    recurse(n - 1);
}


x86 assembly (clang, -O0):
<recurse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3ea0,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x80,%edi
call   1050 <malloc@plt>
mov    %rax,-0x3ea0(%rbp)
lea    -0x3e90(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    -0x3e94(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3ea0(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
jle    119d <recurse+0x6d>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
call   1030 <recurse@plt>
add    $0x3ea0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recurse>:
push   %r14
push   %rbx
sub    $0x3e98,%rsp
mov    %edi,%ebx
mov    $0x80,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xeb0(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
test   %ebx,%ebx
jle    1188 <recurse+0x58>
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1030 <recurse@plt>
add    $0x3e98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Address of a is %p\0A\00"
@.str.1 = [20 x i8] c"Address of x is %p\0A\00"
@.str.2 = [20 x i8] c"Address of q is %p\0A\00"
define void @recurse(i32 %0) {
%2 = alloca i32
%3 = alloca [4000 x i32]
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %2
%6 = call i8* @malloc(i32 128)
store i8* %6, i8** %5
%7 = getelementptr inbounds [4000 x i32], [4000 x i32]* %3, i64 0, i64 0
%8 = bitcast i32* %7 to i8*
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = bitcast i32* %4 to i8*
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %5
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i32, i32* %2
%18 = sub nsw i32 %17, 1
br label %19
19: ; preds = %16, %1
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Address of a is %p\0A\00"
@.str.1 = [20 x i8] c"Address of x is %p\0A\00"
@.str.2 = [20 x i8] c"Address of q is %p\0A\00"
define void @recurse(i32 %0) {
%2 = alloca [4000 x i32]
%3 = alloca i32
%4 = bitcast [4000 x i32]* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%7 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = add nsw i32 %0, -1
br label %13
13: ; preds = %11, %1
ret void
}