#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 SIGABRT 140
#define SIGALRM 139
#define SIGBUS 138
#define SIGFPE 137
#define SIGHUP 136
#define SIGILL 135
#define SIGINT 134
#define SIGKILL 133
#define SIGPIPE 132
#define SIGQUIT 131
#define SIGSEGV 130
#define SIGTERM 129
#define SIGTRAP 128
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void sigmsg(int sig) {
  char *msg;
  switch (sig) {
  case SIGKILL:
    msg = "Killed";
    break;
  case SIGABRT:
    msg = "Aborted";
    break;
  case SIGBUS:
    msg = "Bus error";
    break;
  case SIGFPE:
    msg = "Bad math";
    break;
  case SIGHUP:
    msg = "Hangup";
    break;
  case SIGILL:
    msg = "Illegal instruction";
    break;
  case SIGINT:
    msg = "Interrupted";
    break;
  case SIGPIPE:
    msg = "Broken pipe";
    break;
  case SIGQUIT:
    msg = "Quit";
    break;
  case SIGSEGV:
    msg = "Memory violation";
    break;
  case SIGTERM:
    msg = "Terminated";
    break;
  case SIGALRM:
    msg = "Alarm";
    break;
  case SIGTRAP:
    msg = "Trace";
    break;
  default:
    msg = "Other signal";
    break;
  }
  fputs(msg, stderr);
  fputs("\n", stderr);
}


x86 assembly (clang, -O0):
<sigmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xc,%eax
ja     1214 <sigmsg+0x104>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee9(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xee0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xed8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xed2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xecb(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xec2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xec6(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xec2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xebe(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xeb3(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xeb4(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xeaf(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xea5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    121f <sigmsg+0x10f>
lea    0xe9b(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%esi
lea    0xe82(%rip),%rdi
call   1030 <fputs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigmsg>:
push   %rbx
add    $0xffffff80,%edi
cmp    $0xc,%edi
ja     112c <sigmsg+0x1c>
movslq %edi,%rax
lea    0xf71(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1133 <sigmsg+0x23>
lea    0xf4f(%rip),%rdi
mov    0x2ea6(%rip),%rbx
mov    (%rbx),%esi
call   1030 <fputs@plt>
mov    (%rbx),%esi
lea    0xf45(%rip),%rdi
pop    %rbx
jmp    1030 <fputs@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"Killed\00"
@.str.1 = [8 x i8] c"Aborted\00"
@.str.2 = [10 x i8] c"Bus error\00"
@.str.3 = [9 x i8] c"Bad math\00"
@.str.4 = [7 x i8] c"Hangup\00"
@.str.5 = [20 x i8] c"Illegal instruction\00"
@.str.6 = [12 x i8] c"Interrupted\00"
@.str.7 = [12 x i8] c"Broken pipe\00"
@.str.8 = [5 x i8] c"Quit\00"
@.str.9 = [17 x i8] c"Memory violation\00"
@.str.10 = [11 x i8] c"Terminated\00"
@.str.11 = [6 x i8] c"Alarm\00"
@.str.12 = [6 x i8] c"Trace\00"
@.str.13 = [13 x i8] c"Other signal\00"
@stderr = global i32 0
@.str.14 = [2 x i8] c"\0A\00"
define void @sigmsg(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %18 [
i32 133, label %5
i32 140, label %6
i32 138, label %7
i32 137, label %8
i32 136, label %9
i32 135, label %10
i32 134, label %11
i32 132, label %12
i32 131, label %13
i32 130, label %14
i32 129, label %15
i32 139, label %16
i32 128, label %17
]
5: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %3
br label %19
6: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %19
7: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %19
8: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %19
9: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %19
10: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %19
11: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %19
12: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %19
13: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %19
14: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %19
15: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %19
16: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %19
17: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %19
18: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8** %3
br label %19
19: ; preds = %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%20 = load i8*, i8** %3
%21 = load i32, i32* @stderr
%22 = call i32 @fputs(i8* %20, i32 %21)
%23 = load i32, i32* @stderr
%24 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i32 %23)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Killed\00"
@.str.1 = [8 x i8] c"Aborted\00"
@.str.2 = [10 x i8] c"Bus error\00"
@.str.3 = [9 x i8] c"Bad math\00"
@.str.4 = [7 x i8] c"Hangup\00"
@.str.5 = [20 x i8] c"Illegal instruction\00"
@.str.6 = [12 x i8] c"Interrupted\00"
@.str.7 = [12 x i8] c"Broken pipe\00"
@.str.8 = [5 x i8] c"Quit\00"
@.str.9 = [17 x i8] c"Memory violation\00"
@.str.10 = [11 x i8] c"Terminated\00"
@.str.11 = [6 x i8] c"Alarm\00"
@.str.12 = [6 x i8] c"Trace\00"
@.str.13 = [13 x i8] c"Other signal\00"
@stderr = global i32 0
@.str.14 = [2 x i8] c"\0A\00"
@reltable.sigmsg = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.sigmsg to i64)) to i32)]
define void @sigmsg(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 13
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.sigmsg to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), %1 ]
%10 = load i32, i32* @stderr
%11 = tail call i32 @fputs(i8* %9, i32 %10)
%12 = load i32, i32* @stderr
%13 = tail call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i32 %12)
ret void
}