#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int SIGHUP;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *get_log_file();
int /*<<< orphan*/ log_msg(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ log_msg_arg1s(int /*<<< orphan*/ *, char *,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ strsignal(int);
void sig_handler(int sigid) {
  FILE *f;
  f = get_log_file();
  if (sigid == SIGHUP) {
    log_msg(f, "server: expected signal SIGHUP: exit \n");
    exit(0);
  }
  log_msg_arg1s(f, "server: unexpected signal: %s: exit \n", strsignal(sigid));
  exit(-1);
}


x86 assembly (clang, -O0):
<sig_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1060 <get_log_file@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%eax
jne    118f <sig_handler+0x3f>
mov    -0x10(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1040 <log_msg@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <strsignal@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xe7b(%rip),%rsi
call   1030 <log_msg_arg1s@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<sig_handler>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <get_log_file@plt>
mov    %rax,%rbx
mov    0x2e8a(%rip),%rax
cmp    %ebp,(%rax)
jne    1180 <sig_handler+0x30>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <log_msg@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    %ebp,%edi
call   1050 <strsignal@plt>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <log_msg_arg1s@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@SIGHUP = global i32 0
@.str = [39 x i8] c"server: expected signal SIGHUP: exit \0A\00"
@.str.1 = [38 x i8] c"server: unexpected signal: %s: exit \0A\00"
define void @sig_handler(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = call i32* (...) @get_log_file()
store i32* %4, i32** %3
%5 = load i32, i32* %2
%6 = load i32, i32* @SIGHUP
%7 = icmp eq i32 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32*, i32** %3
%10 = call i32 @log_msg(i32* %9, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %1
%13 = load i32*, i32** %3
%14 = load i32, i32* %2
%15 = call i32 @strsignal(i32 %14)
%16 = call i32 @log_msg_arg1s(i32* %13, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
@SIGHUP = global i32 0
@.str = [39 x i8] c"server: expected signal SIGHUP: exit \0A\00"
@.str.1 = [38 x i8] c"server: unexpected signal: %s: exit \0A\00"
define void @sig_handler(i32 %0) {
%2 = tail call i32* (...) @get_log_file()
%3 = load i32, i32* @SIGHUP
%4 = icmp eq i32 %3, %0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @log_msg(i32* %2, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %1
%9 = tail call i32 @strsignal(i32 %0)
%10 = tail call i32 @log_msg_arg1s(i32* %2, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = tail call i32 @exit(i32 -1)
unreachable
}