#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_NOTICE;
#define SIGHUP 129
#define SIGTERM 128
int /*<<< orphan*/ close_lock();
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
void daemon_signal(int sign) {
  switch (sign) {
  case SIGHUP:
    syslog(LOG_NOTICE, "hangup signal catched");
    break;
  case SIGTERM:
    syslog(LOG_NOTICE, "shutdown broker");
    close_lock();
    closelog();
    exit(0);
  }
}


x86 assembly (clang, -O0):
<daemon_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x80,%eax
je     118e <daemon_signal+0x4e>
jmp    1161 <daemon_signal+0x21>
mov    -0x8(%rbp),%eax
sub    $0x81,%eax
jne    11b8 <daemon_signal+0x78>
jmp    1174 <daemon_signal+0x34>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
call   1040 <syslog@plt>
jmp    11b8 <daemon_signal+0x78>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1040 <syslog@plt>
mov    $0x0,%al
call   1060 <close_lock@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
xor    %edi,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<daemon_signal>:
push   %rax
cmp    $0x81,%edi
je     1153 <daemon_signal+0x13>
cmp    $0x80,%edi
je     1169 <daemon_signal+0x29>
pop    %rax
ret
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
pop    %rax
jmp    1040 <syslog@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1040 <syslog@plt>
xor    %eax,%eax
call   1060 <close_lock@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@LOG_NOTICE = global i32 0
@.str = [22 x i8] c"hangup signal catched\00"
@.str.1 = [16 x i8] c"shutdown broker\00"
define void @daemon_signal(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %13 [
i32 129, label %4
i32 128, label %7
]
4: ; preds = %1
%5 = load i32, i32* @LOG_NOTICE
%6 = call i32 @syslog(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %13
7: ; preds = %1
%8 = load i32, i32* @LOG_NOTICE
%9 = call i32 @syslog(i32 %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @close_lock()
%11 = call i32 (...) @closelog()
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %1, %4
ret void
}

LLVM IR (-O2):
@LOG_NOTICE = global i32 0
@.str = [22 x i8] c"hangup signal catched\00"
@.str.1 = [16 x i8] c"shutdown broker\00"
define void @daemon_signal(i32 %0) {
switch i32 %0, label %11 [
i32 129, label %2
i32 128, label %5
]
2: ; preds = %1
%3 = load i32, i32* @LOG_NOTICE
%4 = tail call i32 @syslog(i32 %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %11
5: ; preds = %1
%6 = load i32, i32* @LOG_NOTICE
%7 = tail call i32 @syslog(i32 %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (...) @close_lock()
%9 = tail call i32 (...) @closelog()
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %1, %2
ret void
}