#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 SIGINT;
int SIGTERM;
int /*<<< orphan*/ disconnect_all_clients();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
void sig_handler(int signo) {
  if (signo == SIGINT || signo == SIGTERM) {
    fprintf(stderr,
            "%s: "
            "shutting down"
            "\n",
            "INFO");
    disconnect_all_clients();
    exit(0);
  }
}


x86 assembly (clang, -O0):
<sig_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ea3(%rip),%rcx
cmp    (%rcx),%eax
je     115f <sig_handler+0x2f>
mov    -0x4(%rbp),%eax
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%eax
jne    1189 <sig_handler+0x59>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
lea    0xe9d(%rip),%rdx
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1040 <disconnect_all_clients@plt>
xor    %edi,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_handler>:
push   %rax
mov    0x2eb0(%rip),%rax
cmp    %edi,(%rax)
je     1149 <sig_handler+0x19>
mov    0x2e9d(%rip),%rax
cmp    %edi,(%rax)
je     1149 <sig_handler+0x19>
pop    %rax
ret
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
lea    0xeb3(%rip),%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1040 <disconnect_all_clients@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SIGINT = global i32 0
@SIGTERM = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"%s: shutting down\0A\00"
@.str.1 = [5 x i8] c"INFO\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 %10, label %6
6: ; preds = %1
%7 = load i32, i32* %2
%8 = load i32, i32* @SIGTERM
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %15
10: ; preds = %6, %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (...) @disconnect_all_clients()
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %6
ret void
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIGTERM = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"%s: shutting down\0A\00"
@.str.1 = [5 x i8] c"INFO\00"
define void @sig_handler(i32 %0) {
%2 = load i32, i32* @SIGINT
%3 = icmp eq i32 %2, %0
%4 = load i32, i32* @SIGTERM
%5 = icmp eq i32 %4, %0
%6 = select i1 %3, i1 true, i1 %5
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 (...) @disconnect_all_clients()
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %1
ret void
}