#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 */
#define SIGHUP 129
#define SIGTERM 128
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ log_message(char *, char *);
void signal_handler(int sig) {
  switch (sig) {
  case SIGHUP:
    log_message("daemond.log", "Hangup Signal Catched");
    break;
  case SIGTERM:
    log_message("daemond.log", "Terminate Signal Catched");
    exit(0);
    break;
  }
}


x86 assembly (clang, -O0):
<signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x80,%eax
je     116c <signal_handler+0x4c>
jmp    1141 <signal_handler+0x21>
mov    -0x8(%rbp),%eax
sub    $0x81,%eax
jne    1186 <signal_handler+0x66>
jmp    1154 <signal_handler+0x34>
lea    0xea5(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1030 <log_message@plt>
jmp    1186 <signal_handler+0x66>
lea    0xe8d(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1030 <log_message@plt>
xor    %edi,%edi
call   1040 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_handler>:
cmp    $0x81,%edi
je     1131 <signal_handler+0x11>
cmp    $0x80,%edi
je     1144 <signal_handler+0x24>
ret
lea    0xec8(%rip),%rdi
lea    0xecd(%rip),%rsi
jmp    1030 <log_message@plt>
push   %rax
lea    0xeb4(%rip),%rdi
lea    0xecf(%rip),%rsi
call   1030 <log_message@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"daemond.log\00"
@.str.1 = [22 x i8] c"Hangup Signal Catched\00"
@.str.2 = [25 x i8] c"Terminate Signal Catched\00"
define void @signal_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %9 [
i32 129, label %4
i32 128, label %6
]
4: ; preds = %1
%5 = call i32 @log_message(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %9
6: ; preds = %1
%7 = call i32 @log_message(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @exit(i32 0)
unreachable
9: ; preds = %1, %4
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"daemond.log\00"
@.str.1 = [22 x i8] c"Hangup Signal Catched\00"
@.str.2 = [25 x i8] c"Terminate Signal Catched\00"
define void @signal_handler(i32 %0) {
switch i32 %0, label %7 [
i32 129, label %2
i32 128, label %4
]
2: ; preds = %1
%3 = tail call i32 @log_message(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %7
4: ; preds = %1
%5 = tail call i32 @log_message(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @exit(i32 0)
unreachable
7: ; preds = %1, %2
ret void
}