#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);
int /*<<< orphan*/ printf(char *);
void func_usrsig(int signo) {
  if (signo == SIGUSR1) {
    printf("Signal SIGUSR1 is been catched!\n");
  } else if (signo == SIGUSR2) {
    printf("Signal SIGUSR2 is been catched!\n");
    printf("INFO:exit this demo!\n");
    exit(0);
  } else {
    printf("ERR: Unreconigizd Signal!\n");
    exit(1);
  }
  return;
}


x86 assembly (clang, -O0):
<func_usrsig>:
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 <func_usrsig+0x2e>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <func_usrsig+0x75>
mov    -0x4(%rbp),%eax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%eax
jne    117f <func_usrsig+0x5f>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func_usrsig>:
push   %rax
mov    0x2ec0(%rip),%rax
cmp    %edi,(%rax)
jne    1139 <func_usrsig+0x19>
lea    0xf1c(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
mov    0x2e98(%rip),%rax
cmp    %edi,(%rax)
jne    1163 <func_usrsig+0x43>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <exit@plt>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@.str = [33 x i8] c"Signal SIGUSR1 is been catched!\0A\00"
@SIGUSR2 = global i32 0
@.str.1 = [33 x i8] c"Signal SIGUSR2 is been catched!\0A\00"
@.str.2 = [22 x i8] c"INFO:exit this demo!\0A\00"
@.str.3 = [27 x i8] c"ERR: Unreconigizd Signal!\0A\00"
define void @func_usrsig(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 ([33 x i8], [33 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 %16
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %8
%17 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %6
ret void
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@str = [26 x i8] c"ERR: Unreconigizd Signal!\00"
@str.4 = [32 x i8] c"Signal SIGUSR2 is been catched!\00"
@str.5 = [21 x i8] c"INFO:exit this demo!\00"
@str.6 = [32 x i8] c"Signal SIGUSR1 is been catched!\00"
define void @func_usrsig(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 ([32 x i8], [32 x i8]* @str.6, i64 0, i64 0))
ret void
6: ; preds = %1
%7 = load i32, i32* @SIGUSR2
%8 = icmp eq i32 %7, %0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.4, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
}