#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 SIGALRM 134
#define SIGCONT 133
#define SIGINT 132
#define SIGKILL 131
#define SIGQUIT 130
#define SIGUSR1 129
#define SIGUSR2 128
int /*<<< orphan*/ strcpy(char *, char *);
int mysig2str(int signo, char *name) {
  switch (signo) {
  case SIGKILL:
    strcpy(name, "KILL");
    break;
  case SIGALRM:
    strcpy(name, "ALRM");
    break;
  case SIGUSR1:
    strcpy(name, "USR1");
    break;
  case SIGUSR2:
    strcpy(name, "USR2");
    break;
  case SIGQUIT:
    strcpy(name, "QUIT");
    break;
  case SIGCONT:
    strcpy(name, "CONT");
    break;
  case SIGINT:
    strcpy(name, "INT");
    break;
  default:
    strcpy(name, "UNKNOWN");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<mysig2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x6,%eax
ja     11db <mysig2str+0xcb>
mov    -0x18(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11f7 <mysig2str+0xe7>
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11f7 <mysig2str+0xe7>
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11f7 <mysig2str+0xe7>
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11f7 <mysig2str+0xe7>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11f7 <mysig2str+0xe7>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11f7 <mysig2str+0xe7>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11f7 <mysig2str+0xe7>
mov    -0x10(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fe <mysig2str+0xee>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysig2str>:
push   %rbx
mov    %rsi,%rax
add    $0xffffff80,%edi
cmp    $0x6,%edi
ja     1131 <mysig2str+0x21>
movslq %edi,%rcx
lea    0xf06(%rip),%rdx
movslq (%rdx,%rcx,4),%rsi
add    %rdx,%rsi
xor    %ebx,%ebx
jmp    113d <mysig2str+0x2d>
mov    $0xffffffff,%ebx
lea    0xee5(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"KILL\00"
@.str.1 = [5 x i8] c"ALRM\00"
@.str.2 = [5 x i8] c"USR1\00"
@.str.3 = [5 x i8] c"USR2\00"
@.str.4 = [5 x i8] c"QUIT\00"
@.str.5 = [5 x i8] c"CONT\00"
@.str.6 = [4 x i8] c"INT\00"
@.str.7 = [8 x i8] c"UNKNOWN\00"
define i32 @mysig2str(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i32, i32* %4
switch i32 %6, label %28 [
i32 131, label %7
i32 134, label %10
i32 129, label %13
i32 128, label %16
i32 130, label %19
i32 133, label %22
i32 132, label %25
]
7: ; preds = %2
%8 = load i8*, i8** %5
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %31
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %31
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %31
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %31
19: ; preds = %2
%20 = load i8*, i8** %5
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %31
22: ; preds = %2
%23 = load i8*, i8** %5
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %31
25: ; preds = %2
%26 = load i8*, i8** %5
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %31
28: ; preds = %2
%29 = load i8*, i8** %5
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %32
31: ; preds = %25, %22, %19, %16, %13, %10, %7
store i32 0, i32* %3
br label %32
32: ; preds = %31, %28
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [5 x i8] c"KILL\00"
@.str.1 = [5 x i8] c"ALRM\00"
@.str.2 = [5 x i8] c"USR1\00"
@.str.3 = [5 x i8] c"USR2\00"
@.str.4 = [5 x i8] c"QUIT\00"
@.str.5 = [5 x i8] c"CONT\00"
@.str.6 = [4 x i8] c"INT\00"
@.str.7 = [8 x i8] c"UNKNOWN\00"
@reltable.mysig2str = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.mysig2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.mysig2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.mysig2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.mysig2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.mysig2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.mysig2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.mysig2str to i64)) to i32)]
define i32 @mysig2str(i32 %0, i8* %1) {
%3 = add i32 %0, -128
%4 = icmp ult i32 %3, 7
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = sext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.mysig2str to i8*), i64 %7)
br label %9
9: ; preds = %2, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), %2 ]
%11 = phi i32 [ 0, %5 ], [ -1, %2 ]
%12 = tail call i32 @strcpy(i8* %1, i8* %10)
ret i32 %11
}