#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 SIGUSR1;
int SIGUSR2;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void sig_usr(int signo) {
  if (signo == SIGUSR1)
    printf("received SIGUSR1\n");
  else if (signo == SIGUSR2)
    printf("received SIGUSR2\n");
  else if (signo == SIGHUP)
    printf("received SIGHUP\n");
  else {
    fprintf(stderr, "received signal: %d\n", signo);
    exit(1);
  }
  return;
}


x86 assembly (clang, -O0):
<sig_usr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e9b(%rip),%rcx
cmp    (%rcx),%eax
jne    115e <sig_usr+0x2e>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
jmp    11d0 <sig_usr+0xa0>
mov    -0x4(%rbp),%eax
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%eax
jne    1181 <sig_usr+0x51>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    11cb <sig_usr+0x9b>
mov    -0x4(%rbp),%eax
mov    0x2e65(%rip),%rcx
cmp    (%rcx),%eax
jne    11a4 <sig_usr+0x74>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
jmp    11c6 <sig_usr+0x96>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe7e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11cb <sig_usr+0x9b>
jmp    11d0 <sig_usr+0xa0>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_usr>:
push   %rax
mov    0x2ea8(%rip),%rax
cmp    %edi,(%rax)
jne    1149 <sig_usr+0x19>
lea    0xef3(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
mov    %edi,%edx
mov    0x2e76(%rip),%rax
cmp    %edi,(%rax)
jne    1163 <sig_usr+0x33>
lea    0xec8(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
mov    0x2e86(%rip),%rax
cmp    %edx,(%rax)
jne    117b <sig_usr+0x4b>
lea    0xea0(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@.str = [18 x i8] c"received SIGUSR1\0A\00"
@SIGUSR2 = global i32 0
@.str.1 = [18 x i8] c"received SIGUSR2\0A\00"
@SIGHUP = global i32 0
@.str.2 = [17 x i8] c"received SIGHUP\0A\00"
@stderr = global i32 0
@.str.3 = [21 x i8] c"received signal: %d\0A\00"
define void @sig_usr(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @SIGUSR1
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %27
8: ; preds = %1
%9 = load i32, i32* %2
%10 = load i32, i32* @SIGUSR2
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %26
14: ; preds = %8
%15 = load i32, i32* %2
%16 = load i32, i32* @SIGHUP
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %25
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i32, i32* %2
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %18
br label %26
26: ; preds = %25, %12
br label %27
27: ; preds = %26, %6
ret void
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@SIGHUP = global i32 0
@stderr = global i32 0
@.str.3 = [21 x i8] c"received signal: %d\0A\00"
@str = [16 x i8] c"received SIGHUP\00"
@str.4 = [17 x i8] c"received SIGUSR2\00"
@str.5 = [17 x i8] c"received SIGUSR1\00"
define void @sig_usr(i32 %0) {
%2 = load i32, i32* @SIGUSR1
%3 = icmp eq i32 %2, %0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = load i32, i32* @SIGUSR2
%6 = icmp eq i32 %5, %0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = load i32, i32* @SIGHUP
%9 = icmp eq i32 %8, %0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %0)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7, %4, %1
%15 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0), %1 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.4, i64 0, i64 0), %4 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0), %7 ]
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
ret void
}