#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 /*<<< orphan*/ PrintCurrentMask(char *);
int SIGUSR1;
int SIGUSR2;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
void Handle(int sig) {
  if (sig == SIGUSR1)
    PrintCurrentMask("USR1 handler: ");
  else if (sig == SIGUSR2)
    PrintCurrentMask("USR2 handler: ");
  else {
    fprintf(stderr, "Unexpected signal %d\n", sig);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<Handle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ea3(%rip),%rcx
cmp    (%rcx),%eax
jne    115e <Handle+0x2e>
lea    0xeac(%rip),%rdi
call   1040 <PrintCurrentMask@plt>
jmp    11a8 <Handle+0x78>
mov    -0x4(%rbp),%eax
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%eax
jne    1181 <Handle+0x51>
lea    0xe98(%rip),%rdi
call   1040 <PrintCurrentMask@plt>
jmp    11a3 <Handle+0x73>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11a8 <Handle+0x78>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Handle>:
push   %rax
mov    0x2eb0(%rip),%rax
cmp    %edi,(%rax)
jne    1149 <Handle+0x19>
lea    0xebd(%rip),%rdi
pop    %rax
jmp    1040 <PrintCurrentMask@plt>
mov    %edi,%edx
mov    0x2e7e(%rip),%rax
cmp    %edi,(%rax)
jne    1163 <Handle+0x33>
lea    0xeb2(%rip),%rdi
pop    %rax
jmp    1040 <PrintCurrentMask@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xeab(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@.str = [15 x i8] c"USR1 handler: \00"
@SIGUSR2 = global i32 0
@.str.1 = [15 x i8] c"USR2 handler: \00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"Unexpected signal %d\0A\00"
define void @Handle(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 @PrintCurrentMask(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %20
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 @PrintCurrentMask(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %19
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i32, i32* %2
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %12
br label %20
20: ; preds = %19, %6
ret void
}

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