#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 {
  scalar_t__ sa_flags;
  int /*<<< orphan*/ sa_mask;
  int /*<<< orphan*/ sa_handler;
};
typedef int /*<<< orphan*/ __sighandler_t;

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ sigaction(int /*<<< orphan*/, struct sigaction *,
                             int /*<<< orphan*/ *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
void SetSignalsHandler(__sighandler_t handler) {
  struct sigaction sigAction;
  sigAction.sa_handler = handler;
  sigemptyset(&sigAction.sa_mask);
  sigAction.sa_flags = 0;
  sigaction(SIGTERM, &sigAction, NULL);
  sigaction(SIGINT, &sigAction, NULL);
  sigaction(SIGQUIT, &sigAction, NULL);
}


x86 assembly (clang, -O0):
<SetSignalsHandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
add    $0x8,%rdi
call   1040 <sigemptyset@plt>
movq   $0x0,-0x18(%rbp)
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    0x2e5f(%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):
<SetSignalsHandler>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,0xc(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <sigemptyset@plt>
movq   $0x0,(%rsp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    0x2e6d(%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 { i64, i32, i32 }
@SIGTERM = global i32 0
@SIGINT = global i32 0
@SIGQUIT = global i32 0
define void @SetSignalsHandler(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sigaction
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 2
store i32 %4, i32* %5
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 1
%7 = call i32 @sigemptyset(i32* %6)
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 0
store i64 0, i64* %8
%9 = load i32, i32* @SIGTERM
%10 = call i32 @sigaction(i32 %9, %struct.sigaction* %3, i32* null)
%11 = load i32, i32* @SIGINT
%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 { i64, i32, i32 }
@SIGTERM = global i32 0
@SIGINT = global i32 0
@SIGQUIT = global i32 0
define void @SetSignalsHandler(i32 %0) {
%2 = alloca %struct.sigaction
%3 = bitcast %struct.sigaction* %2 to i8*
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 2
store i32 %0, i32* %4
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 1
%6 = call i32 @sigemptyset(i32* %5)
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
store i64 0, i64* %7
%8 = load i32, i32* @SIGTERM
%9 = call i32 @sigaction(i32 %8, %struct.sigaction* %2, i32* null)
%10 = load i32, i32* @SIGINT
%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
}