#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 backtrace(void **, int);
int /*<<< orphan*/ backtrace_symbols_fd(void **, int, int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void print_c_trace(void) {
  void *buffer[128];
  int size = backtrace(buffer, 128);
  fprintf(stderr, "C stack trace (most recent call first):\n");
  fflush(stderr);
  backtrace_symbols_fd(buffer, size, fileno(stderr));
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<print_c_trace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    -0x400(%rbp),%rdi
mov    $0x80,%esi
call   1040 <backtrace@plt>
mov    %eax,-0x404(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x400(%rbp),%rax
mov    %rax,-0x410(%rbp)
mov    -0x404(%rbp),%eax
mov    %eax,-0x408(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
mov    -0x410(%rbp),%rdi
mov    -0x408(%rbp),%esi
mov    %eax,%edx
call   1030 <backtrace_symbols_fd@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_c_trace>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x80,%esi
call   1040 <backtrace@plt>
mov    %eax,%ebp
mov    0x2e6c(%rip),%rbx
mov    (%rbx),%edi
lea    0xe83(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    (%rbx),%edi
call   1060 <fileno@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <backtrace_symbols_fd@plt>
mov    (%rbx),%edi
lea    0xe82(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"C stack trace (most recent call first):\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_c_trace() {
%1 = alloca [128 x i8*]
%2 = alloca i32
%3 = getelementptr inbounds [128 x i8*], [128 x i8*]* %1, i64 0, i64 0
%4 = call i32 @backtrace(i8** %3, i32 128)
store i32 %4, i32* %2
%5 = load i32, i32* @stderr
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = call i32 @fflush(i32 %7)
%9 = getelementptr inbounds [128 x i8*], [128 x i8*]* %1, i64 0, i64 0
%10 = load i32, i32* %2
%11 = load i32, i32* @stderr
%12 = call i32 @fileno(i32 %11)
%13 = call i32 @backtrace_symbols_fd(i8** %9, i32 %10, i32 %12)
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"C stack trace (most recent call first):\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_c_trace() {
%1 = alloca [128 x i8*]
%2 = bitcast [128 x i8*]* %1 to i8*
%3 = getelementptr inbounds [128 x i8*], [128 x i8*]* %1, i64 0, i64 0
%4 = call i32 @backtrace(i8** %3, i32 128)
%5 = load i32, i32* @stderr
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = call i32 @fflush(i32 %7)
%9 = load i32, i32* @stderr
%10 = call i32 @fileno(i32 %9)
%11 = call i32 @backtrace_symbols_fd(i8** %3, i32 %4, i32 %10)
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}