#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 get_backtrace(void **, int);
int /*<<< orphan*/ print_backtrace(void **, int);
int /*<<< orphan*/ printf(char *, ...);
void __attribute__((no)) f1() {
  int len;
  void *arr[32];
  printf("f1: ++get_backtrace\n");
  len = get_backtrace(arr, 32);
  printf("f1: --get_backtrace %d\n", len);
  printf("f1: ++print_backtrace\n");
  print_backtrace(arr, len);
  printf("f1: --print_backtrace\n");
}


x86 assembly (clang, -O0):
<f1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    $0x20,%esi
call   1050 <get_backtrace@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1030 <print_backtrace@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f1>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1060 <get_backtrace@plt>
mov    %eax,%ebp
lea    0xe92(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <print_backtrace@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"f1: ++get_backtrace\0A\00"
@.str.1 = [24 x i8] c"f1: --get_backtrace %d\0A\00"
@.str.2 = [23 x i8] c"f1: ++print_backtrace\0A\00"
@.str.3 = [23 x i8] c"f1: --print_backtrace\0A\00"
define void @f1() {
%1 = alloca i32
%2 = alloca [32 x i8*]
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [32 x i8*], [32 x i8*]* %2, i64 0, i64 0
%5 = call i32 @get_backtrace(i8** %4, i32 32)
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%9 = getelementptr inbounds [32 x i8*], [32 x i8*]* %2, i64 0, i64 0
%10 = load i32, i32* %1
%11 = call i32 @print_backtrace(i8** %9, i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"f1: --get_backtrace %d\0A\00"
@str = [20 x i8] c"f1: ++get_backtrace\00"
@str.4 = [22 x i8] c"f1: ++print_backtrace\00"
@str.5 = [22 x i8] c"f1: --print_backtrace\00"
define void @f1() {
%1 = alloca [32 x i8*]
%2 = bitcast [32 x i8*]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [32 x i8*], [32 x i8*]* %1, i64 0, i64 0
%5 = call i32 @get_backtrace(i8** %4, i32 32)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
%8 = call i32 @print_backtrace(i8** %4, i32 %5)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
ret void
}