#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 */
int SIGHUP;
int SIGINT;
int SIGKILL;
int SIGTERM;
int SIGUSR1;
int SIGUSR2;
int atoi(char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
int action_by_name(const char *name) {
  if (!strcmp(name, "RESTART"))
    return -1;
  if (!strcmp(name, "HUP") || !strcmp(name, "SIG"
                                            "HUP"))
    return SIGHUP;
  if (!strcmp(name, "INT") || !strcmp(name, "SIG"
                                            "INT"))
    return SIGINT;
  if (!strcmp(name, "KILL") || !strcmp(name, "SIG"
                                             "KILL"))
    return SIGKILL;
  if (!strcmp(name, "TERM") || !strcmp(name, "SIG"
                                             "TERM"))
    return SIGTERM;
  if (!strcmp(name, "USR1") || !strcmp(name, "SIG"
                                             "USR1"))
    return SIGUSR1;
  if (!strcmp(name, "USR2") || !strcmp(name, "SIG"
                                             "USR2"))
    return SIGUSR2;
  return atoi(name);
}


x86 assembly (clang, -O0):
<action_by_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1151 <action_by_name+0x31>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ef <action_by_name+0x1cf>
mov    -0x10(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1183 <action_by_name+0x63>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1194 <action_by_name+0x74>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ef <action_by_name+0x1cf>
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11c6 <action_by_name+0xa6>
mov    -0x10(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11d7 <action_by_name+0xb7>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ef <action_by_name+0x1cf>
mov    -0x10(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1209 <action_by_name+0xe9>
mov    -0x10(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    121a <action_by_name+0xfa>
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ef <action_by_name+0x1cf>
mov    -0x10(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     124c <action_by_name+0x12c>
mov    -0x10(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    125d <action_by_name+0x13d>
mov    0x2d7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ef <action_by_name+0x1cf>
mov    -0x10(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     128f <action_by_name+0x16f>
mov    -0x10(%rbp),%rdi
lea    0xda5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    12a0 <action_by_name+0x180>
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ef <action_by_name+0x1cf>
mov    -0x10(%rbp),%rdi
lea    0xd86(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     12d2 <action_by_name+0x1b2>
mov    -0x10(%rbp),%rdi
lea    0xd6a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    12e3 <action_by_name+0x1c3>
mov    0x2ce7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ef <action_by_name+0x1cf>
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<action_by_name>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     124a <action_by_name+0x12a>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1241 <action_by_name+0x121>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1241 <action_by_name+0x121>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1251 <action_by_name+0x131>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1251 <action_by_name+0x131>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     125a <action_by_name+0x13a>
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     125a <action_by_name+0x13a>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1263 <action_by_name+0x143>
lea    0xe3e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1263 <action_by_name+0x143>
lea    0xe36(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     126c <action_by_name+0x14c>
lea    0xe20(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     126c <action_by_name+0x14c>
lea    0xe18(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1275 <action_by_name+0x155>
lea    0xe02(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1275 <action_by_name+0x155>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <atoi@plt>
mov    0x2da8(%rip),%rax
jmp    127c <action_by_name+0x15c>
mov    $0xffffffff,%eax
pop    %rbx
ret
mov    0x2d80(%rip),%rax
jmp    127c <action_by_name+0x15c>
mov    0x2d57(%rip),%rax
jmp    127c <action_by_name+0x15c>
mov    0x2d66(%rip),%rax
jmp    127c <action_by_name+0x15c>
mov    0x2d6d(%rip),%rax
jmp    127c <action_by_name+0x15c>
mov    0x2d44(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"RESTART\00"
@.str.1 = [4 x i8] c"HUP\00"
@.str.2 = [7 x i8] c"SIGHUP\00"
@SIGHUP = global i32 0
@.str.3 = [4 x i8] c"INT\00"
@.str.4 = [7 x i8] c"SIGINT\00"
@SIGINT = global i32 0
@.str.5 = [5 x i8] c"KILL\00"
@.str.6 = [8 x i8] c"SIGKILL\00"
@SIGKILL = global i32 0
@.str.7 = [5 x i8] c"TERM\00"
@.str.8 = [8 x i8] c"SIGTERM\00"
@SIGTERM = global i32 0
@.str.9 = [5 x i8] c"USR1\00"
@.str.10 = [8 x i8] c"SIGUSR1\00"
@SIGUSR1 = global i32 0
@.str.11 = [5 x i8] c"USR2\00"
@.str.12 = [8 x i8] c"SIGUSR2\00"
@SIGUSR2 = global i32 0
define i32 @action_by_name(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strcmp(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 -1, i32* %2
br label %71
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12, %8
%17 = load i32, i32* @SIGHUP
store i32 %17, i32* %2
br label %71
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22, %18
%27 = load i32, i32* @SIGINT
store i32 %27, i32* %2
br label %71
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i8*, i8** %3
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %32, %28
%37 = load i32, i32* @SIGKILL
store i32 %37, i32* %2
br label %71
38: ; preds = %32
%39 = load i8*, i8** %3
%40 = call i32 @strcmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i8*, i8** %3
%44 = call i32 @strcmp(i8* %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %42, %38
%47 = load i32, i32* @SIGTERM
store i32 %47, i32* %2
br label %71
48: ; preds = %42
%49 = load i8*, i8** %3
%50 = call i32 @strcmp(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i8*, i8** %3
%54 = call i32 @strcmp(i8* %53, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%55 = icmp ne i32 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %52, %48
%57 = load i32, i32* @SIGUSR1
store i32 %57, i32* %2
br label %71
58: ; preds = %52
%59 = load i8*, i8** %3
%60 = call i32 @strcmp(i8* %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load i8*, i8** %3
%64 = call i32 @strcmp(i8* %63, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%65 = icmp ne i32 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %62, %58
%67 = load i32, i32* @SIGUSR2
store i32 %67, i32* %2
br label %71
68: ; preds = %62
%69 = load i8*, i8** %3
%70 = call i32 @atoi(i8* %69)
store i32 %70, i32* %2
br label %71
71: ; preds = %68, %66, %56, %46, %36, %26, %16, %7
%72 = load i32, i32* %2
ret i32 %72
}

LLVM IR (-O2):
@.str = [8 x i8] c"RESTART\00"
@.str.1 = [4 x i8] c"HUP\00"
@.str.2 = [7 x i8] c"SIGHUP\00"
@SIGHUP = global i32 0
@.str.3 = [4 x i8] c"INT\00"
@.str.4 = [7 x i8] c"SIGINT\00"
@SIGINT = global i32 0
@.str.5 = [5 x i8] c"KILL\00"
@.str.6 = [8 x i8] c"SIGKILL\00"
@SIGKILL = global i32 0
@.str.7 = [5 x i8] c"TERM\00"
@.str.8 = [8 x i8] c"SIGTERM\00"
@SIGTERM = global i32 0
@.str.9 = [5 x i8] c"USR1\00"
@.str.10 = [8 x i8] c"SIGUSR1\00"
@SIGUSR1 = global i32 0
@.str.11 = [5 x i8] c"USR2\00"
@.str.12 = [8 x i8] c"SIGUSR2\00"
@SIGUSR2 = global i32 0
define i32 @action_by_name(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %54, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7, %4
%11 = load i32, i32* @SIGHUP
br label %54
12: ; preds = %7
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15, %12
%19 = load i32, i32* @SIGINT
br label %54
20: ; preds = %15
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23, %20
%27 = load i32, i32* @SIGKILL
br label %54
28: ; preds = %23
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31, %28
%35 = load i32, i32* @SIGTERM
br label %54
36: ; preds = %31
%37 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39, %36
%43 = load i32, i32* @SIGUSR1
br label %54
44: ; preds = %39
%45 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%46 = icmp eq i32 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47, %44
%51 = load i32, i32* @SIGUSR2
br label %54
52: ; preds = %47
%53 = tail call i32 @atoi(i8* %0)
br label %54
54: ; preds = %1, %52, %50, %42, %34, %26, %18, %10
%55 = phi i32 [ %53, %52 ], [ %51, %50 ], [ %43, %42 ], [ %35, %34 ], [ %27, %26 ], [ %19, %18 ], [ %11, %10 ], [ -1, %1 ]
ret i32 %55
}