#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int si_pid;
};
typedef TYPE_1__ siginfo_t;

/* Variables and functions */
#define SIGABRT 158
#define SIGALRM 157
#define SIGBUS 156
#define SIGCLD 155
#define SIGCONT 154
#define SIGFPE 153
#define SIGHUP 152
#define SIGILL 151
#define SIGINT 150
#define SIGKILL 149
#define SIGPIPE 148
#define SIGPOLL 147
#define SIGPROF 146
#define SIGPWR 145
#define SIGQUIT 144
#define SIGSEGV 143
#define SIGSTKFLT 142
#define SIGSTOP 141
#define SIGSYS 140
#define SIGTERM 139
#define SIGTRAP 138
#define SIGTSTP 137
#define SIGTTIN 136
#define SIGTTOU 135
#define SIGURG 134
#define SIGUSR1 133
#define SIGUSR2 132
#define SIGVTALRM 131
#define SIGWINCH 130
#define SIGXCPU 129
#define SIGXFSZ 128
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *, int);
int /*<<< orphan*/ signal(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strsignal(int);
void debug_signal_handler(int signo, siginfo_t *siginfo, void *ucontext) {
  fprintf(stderr, "signal %d (%s) received from %d\n", signo, strsignal(signo),
          siginfo->si_pid);
  switch (signo) {
  case SIGHUP:
    break;
  case SIGINT:
    break;
  case SIGQUIT:
    break;
  case SIGILL:
    break;
  case SIGTRAP:
    break;
  case SIGABRT:
    break;
  case SIGBUS:
    break;
  case SIGFPE:
    break;
  case SIGKILL:
    break;
  case SIGUSR1:
    break;
  case SIGSEGV:
    signal(signo, SIG_IGN);
    break;
  case SIGUSR2:
    break;
  case SIGPIPE:
    break;
  case SIGALRM:
    break;
  case SIGTERM:
    break;
  case SIGSTKFLT:
    break;
  case SIGCLD:
    break;
  case SIGCONT:
    break;
  case SIGSTOP:
    break;
  case SIGTSTP:
    break;
  case SIGTTIN:
    break;
  case SIGTTOU:
    break;
  case SIGURG:
    break;
  case SIGXCPU:
    break;
  case SIGXFSZ:
    break;
  case SIGVTALRM:
    break;
  case SIGPROF:
    break;
  case SIGWINCH:
    break;
  case SIGPOLL:
    break;
  case SIGPWR:
    break;
  case SIGSYS:
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<debug_signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    %edi,-0x24(%rbp)
call   1050 <strsignal@plt>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%edx
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
lea    0xf0b(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1e,%eax
ja     124b <debug_signal_handler+0x11b>
mov    -0x20(%rbp),%rax
lea    0xe6a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
mov    -0x4(%rbp),%edi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
jmp    1250 <debug_signal_handler+0x120>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_signal_handler>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e98(%rip),%rax
mov    (%rax),%r14d
call   1050 <strsignal@plt>
mov    (%rbx),%r8d
lea    0xeae(%rip),%rsi
mov    %r14d,%edi
mov    %ebp,%edx
mov    %rax,%rcx
call   1040 <fprintf@plt>
cmp    $0x8f,%ebp
jne    117e <debug_signal_handler+0x4e>
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    $0x8f,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <signal@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"signal %d (%s) received from %d\0A\00"
@SIG_IGN = global i32 0
define void @debug_signal_handler(i32 %0, %struct.TYPE_3__* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
store i32 %0, i32* %4
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %5
store i8* %2, i8** %6
%7 = load i32, i32* @stderr
%8 = load i32, i32* %4
%9 = load i32, i32* %4
%10 = call i8* @strsignal(i32 %9)
%11 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %10, i32 %13)
%15 = load i32, i32* %4
switch i32 %15, label %50 [
i32 152, label %16
i32 150, label %17
i32 144, label %18
i32 151, label %19
i32 138, label %20
i32 158, label %21
i32 156, label %22
i32 153, label %23
i32 149, label %24
i32 133, label %25
i32 143, label %26
i32 132, label %30
i32 148, label %31
i32 157, label %32
i32 139, label %33
i32 142, label %34
i32 155, label %35
i32 154, label %36
i32 141, label %37
i32 137, label %38
i32 136, label %39
i32 135, label %40
i32 134, label %41
i32 129, label %42
i32 128, label %43
i32 131, label %44
i32 146, label %45
i32 130, label %46
i32 147, label %47
i32 145, label %48
i32 140, label %49
]
16: ; preds = %3
br label %51
17: ; preds = %3
br label %51
18: ; preds = %3
br label %51
19: ; preds = %3
br label %51
20: ; preds = %3
br label %51
21: ; preds = %3
br label %51
22: ; preds = %3
br label %51
23: ; preds = %3
br label %51
24: ; preds = %3
br label %51
25: ; preds = %3
br label %51
26: ; preds = %3
%27 = load i32, i32* %4
%28 = load i32, i32* @SIG_IGN
%29 = call i32 @signal(i32 %27, i32 %28)
br label %51
30: ; preds = %3
br label %51
31: ; preds = %3
br label %51
32: ; preds = %3
br label %51
33: ; preds = %3
br label %51
34: ; preds = %3
br label %51
35: ; preds = %3
br label %51
36: ; preds = %3
br label %51
37: ; preds = %3
br label %51
38: ; preds = %3
br label %51
39: ; preds = %3
br label %51
40: ; preds = %3
br label %51
41: ; preds = %3
br label %51
42: ; preds = %3
br label %51
43: ; preds = %3
br label %51
44: ; preds = %3
br label %51
45: ; preds = %3
br label %51
46: ; preds = %3
br label %51
47: ; preds = %3
br label %51
48: ; preds = %3
br label %51
49: ; preds = %3
br label %51
50: ; preds = %3
br label %51
51: ; preds = %50, %49, %48, %47, %46, %45, %44, %43, %42, %41, %40, %39, %38, %37, %36, %35, %34, %33, %32, %31, %30, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"signal %d (%s) received from %d\0A\00"
@SIG_IGN = global i32 0
define void @debug_signal_handler(i32 %0, %struct.TYPE_3__* nocapture %1, i8* nocapture readnone %2) {
%4 = load i32, i32* @stderr
%5 = tail call i8* @strsignal(i32 %0)
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %5, i32 %7)
%9 = icmp eq i32 %0, 143
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32, i32* @SIG_IGN
%12 = tail call i32 @signal(i32 143, i32 %11)
br label %13
13: ; preds = %3, %10
ret void
}