#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*/ getStackTrace(unsigned long *, int);
int /*<<< orphan*/ printf(char *, int, unsigned long);
g() {
  unsigned long returnStack[16];
  int i;
  getStackTrace(returnStack, 16);
  for (i = 0; i < 16 && returnStack[i]; i++)
    printf("%2d: 0x%lx\n", i, returnStack[i]);
}


x86 assembly (clang, -O0):
<g>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    -0x90(%rbp),%rdi
mov    $0x10,%esi
call   1040 <getStackTrace@plt>
movl   $0x0,-0x94(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x94(%rbp)
mov    %al,-0x95(%rbp)
jge    1174 <g+0x54>
movslq -0x94(%rbp),%rax
cmpq   $0x0,-0x90(%rbp,%rax,8)
setne  %al
mov    %al,-0x95(%rbp)
mov    -0x95(%rbp),%al
test   $0x1,%al
jne    1187 <g+0x67>
jmp    11bc <g+0x9c>
mov    -0x94(%rbp),%esi
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdx
ff
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1146 <g+0x26>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g>:
sub    $0x88,%rsp
mov    %rsp,%rdi
mov    $0x10,%esi
call   1040 <getStackTrace@plt>
mov    (%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xeb8(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    0x8(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xe9c(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    0x10(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xe7d(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    0x18(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xe5e(%rip),%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    0x20(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xe3f(%rip),%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    0x28(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xe20(%rip),%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
mov    0x30(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xe01(%rip),%rdi
mov    $0x6,%esi
call   1030 <printf@plt>
mov    0x38(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xde2(%rip),%rdi
mov    $0x7,%esi
call   1030 <printf@plt>
mov    0x40(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xdc3(%rip),%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
mov    0x48(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xda4(%rip),%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
mov    0x50(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xd85(%rip),%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
mov    0x58(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xd6a(%rip),%rdi
mov    $0xb,%esi
call   1030 <printf@plt>
mov    0x60(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xd4f(%rip),%rdi
mov    $0xc,%esi
call   1030 <printf@plt>
mov    0x68(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xd34(%rip),%rdi
mov    $0xd,%esi
call   1030 <printf@plt>
mov    0x70(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xd19(%rip),%rdi
mov    $0xe,%esi
call   1030 <printf@plt>
mov    0x78(%rsp),%rdx
test   %rdx,%rdx
je     130c <g+0x1ec>
lea    0xcfe(%rip),%rdi
mov    $0xf,%esi
call   1030 <printf@plt>
add    $0x88,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%2d: 0x%lx\0A\00"
define i32 @g() {
%1 = alloca i32
%2 = alloca [16 x i64]
%3 = alloca i32
%4 = getelementptr inbounds [16 x i64], [16 x i64]* %2, i64 0, i64 0
%5 = call i32 @getStackTrace(i64* %4, i32 16)
store i32 0, i32* %3
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [16 x i64], [16 x i64]* %2, i64 0, i64 %11
%13 = load i64, i64* %12
%14 = icmp ne i64 %13, 0
br label %15
15: ; preds = %9, %6
%16 = phi i1 [ false, %6 ], [ %14, %9 ]
br i1 %16, label %17, label %27
17: ; preds = %15
%18 = load i32, i32* %3
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [16 x i64], [16 x i64]* %2, i64 0, i64 %20
%22 = load i64, i64* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %18, i64 %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %6
27: ; preds = %15
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [12 x i8] c"%2d: 0x%lx\0A\00"
define i32 @g() {
%1 = alloca [16 x i64]
%2 = bitcast [16 x i64]* %1 to i8*
%3 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 0
%4 = call i32 @getStackTrace(i64* %3, i32 16)
%5 = load i64, i64* %3
%6 = icmp eq i64 %5, 0
br i1 %6, label %84, label %7
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0, i64 %5)
%9 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 1
%10 = load i64, i64* %9
%11 = icmp eq i64 %10, 0
br i1 %11, label %84, label %12
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 1, i64 %10)
%14 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 2
%15 = load i64, i64* %14
%16 = icmp eq i64 %15, 0
br i1 %16, label %84, label %17
17: ; preds = %12
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 2, i64 %15)
%19 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 3
%20 = load i64, i64* %19
%21 = icmp eq i64 %20, 0
br i1 %21, label %84, label %22
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 3, i64 %20)
%24 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 4
%25 = load i64, i64* %24
%26 = icmp eq i64 %25, 0
br i1 %26, label %84, label %27
27: ; preds = %22
%28 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 4, i64 %25)
%29 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 5
%30 = load i64, i64* %29
%31 = icmp eq i64 %30, 0
br i1 %31, label %84, label %32
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 5, i64 %30)
%34 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 6
%35 = load i64, i64* %34
%36 = icmp eq i64 %35, 0
br i1 %36, label %84, label %37
37: ; preds = %32
%38 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 6, i64 %35)
%39 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 7
%40 = load i64, i64* %39
%41 = icmp eq i64 %40, 0
br i1 %41, label %84, label %42
42: ; preds = %37
%43 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 7, i64 %40)
%44 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 8
%45 = load i64, i64* %44
%46 = icmp eq i64 %45, 0
br i1 %46, label %84, label %47
47: ; preds = %42
%48 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 8, i64 %45)
%49 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 9
%50 = load i64, i64* %49
%51 = icmp eq i64 %50, 0
br i1 %51, label %84, label %52
52: ; preds = %47
%53 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 9, i64 %50)
%54 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 10
%55 = load i64, i64* %54
%56 = icmp eq i64 %55, 0
br i1 %56, label %84, label %57
57: ; preds = %52
%58 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 10, i64 %55)
%59 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 11
%60 = load i64, i64* %59
%61 = icmp eq i64 %60, 0
br i1 %61, label %84, label %62
62: ; preds = %57
%63 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11, i64 %60)
%64 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 12
%65 = load i64, i64* %64
%66 = icmp eq i64 %65, 0
br i1 %66, label %84, label %67
67: ; preds = %62
%68 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 12, i64 %65)
%69 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 13
%70 = load i64, i64* %69
%71 = icmp eq i64 %70, 0
br i1 %71, label %84, label %72
72: ; preds = %67
%73 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 13, i64 %70)
%74 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 14
%75 = load i64, i64* %74
%76 = icmp eq i64 %75, 0
br i1 %76, label %84, label %77
77: ; preds = %72
%78 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 14, i64 %75)
%79 = getelementptr inbounds [16 x i64], [16 x i64]* %1, i64 0, i64 15
%80 = load i64, i64* %79
%81 = icmp eq i64 %80, 0
br i1 %81, label %84, label %82
82: ; preds = %77
%83 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 15, i64 %80)
br label %84
84: ; preds = %82, %77, %72, %67, %62, %57, %52, %47, %42, %37, %32, %27, %22, %17, %12, %7, %0
ret i32 undef
}