#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
void sigUsr1(int signo) {
  if (signo == SIGUSR1)
    printf("Received SIGUSR1\n");
  else
    printf("Received wrong SIGNAL\n");
  fprintf(stdout, "sigUsr1 sleeping ...\n");
  sleep(5);
  fprintf(stdout, "... sigUsr1 end sleeping.\n");
  return;
}


x86 assembly (clang, -O0):
<sigUsr1>:
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 <sigUsr1+0x2e>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
jmp    116a <sigUsr1+0x3a>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigUsr1>:
push   %rbx
mov    0x2eb0(%rip),%rax
cmp    %edi,(%rax)
lea    0xf06(%rip),%rax
lea    0xee9(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    0x2e80(%rip),%rbx
mov    (%rbx),%edi
lea    0xe9f(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%rbx),%edi
lea    0xe9d(%rip),%rsi
pop    %rbx
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@.str = [18 x i8] c"Received SIGUSR1\0A\00"
@.str.1 = [23 x i8] c"Received wrong SIGNAL\0A\00"
@stdout = global i32 0
@.str.2 = [22 x i8] c"sigUsr1 sleeping ...\0A\00"
@.str.3 = [27 x i8] c"... sigUsr1 end sleeping.\0A\00"
define void @sigUsr1(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 %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @sleep(i32 5)
%14 = load i32, i32* @stdout
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@stdout = global i32 0
@.str.2 = [22 x i8] c"sigUsr1 sleeping ...\0A\00"
@.str.3 = [27 x i8] c"... sigUsr1 end sleeping.\0A\00"
@str = [22 x i8] c"Received wrong SIGNAL\00"
@str.4 = [17 x i8] c"Received SIGUSR1\00"
define void @sigUsr1(i32 %0) {
%2 = load i32, i32* @SIGUSR1
%3 = icmp eq i32 %2, %0
%4 = select i1 %3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0)
%5 = tail call i32 @puts(i8* dereferenceable(1) %4)
%6 = load i32, i32* @stdout
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @sleep(i32 5)
%9 = load i32, i32* @stdout
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
ret void
}