#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*/ abort();
size_t backtrace(void **, int);
char **backtrace_symbols(void **, size_t);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char **);
int /*<<< orphan*/ stderr;
void _abort() {
  void *bt[128];
  char **strings;
  size_t size;
  size = backtrace(bt, 128);
  strings = backtrace_symbols(bt, size);
  fprintf(stderr, "\nfatal error; backtrace:\n");
  for (int i = 0; i < size; i++) {
    fprintf(stderr, "%s\n", strings[i]);
  }
  fflush(stderr);
  free(strings);
  abort();
}


x86 assembly (clang, -O0):
<_abort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    -0x400(%rbp),%rdi
mov    $0x80,%esi
call   1060 <backtrace@plt>
mov    %rax,-0x410(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x410(%rbp),%rsi
call   1050 <backtrace_symbols@plt>
mov    %rax,-0x408(%rbp)
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x414(%rbp)
movslq -0x414(%rbp),%rax
cmp    -0x410(%rbp),%rax
jae    120f <_abort+0xaf>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
mov    -0x408(%rbp),%rax
movslq -0x414(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    11be <_abort+0x5e>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    -0x408(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1040 <abort@plt>

x86 assembly (clang, -O2):
<_abort>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x80,%esi
call   1060 <backtrace@plt>
mov    %rax,%r13
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <backtrace_symbols@plt>
mov    %rax,%r14
mov    0x2e48(%rip),%r12
mov    (%r12),%edi
lea    0xe5d(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %r13,%r13
je     11db <_abort+0x7b>
lea    0xe64(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edi
mov    (%r14,%rbx,8),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11c0 <_abort+0x60>
mov    (%r12),%edi
call   1080 <fflush@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"\0Afatal error; backtrace:\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @_abort() {
%1 = alloca [128 x i8*]
%2 = alloca i8**
%3 = alloca i64
%4 = alloca i32
%5 = getelementptr inbounds [128 x i8*], [128 x i8*]* %1, i64 0, i64 0
%6 = call i64 @backtrace(i8** %5, i32 128)
store i64 %6, i64* %3
%7 = getelementptr inbounds [128 x i8*], [128 x i8*]* %1, i64 0, i64 0
%8 = load i64, i64* %3
%9 = call i8** @backtrace_symbols(i8** %7, i64 %8)
store i8** %9, i8*** %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %12
12: ; preds = %25, %0
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = load i64, i64* %3
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %28
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %17
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %12
28: ; preds = %12
%29 = load i32, i32* @stderr
%30 = call i32 @fflush(i32 %29)
%31 = load i8**, i8*** %2
%32 = call i32 @free(i8** %31)
%33 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"\0Afatal error; backtrace:\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @_abort() {
%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 i64 @backtrace(i8** %3, i32 128)
%5 = call i8** @backtrace_symbols(i8** %3, i64 %4)
%6 = load i32, i32* @stderr
%7 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %4, 0
br i1 %8, label %9, label %14
9: ; preds = %14, %0
%10 = load i32, i32* @stderr
%11 = call i32 @fflush(i32 %10)
%12 = call i32 @free(i8** %5)
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %0, %14
%15 = phi i64 [ %20, %14 ], [ 0, %0 ]
%16 = load i32, i32* @stderr
%17 = getelementptr inbounds i8*, i8** %5, i64 %15
%18 = load i8*, i8** %17
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = add nuw i64 %15, 1
%21 = icmp eq i64 %20, %4
br i1 %21, label %9, label %14
}