#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;

/* Variables and functions */
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, char const *,
                         char const *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/);
char *show_backtrace(char *);
int /*<<< orphan*/ sig_info(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void sig_action(int number, siginfo_t *info, void *data, const char *signame,
                const char *sigmsg) {
  const char *logname;
  fputs(signame, stderr);
  fputc('\n', stderr);
  fputs(sigmsg, stderr);
  fputs("\nTrying to print backtrace, mail it to your technical support.\n",
        stderr);
  logname = show_backtrace("SIGSEGV");
  sig_info(info);
  error(-number, 0, "%s! check backtrace at \"%s\".\n", signame, logname);
}


x86 assembly (clang, -O0):
<sig_action>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1040 <fputc@plt>
mov    -0x28(%rbp),%rdi
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
lea    0xe4e(%rip),%rdi
call   1030 <fputs@plt>
lea    0xe82(%rip),%rdi
call   1070 <show_backtrace@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <sig_info@plt>
xor    %edi,%edi
sub    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%r8
xor    %esi,%esi
lea    0xe62(%rip),%rdx
call   1060 <error@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_action>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r12
mov    %rcx,%r15
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e76(%rip),%rbx
mov    (%rbx),%esi
mov    %rcx,%rdi
call   1030 <fputs@plt>
mov    (%rbx),%esi
mov    $0xa,%edi
call   1040 <fputc@plt>
mov    (%rbx),%esi
mov    %r12,%rdi
call   1030 <fputs@plt>
mov    (%rbx),%esi
lea    0xe6d(%rip),%rdi
call   1030 <fputs@plt>
lea    0xea1(%rip),%rdi
call   1070 <show_backtrace@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <sig_info@plt>
neg    %ebp
lea    0xe90(%rip),%rdx
mov    %ebp,%edi
xor    %esi,%esi
mov    %r15,%rcx
mov    %rbx,%r8
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <error@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [64 x i8] c"\0ATrying to print backtrace, mail it to your technical support.\0A\00"
@.str.1 = [8 x i8] c"SIGSEGV\00"
@.str.2 = [30 x i8] c"%s! check backtrace at \22%s\22.\0A\00"
define void @sig_action(i32 %0, i32* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 %0, i32* %6
store i32* %1, i32** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i8*, i8** %9
%13 = load i32, i32* @stderr
%14 = call i32 @fputs(i8* %12, i32 %13)
%15 = load i32, i32* @stderr
%16 = call i32 @fputc(i8 signext 10, i32 %15)
%17 = load i8*, i8** %10
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* %17, i32 %18)
%20 = load i32, i32* @stderr
%21 = call i32 @fputs(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = call i8* @show_backtrace(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %22, i8** %11
%23 = load i32*, i32** %7
%24 = call i32 @sig_info(i32* %23)
%25 = load i32, i32* %6
%26 = sub nsw i32 0, %25
%27 = load i8*, i8** %9
%28 = load i8*, i8** %11
%29 = call i32 @error(i32 %26, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %28)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [64 x i8] c"\0ATrying to print backtrace, mail it to your technical support.\0A\00"
@.str.1 = [8 x i8] c"SIGSEGV\00"
@.str.2 = [30 x i8] c"%s! check backtrace at \22%s\22.\0A\00"
define void @sig_action(i32 %0, i32* %1, i8* nocapture readnone %2, i8* %3, i8* %4) {
%6 = load i32, i32* @stderr
%7 = tail call i32 @fputs(i8* %3, i32 %6)
%8 = load i32, i32* @stderr
%9 = tail call i32 @fputc(i8 signext 10, i32 %8)
%10 = load i32, i32* @stderr
%11 = tail call i32 @fputs(i8* %4, i32 %10)
%12 = load i32, i32* @stderr
%13 = tail call i32 @fputs(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i8* @show_backtrace(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @sig_info(i32* %1)
%16 = sub nsw i32 0, %0
%17 = tail call i32 @error(i32 %16, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %3, i8* %14)
ret void
}