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


x86 assembly (clang, -O0):
<sigUsr2>:
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 <sigUsr2+0x2e>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
jmp    116a <sigUsr2+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):
<sigUsr2>:
push   %rbx
mov    0x2ea8(%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):
@SIGUSR2 = global i32 0
@.str = [18 x i8] c"Received SIGUSR2\0A\00"
@.str.1 = [23 x i8] c"Received wrong SIGNAL\0A\00"
@stdout = global i32 0
@.str.2 = [22 x i8] c"sigUsr2 sleeping ...\0A\00"
@.str.3 = [27 x i8] c"... sigUsr2 end sleeping.\0A\00"
define void @sigUsr2(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @SIGUSR2
%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):
@SIGUSR2 = global i32 0
@stdout = global i32 0
@.str.2 = [22 x i8] c"sigUsr2 sleeping ...\0A\00"
@.str.3 = [27 x i8] c"... sigUsr2 end sleeping.\0A\00"
@str = [22 x i8] c"Received wrong SIGNAL\00"
@str.4 = [17 x i8] c"Received SIGUSR2\00"
define void @sigUsr2(i32 %0) {
%2 = load i32, i32* @SIGUSR2
%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
}