#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 */
struct sigaction {
  void (*sa_handler)(int);
  scalar_t__ sa_flags;
};

/* Variables and functions */
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ sigaction(int /*<<< orphan*/, struct sigaction *,
                             int /*<<< orphan*/ *);
void signal_init(void (*sig_handler)(int s)) {
  struct sigaction sig;
  sig.sa_handler = sig_handler;
  sig.sa_flags = 0;
  sigaction(SIGTERM, &sig, NULL);
  sigaction(SIGINT, &sig, NULL);
  sigaction(SIGHUP, &sig, NULL);
  sigaction(SIGQUIT, &sig, NULL);
}


x86 assembly (clang, -O0):
<signal_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_init>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2eaf(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sigaction = type { void (i32)*, i64 }
@SIGTERM = global i32 0
@SIGINT = global i32 0
@SIGHUP = global i32 0
@SIGQUIT = global i32 0
define void @signal_init(void (i32)* %0) {
%2 = alloca void (i32)*
%3 = alloca %struct.sigaction
store void (i32)* %0, void (i32)** %2
%4 = load void (i32)*, void (i32)** %2
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 0
store void (i32)* %4, void (i32)** %5
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 1
store i64 0, i64* %6
%7 = load i32, i32* @SIGTERM
%8 = call i32 @sigaction(i32 %7, %struct.sigaction* %3, i32* null)
%9 = load i32, i32* @SIGINT
%10 = call i32 @sigaction(i32 %9, %struct.sigaction* %3, i32* null)
%11 = load i32, i32* @SIGHUP
%12 = call i32 @sigaction(i32 %11, %struct.sigaction* %3, i32* null)
%13 = load i32, i32* @SIGQUIT
%14 = call i32 @sigaction(i32 %13, %struct.sigaction* %3, i32* null)
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { void (i32)*, i64 }
@SIGTERM = global i32 0
@SIGINT = global i32 0
@SIGHUP = global i32 0
@SIGQUIT = global i32 0
define void @signal_init(void (i32)* %0) {
%2 = alloca %struct.sigaction
%3 = bitcast %struct.sigaction* %2 to i8*
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
store void (i32)* %0, void (i32)** %4
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 1
store i64 0, i64* %5
%6 = load i32, i32* @SIGTERM
%7 = call i32 @sigaction(i32 %6, %struct.sigaction* %2, i32* null)
%8 = load i32, i32* @SIGINT
%9 = call i32 @sigaction(i32 %8, %struct.sigaction* %2, i32* null)
%10 = load i32, i32* @SIGHUP
%11 = call i32 @sigaction(i32 %10, %struct.sigaction* %2, i32* null)
%12 = load i32, i32* @SIGQUIT
%13 = call i32 @sigaction(i32 %12, %struct.sigaction* %2, i32* null)
ret void
}