#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 *, char);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
void sighand(int sig) {
  if (sig == SIGUSR1) {
    char str[] = "SIGUSR1 receiced";
    int i = 0;
    while (str[i] != '\0') {
      fprintf(stderr, "%c", str[i++]);
      sleep(1);
    }
  }
  if (sig == SIGUSR2) {
    char str[] = "catch a SIGUSR2";
    int i = 0;
    while (str[i] != '\0') {
      fprintf(stderr, "%c", str[i++]);
      sleep(1);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<sighand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eb3(%rip),%rcx
cmp    (%rcx),%eax
jne    11b0 <sighand+0x90>
mov    0xebc(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb7(%rip),%al
mov    %al,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11ab <sighand+0x8b>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
cltq
lea    0xe9e(%rip),%rsi
movsbl -0x20(%rbp,%rax,1),%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
jmp    1163 <sighand+0x43>
jmp    11b0 <sighand+0x90>
mov    -0x4(%rbp),%eax
mov    0x2e16(%rip),%rcx
cmp    (%rcx),%eax
jne    122c <sighand+0x10c>
mov    0xe57(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe54(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1227 <sighand+0x107>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x44(%rbp)
cltq
lea    0xe22(%rip),%rsi
movsbl -0x40(%rbp,%rax,1),%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
jmp    11df <sighand+0xbf>
jmp    122c <sighand+0x10c>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sighand>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    0x2eba(%rip),%rax
cmp    %edi,(%rax)
jne    12e4 <sighand+0x1c4>
mov    0x2e9b(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xeb9(%rip),%rbx
mov    %rbx,%rsi
mov    $0x53,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x49,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x47,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x55,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x53,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x52,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x31,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x72,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x65,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x63,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x65,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x69,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x63,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x65,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x2ce5(%rip),%rax
cmp    %r14d,(%rax)
jne    148c <sighand+0x36c>
mov    0x2cdd(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xcfb(%rip),%rbx
mov    %rbx,%rsi
mov    $0x63,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x61,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x74,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x63,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x68,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x61,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x53,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x49,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x47,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x55,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x53,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x52,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x32,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <sleep@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@__const.sighand.str = [17 x i8] c"SIGUSR1 receiced\00"
@stderr = global i32 0
@.str = [3 x i8] c"%c\00"
@SIGUSR2 = global i32 0
@__const.sighand.str.1 = [16 x i8] c"catch a SIGUSR2\00"
define void @sighand(i32 %0) {
%2 = alloca i32
%3 = alloca [17 x i8]
%4 = alloca i32
%5 = alloca [16 x i8]
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = load i32, i32* @SIGUSR1
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %1
%11 = bitcast [17 x i8]* %3 to i8*
store i32 0, i32* %4
br label %12
12: ; preds = %19, %10
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %12
%20 = load i32, i32* @stderr
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %25)
%27 = call i32 @sleep(i32 1)
br label %12
28: ; preds = %12
br label %29
29: ; preds = %28, %1
%30 = load i32, i32* %2
%31 = load i32, i32* @SIGUSR2
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %52
33: ; preds = %29
%34 = bitcast [16 x i8]* %5 to i8*
store i32 0, i32* %6
br label %35
35: ; preds = %42, %33
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %51
42: ; preds = %35
%43 = load i32, i32* @stderr
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %48)
%50 = call i32 @sleep(i32 1)
br label %35
51: ; preds = %35
br label %52
52: ; preds = %51, %29
ret void
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@stderr = global i32 0
@.str = [3 x i8] c"%c\00"
@SIGUSR2 = global i32 0
define void @sighand(i32 %0) {
%2 = load i32, i32* @SIGUSR1
%3 = icmp eq i32 %2, %0
br i1 %3, label %4, label %53
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 83)
%7 = tail call i32 @sleep(i32 1)
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 73)
%10 = tail call i32 @sleep(i32 1)
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 71)
%13 = tail call i32 @sleep(i32 1)
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 85)
%16 = tail call i32 @sleep(i32 1)
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 83)
%19 = tail call i32 @sleep(i32 1)
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 82)
%22 = tail call i32 @sleep(i32 1)
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 49)
%25 = tail call i32 @sleep(i32 1)
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 32)
%28 = tail call i32 @sleep(i32 1)
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 114)
%31 = tail call i32 @sleep(i32 1)
%32 = load i32, i32* @stderr
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 101)
%34 = tail call i32 @sleep(i32 1)
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 99)
%37 = tail call i32 @sleep(i32 1)
%38 = load i32, i32* @stderr
%39 = tail call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 101)
%40 = tail call i32 @sleep(i32 1)
%41 = load i32, i32* @stderr
%42 = tail call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 105)
%43 = tail call i32 @sleep(i32 1)
%44 = load i32, i32* @stderr
%45 = tail call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 99)
%46 = tail call i32 @sleep(i32 1)
%47 = load i32, i32* @stderr
%48 = tail call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 101)
%49 = tail call i32 @sleep(i32 1)
%50 = load i32, i32* @stderr
%51 = tail call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 100)
%52 = tail call i32 @sleep(i32 1)
br label %53
53: ; preds = %4, %1
%54 = load i32, i32* @SIGUSR2
%55 = icmp eq i32 %54, %0
br i1 %55, label %56, label %102
56: ; preds = %53
%57 = load i32, i32* @stderr
%58 = tail call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 99)
%59 = tail call i32 @sleep(i32 1)
%60 = load i32, i32* @stderr
%61 = tail call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 97)
%62 = tail call i32 @sleep(i32 1)
%63 = load i32, i32* @stderr
%64 = tail call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 116)
%65 = tail call i32 @sleep(i32 1)
%66 = load i32, i32* @stderr
%67 = tail call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 99)
%68 = tail call i32 @sleep(i32 1)
%69 = load i32, i32* @stderr
%70 = tail call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 104)
%71 = tail call i32 @sleep(i32 1)
%72 = load i32, i32* @stderr
%73 = tail call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 32)
%74 = tail call i32 @sleep(i32 1)
%75 = load i32, i32* @stderr
%76 = tail call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 97)
%77 = tail call i32 @sleep(i32 1)
%78 = load i32, i32* @stderr
%79 = tail call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 32)
%80 = tail call i32 @sleep(i32 1)
%81 = load i32, i32* @stderr
%82 = tail call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 83)
%83 = tail call i32 @sleep(i32 1)
%84 = load i32, i32* @stderr
%85 = tail call i32 @fprintf(i32 %84, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 73)
%86 = tail call i32 @sleep(i32 1)
%87 = load i32, i32* @stderr
%88 = tail call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 71)
%89 = tail call i32 @sleep(i32 1)
%90 = load i32, i32* @stderr
%91 = tail call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 85)
%92 = tail call i32 @sleep(i32 1)
%93 = load i32, i32* @stderr
%94 = tail call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 83)
%95 = tail call i32 @sleep(i32 1)
%96 = load i32, i32* @stderr
%97 = tail call i32 @fprintf(i32 %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 82)
%98 = tail call i32 @sleep(i32 1)
%99 = load i32, i32* @stderr
%100 = tail call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 50)
%101 = tail call i32 @sleep(i32 1)
br label %102
102: ; preds = %56, %53
ret void
}