#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 */
#define SIGCONT 132
#define SIGHUP 131
#define SIGINT 130
#define SIGKILL 129
#define SIGTERM 128
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ say(char *);
void sighandler(int sig) {
  switch (sig) {
  case SIGKILL:
    say("dying on SIGKILL");
    _exit(0);
    break;
  case SIGINT:
    say("dying on SIGINT");
    _exit(0);
    break;
  case SIGTERM:
    say("dying on SIGTERM");
    _exit(0);
    break;
  case SIGHUP:
    say("got SIGHUP");
    break;
  case SIGCONT:
    say("got SIGCONT, continuing");
    break;
  default:
    say("ignoring unexpected signal");
    break;
  }
}


x86 assembly (clang, -O0):
<sighandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     11af <sighandler+0x8f>
mov    -0x10(%rbp),%rax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb9(%rip),%rdi
call   1040 <say@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
lea    0xeb7(%rip),%rdi
call   1040 <say@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
lea    0xeb4(%rip),%rdi
call   1040 <say@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
lea    0xeb2(%rip),%rdi
call   1040 <say@plt>
jmp    11bb <sighandler+0x9b>
lea    0xeac(%rip),%rdi
call   1040 <say@plt>
jmp    11bb <sighandler+0x9b>
lea    0xeb3(%rip),%rdi
call   1040 <say@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sighandler>:
push   %rax
mov    %edi,%eax
add    $0xffffff80,%eax
cmp    $0x4,%eax
ja     114f <sighandler+0x2f>
lea    0xf14(%rip),%rdi
lea    0xec7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf08(%rip),%rdi
pop    %rax
jmp    1040 <say@plt>
lea    0xf13(%rip),%rdi
pop    %rax
jmp    1040 <say@plt>
lea    0xed2(%rip),%rdi
jmp    1175 <sighandler+0x55>
lea    0xea8(%rip),%rdi
jmp    1175 <sighandler+0x55>
lea    0xeb0(%rip),%rdi
call   1040 <say@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"dying on SIGKILL\00"
@.str.1 = [16 x i8] c"dying on SIGINT\00"
@.str.2 = [17 x i8] c"dying on SIGTERM\00"
@.str.3 = [11 x i8] c"got SIGHUP\00"
@.str.4 = [24 x i8] c"got SIGCONT, continuing\00"
@.str.5 = [27 x i8] c"ignoring unexpected signal\00"
define void @sighandler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %17 [
i32 129, label %4
i32 130, label %7
i32 128, label %10
i32 131, label %13
i32 132, label %15
]
4: ; preds = %1
%5 = call i32 @say(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @_exit(i32 0)
unreachable
7: ; preds = %1
%8 = call i32 @say(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @_exit(i32 0)
unreachable
10: ; preds = %1
%11 = call i32 @say(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @_exit(i32 0)
unreachable
13: ; preds = %1
%14 = call i32 @say(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %19
15: ; preds = %1
%16 = call i32 @say(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %19
17: ; preds = %1
%18 = call i32 @say(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %19
19: ; preds = %17, %15, %13
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"dying on SIGKILL\00"
@.str.1 = [16 x i8] c"dying on SIGINT\00"
@.str.2 = [17 x i8] c"dying on SIGTERM\00"
@.str.3 = [11 x i8] c"got SIGHUP\00"
@.str.4 = [24 x i8] c"got SIGCONT, continuing\00"
@.str.5 = [27 x i8] c"ignoring unexpected signal\00"
define void @sighandler(i32 %0) {
switch i32 %0, label %12 [
i32 129, label %2
i32 130, label %5
i32 128, label %8
i32 131, label %13
i32 132, label %11
]
2: ; preds = %1
%3 = tail call i32 @say(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @_exit(i32 0)
unreachable
5: ; preds = %1
%6 = tail call i32 @say(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @_exit(i32 0)
unreachable
8: ; preds = %1
%9 = tail call i32 @say(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @_exit(i32 0)
unreachable
11: ; preds = %1
br label %13
12: ; preds = %1
br label %13
13: ; preds = %1, %12, %11
%14 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), %12 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), %11 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %1 ]
%15 = tail call i32 @say(i8* %14)
ret void
}