#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*/ STDOUT_FILENO;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ show_backtrace();
int /*<<< orphan*/ sprintf(char *, char const *, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int /*<<< orphan*/);
void OsSigHandler(int no) {
  const char btline[] = "Killed by Signal %d\n";
  char buf[128];
  sprintf(buf, btline, no);
  write(STDOUT_FILENO, buf, strlen(buf));
  show_backtrace();
  exit(-no);
}


x86 assembly (clang, -O0):
<OsSigHandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
mov    0xe9b(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe98(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe96(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe91(%rip),%al
mov    %al,-0xc(%rbp)
lea    -0xa0(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1050 <sprintf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x0,%al
call   1070 <show_backtrace@plt>
xor    %edi,%edi
sub    -0x4(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<OsSigHandler>:
push   %rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %edi,%ebx
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0xa6425206c616e,%rax
mov    %rax,0xd(%rsp)
lea    0x20(%rsp),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %eax,%eax
call   1070 <show_backtrace@plt>
neg    %ebx
mov    %ebx,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@__const.OsSigHandler.btline = [21 x i8] c"Killed by Signal %d\0A\00"
@STDOUT_FILENO = global i32 0
define void @OsSigHandler(i32 %0) {
%2 = alloca i32
%3 = alloca [21 x i8]
%4 = alloca [128 x i8]
store i32 %0, i32* %2
%5 = bitcast [21 x i8]* %3 to i8*
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* %2
%9 = call i32 @sprintf(i8* %6, i8* %7, i32 %8)
%10 = load i32, i32* @STDOUT_FILENO
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @write(i32 %10, i8* %11, i32 %13)
%15 = call i32 (...) @show_backtrace()
%16 = load i32, i32* %2
%17 = sub nsw i32 0, %16
%18 = call i32 @exit(i32 %17)
unreachable
}

LLVM IR (-O2):
@__const.OsSigHandler.btline = [21 x i8] c"Killed by Signal %d\0A\00"
@STDOUT_FILENO = global i32 0
define void @OsSigHandler(i32 %0) {
%2 = alloca [21 x i8]
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* %4, i32 %0)
%7 = load i32, i32* @STDOUT_FILENO
%8 = call i32 @strlen(i8* %5)
%9 = call i32 @write(i32 %7, i8* %5, i32 %8)
%10 = call i32 (...) @show_backtrace()
%11 = sub nsw i32 0, %0
%12 = call i32 @exit(i32 %11)
unreachable
}