#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 SIGUSR1;
int SIGUSR2;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
void handle(int sig) {
  if (SIGUSR1 == sig) {
    printf("USR1 received\n");
    sleep(20);
  } else if (SIGUSR2 == sig)
    printf("USR2 received\n");
  else
    exit(0);
}


x86 assembly (clang, -O0):
<handle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
cmp    -0x4(%rbp),%eax
jne    1168 <handle+0x38>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    $0x14,%edi
call   1050 <sleep@plt>
jmp    1197 <handle+0x67>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
cmp    -0x4(%rbp),%eax
jne    118b <handle+0x5b>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    1192 <handle+0x62>
xor    %edi,%edi
call   1040 <exit@plt>
jmp    1197 <handle+0x67>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle>:
push   %rax
mov    0x2eb0(%rip),%rax
cmp    %edi,(%rax)
jne    1153 <handle+0x23>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
mov    $0x14,%edi
pop    %rax
jmp    1050 <sleep@plt>
mov    0x2e7e(%rip),%rax
cmp    %edi,(%rax)
jne    116b <handle+0x3b>
lea    0xe9b(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@.str = [15 x i8] c"USR1 received\0A\00"
@SIGUSR2 = global i32 0
@.str.1 = [15 x i8] c"USR2 received\0A\00"
define void @handle(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @SIGUSR1
%4 = load i32, i32* %2
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @sleep(i32 20)
br label %18
9: ; preds = %1
%10 = load i32, i32* @SIGUSR2
%11 = load i32, i32* %2
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %17
15: ; preds = %9
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %13
br label %18
18: ; preds = %17, %6
ret void
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@str = [14 x i8] c"USR2 received\00"
@str.2 = [14 x i8] c"USR1 received\00"
define void @handle(i32 %0) {
%2 = load i32, i32* @SIGUSR1
%3 = icmp eq i32 %2, %0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.2, i64 0, i64 0))
%6 = tail call i32 @sleep(i32 20)
br label %14
7: ; preds = %1
%8 = load i32, i32* @SIGUSR2
%9 = icmp eq i32 %8, %0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %14
12: ; preds = %7
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %10, %4
ret void
}