#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*/ 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
    fprintf(stderr, "Received signal %d\n", signo);
  return;
}


x86 assembly (clang, -O0):
<sig_usr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eb3(%rip),%rcx
cmp    (%rcx),%eax
jne    114e <sig_usr+0x2e>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
jmp    118e <sig_usr+0x6e>
mov    -0x4(%rbp),%eax
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
jne    1171 <sig_usr+0x51>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
jmp    1189 <sig_usr+0x69>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xea0(%rip),%rsi
call   1040 <fprintf@plt>
jmp    118e <sig_usr+0x6e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_usr>:
mov    0x2ec1(%rip),%rax
cmp    %edi,(%rax)
jne    1137 <sig_usr+0x17>
lea    0xef3(%rip),%rdi
jmp    1030 <puts@plt>
mov    %edi,%edx
mov    0x2e90(%rip),%rax
cmp    %edi,(%rax)
jne    1150 <sig_usr+0x30>
lea    0xec9(%rip),%rdi
jmp    1030 <puts@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
jmp    1040 <fprintf@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"
@stderr = global i32 0
@.str.2 = [20 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 %19
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 %18
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i32, i32* %2
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %14, %12
br label %19
19: ; preds = %18, %6
ret void
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@stderr = global i32 0
@.str.2 = [20 x i8] c"Received signal %d\0A\00"
@str = [17 x i8] c"received SIGUSR2\00"
@str.3 = [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 %4, label %6
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.3, i64 0, i64 0))
br label %14
6: ; preds = %1
%7 = load i32, i32* @SIGUSR2
%8 = icmp eq i32 %7, %0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %14
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %14
14: ; preds = %9, %11, %4
ret void
}