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

/* Variables and functions */
int /*<<< orphan*/ eiki_print_context(int /*<<< orphan*/ const *);
int /*<<< orphan*/ eiki_print_pid_prefix();
int /*<<< orphan*/ eiki_print_signal(int, int /*<<< orphan*/ const *);
int /*<<< orphan*/ eiki_print_stack_trace(int /*<<< orphan*/);
int /*<<< orphan*/ eiki_reraise_signal(int);
void eiki_signal_handler(int signum, const siginfo_t *info,
                         const ucontext_t *context) {
  eiki_print_pid_prefix();
  eiki_print_signal(signum, info);
  eiki_print_pid_prefix();
  eiki_print_stack_trace(0);
  eiki_print_pid_prefix();
  eiki_print_context(context);
  eiki_reraise_signal(signum);
}


x86 assembly (clang, -O0):
<eiki_signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1060 <eiki_print_pid_prefix@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <eiki_print_signal@plt>
mov    $0x0,%al
call   1060 <eiki_print_pid_prefix@plt>
xor    %edi,%edi
call   1070 <eiki_print_stack_trace@plt>
mov    $0x0,%al
call   1060 <eiki_print_pid_prefix@plt>
mov    -0x18(%rbp),%rdi
call   1030 <eiki_print_context@plt>
mov    -0x4(%rbp),%edi
call   1050 <eiki_reraise_signal@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eiki_signal_handler>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <eiki_print_pid_prefix@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <eiki_print_signal@plt>
xor    %eax,%eax
call   1060 <eiki_print_pid_prefix@plt>
xor    %edi,%edi
call   1070 <eiki_print_stack_trace@plt>
xor    %eax,%eax
call   1060 <eiki_print_pid_prefix@plt>
mov    %r14,%rdi
call   1030 <eiki_print_context@plt>
mov    %ebp,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <eiki_reraise_signal@plt>

LLVM IR (-O0):
define void @eiki_signal_handler(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%7 = call i32 (...) @eiki_print_pid_prefix()
%8 = load i32, i32* %4
%9 = load i32*, i32** %5
%10 = call i32 @eiki_print_signal(i32 %8, i32* %9)
%11 = call i32 (...) @eiki_print_pid_prefix()
%12 = call i32 @eiki_print_stack_trace(i32 0)
%13 = call i32 (...) @eiki_print_pid_prefix()
%14 = load i32*, i32** %6
%15 = call i32 @eiki_print_context(i32* %14)
%16 = load i32, i32* %4
%17 = call i32 @eiki_reraise_signal(i32 %16)
ret void
}

LLVM IR (-O2):
define void @eiki_signal_handler(i32 %0, i32* %1, i32* %2) {
%4 = tail call i32 (...) @eiki_print_pid_prefix()
%5 = tail call i32 @eiki_print_signal(i32 %0, i32* %1)
%6 = tail call i32 (...) @eiki_print_pid_prefix()
%7 = tail call i32 @eiki_print_stack_trace(i32 0)
%8 = tail call i32 (...) @eiki_print_pid_prefix()
%9 = tail call i32 @eiki_print_context(i32* %2)
%10 = tail call i32 @eiki_reraise_signal(i32 %0)
ret void
}