#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);
int /*<<< orphan*/ backtrace_symbols_fd(void **, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void __softboundmpx_abort() {
  fprintf(stderr,
          "\nSoftboundmpx: Memory safety violation detected\n\nBacktrace:\n");
  size_t size;
  void *array[100];
  size = backtrace(array, 100);
  backtrace_symbols_fd(array, size, fileno(stderr));
  fprintf(stderr, "\n\n");
  abort();
}


x86 assembly (clang, -O0):
<__softboundmpx_abort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x330(%rbp),%rdi
mov    $0x64,%esi
call   1050 <backtrace@plt>
mov    %rax,-0x8(%rbp)
lea    -0x330(%rbp),%rax
mov    %rax,-0x340(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x338(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1070 <fileno@plt>
mov    -0x340(%rbp),%rdi
mov    -0x338(%rbp),%rsi
mov    %eax,%edx
call   1030 <backtrace_symbols_fd@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>

x86 assembly (clang, -O2):
<__softboundmpx_abort>:
push   %r15
push   %r14
push   %rbx
sub    $0x320,%rsp
mov    0x2e7d(%rip),%r15
mov    (%r15),%edi
lea    0xe93(%rip),%rsi
call   1060 <fprintf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x64,%esi
call   1050 <backtrace@plt>
mov    %rax,%rbx
mov    (%r15),%edi
call   1070 <fileno@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <backtrace_symbols_fd@plt>
mov    (%r15),%edi
lea    0xe99(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [61 x i8] c"\0ASoftboundmpx: Memory safety violation detected\0A\0ABacktrace:\0A\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
define void @__softboundmpx_abort() {
%1 = alloca i64
%2 = alloca [100 x i8*]
%3 = load i32, i32* @stderr
%4 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 0
%6 = call i64 @backtrace(i8** %5, i32 100)
store i64 %6, i64* %1
%7 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 0
%8 = load i64, i64* %1
%9 = load i32, i32* @stderr
%10 = call i32 @fileno(i32 %9)
%11 = call i32 @backtrace_symbols_fd(i8** %7, i64 %8, i32 %10)
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [61 x i8] c"\0ASoftboundmpx: Memory safety violation detected\0A\0ABacktrace:\0A\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
define void @__softboundmpx_abort() {
%1 = alloca [100 x i8*]
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [100 x i8*]* %1 to i8*
%5 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 0
%6 = call i64 @backtrace(i8** %5, i32 100)
%7 = load i32, i32* @stderr
%8 = call i32 @fileno(i32 %7)
%9 = call i32 @backtrace_symbols_fd(i8** %5, i64 %6, i32 %8)
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (...) @abort()
unreachable
}