#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 */
typedef int /*<<< orphan*/ siginfo_t;
typedef int /*<<< orphan*/ __sighandler_t;

/* Variables and functions */
int /*<<< orphan*/ dump_terminate();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
__sighandler_t dump_sig_handler(int sig, siginfo_t *sip, void *p) {
  {
    fprintf(stderr, "ERROR: ");
    fprintf(stderr, "Got signal: %i\n", sig);
  };
  {
    fprintf(stderr, "ERROR: ");
    fprintf(stderr, "Dump failed!\n");
  };
  dump_terminate();
  return 0;
}


x86 assembly (clang, -O0):
<dump_sig_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%edi
lea    0xebd(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <dump_terminate@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_sig_handler>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
mov    0x2eb2(%rip),%r15
mov    (%r15),%edi
lea    0xec8(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r15),%edi
lea    0xebc(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r15),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r15),%edi
lea    0xeac(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <dump_terminate@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [8 x i8] c"ERROR: \00"
@.str.1 = [16 x i8] c"Got signal: %i\0A\00"
@.str.2 = [14 x i8] c"Dump failed!\0A\00"
define i32 @dump_sig_handler(i32 %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
store i32 %0, i32* %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = load i32, i32* %4
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (...) @dump_terminate()
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c"ERROR: \00"
@.str.1 = [16 x i8] c"Got signal: %i\0A\00"
@.str.2 = [14 x i8] c"Dump failed!\0A\00"
define i32 @dump_sig_handler(i32 %0, i32* nocapture readnone %1, i8* nocapture readnone %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 (...) @dump_terminate()
ret i32 0
}