#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 /*<<< orphan*/ LOG_INFO;
int SIGHUP;
int SIGINT;
int SIGTERM;
int /*<<< orphan*/ quit();
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
void sig_handler(int signo) {
  if (signo == SIGINT) {
    syslog(LOG_INFO, "Received SIGINT.");
    quit();
  } else if (signo == SIGTERM) {
    syslog(LOG_INFO, "Received SIGTERM.");
    quit();
  } else if (signo == SIGHUP) {
    syslog(LOG_INFO, "Ooh, that tickles!");
  }
}


x86 assembly (clang, -O0):
<sig_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eab(%rip),%rcx
cmp    (%rcx),%eax
jne    115e <sig_handler+0x3e>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <quit@plt>
jmp    11c2 <sig_handler+0xa2>
mov    -0x4(%rbp),%eax
mov    0x2e70(%rip),%rcx
cmp    (%rcx),%eax
jne    1191 <sig_handler+0x71>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <quit@plt>
jmp    11bd <sig_handler+0x9d>
mov    -0x4(%rbp),%eax
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%eax
jne    11b8 <sig_handler+0x98>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1040 <syslog@plt>
jmp    11bd <sig_handler+0x9d>
jmp    11c2 <sig_handler+0xa2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_handler>:
push   %rax
mov    0x2eb8(%rip),%rax
cmp    %edi,(%rax)
jne    113e <sig_handler+0x1e>
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
lea    0xec4(%rip),%rsi
jmp    1159 <sig_handler+0x39>
mov    0x2e93(%rip),%rax
cmp    %edi,(%rax)
jne    1166 <sig_handler+0x46>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xeb8(%rip),%rsi
call   1040 <syslog@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <quit@plt>
mov    0x2e83(%rip),%rax
cmp    %edi,(%rax)
jne    1187 <sig_handler+0x67>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
pop    %rax
jmp    1040 <syslog@plt>
pop    %rax
ret

LLVM IR (-O0):
@SIGINT = global i32 0
@LOG_INFO = global i32 0
@.str = [17 x i8] c"Received SIGINT.\00"
@SIGTERM = global i32 0
@.str.1 = [18 x i8] c"Received SIGTERM.\00"
@SIGHUP = global i32 0
@.str.2 = [19 x i8] c"Ooh, that tickles!\00"
define void @sig_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @SIGINT
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* @LOG_INFO
%8 = call i32 @syslog(i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @quit()
br label %27
10: ; preds = %1
%11 = load i32, i32* %2
%12 = load i32, i32* @SIGTERM
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* @LOG_INFO
%16 = call i32 @syslog(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (...) @quit()
br label %26
18: ; preds = %10
%19 = load i32, i32* %2
%20 = load i32, i32* @SIGHUP
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* @LOG_INFO
%24 = call i32 @syslog(i32 %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %22, %18
br label %26
26: ; preds = %25, %14
br label %27
27: ; preds = %26, %6
ret void
}

LLVM IR (-O2):
@SIGINT = global i32 0
@LOG_INFO = global i32 0
@.str = [17 x i8] c"Received SIGINT.\00"
@SIGTERM = global i32 0
@.str.1 = [18 x i8] c"Received SIGTERM.\00"
@SIGHUP = global i32 0
@.str.2 = [19 x i8] c"Ooh, that tickles!\00"
define void @sig_handler(i32 %0) {
%2 = load i32, i32* @SIGINT
%3 = icmp eq i32 %2, %0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = load i32, i32* @LOG_INFO
%6 = tail call i32 @syslog(i32 %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @quit()
br label %21
8: ; preds = %1
%9 = load i32, i32* @SIGTERM
%10 = icmp eq i32 %9, %0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* @LOG_INFO
%13 = tail call i32 @syslog(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 (...) @quit()
br label %21
15: ; preds = %8
%16 = load i32, i32* @SIGHUP
%17 = icmp eq i32 %16, %0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @LOG_INFO
%20 = tail call i32 @syslog(i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %11, %18, %15, %4
ret void
}