#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*/ SIGINT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ atexit(void (*)());
int /*<<< orphan*/ setup_sigaction(void (*)(int), int, int /*<<< orphan*/, ...);
void setup_sig(void (*cleanup)(void), void (*sigterm)(int),
               void (*sigusr1)(int)) {
  setup_sigaction(sigterm, 2, SIGTERM, SIGINT);
  setup_sigaction(sigusr1, 1, SIGUSR1);
  atexit(cleanup);
}


x86 assembly (clang, -O0):
<setup_sig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
mov    0x2e98(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
mov    $0x0,%al
call   1040 <setup_sigaction@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <setup_sigaction@plt>
mov    -0x8(%rbp),%rdi
call   1180 <atexit>
add    $0x20,%rsp
pop    %rbp
ret
xchg   %ax,%ax

x86 assembly (clang, -O2):
<setup_sig>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%r14
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
mov    0x2ea6(%rip),%rax
mov    (%rax),%ecx
mov    %rsi,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <setup_sigaction@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <setup_sigaction@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1180 <atexit>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)

LLVM IR (-O0):
@SIGTERM = global i32 0
@SIGINT = global i32 0
@SIGUSR1 = global i32 0
define void @setup_sig(void ()* %0, void (i32)* %1, void (i32)* %2) {
%4 = alloca void ()*
%5 = alloca void (i32)*
%6 = alloca void (i32)*
store void ()* %0, void ()** %4
store void (i32)* %1, void (i32)** %5
store void (i32)* %2, void (i32)** %6
%7 = load void (i32)*, void (i32)** %5
%8 = load i32, i32* @SIGTERM
%9 = load i32, i32* @SIGINT
%10 = call i32 (void (i32)*, i32, i32, ...) @setup_sigaction(void (i32)* %7, i32 2, i32 %8, i32 %9)
%11 = load void (i32)*, void (i32)** %6
%12 = load i32, i32* @SIGUSR1
%13 = call i32 (void (i32)*, i32, i32, ...) @setup_sigaction(void (i32)* %11, i32 1, i32 %12)
%14 = load void ()*, void ()** %4
%15 = bitcast void ()* %14 to void (...)*
%16 = call i32 @atexit(void (...)* %15)
ret void
}

LLVM IR (-O2):
@SIGTERM = global i32 0
@SIGINT = global i32 0
@SIGUSR1 = global i32 0
define void @setup_sig(void ()* %0, void (i32)* %1, void (i32)* %2) {
%4 = load i32, i32* @SIGTERM
%5 = load i32, i32* @SIGINT
%6 = tail call i32 (void (i32)*, i32, i32, ...) @setup_sigaction(void (i32)* %1, i32 2, i32 %4, i32 %5)
%7 = load i32, i32* @SIGUSR1
%8 = tail call i32 (void (i32)*, i32, i32, ...) @setup_sigaction(void (i32)* %2, i32 1, i32 %7)
%9 = bitcast void ()* %0 to void (...)*
%10 = tail call i32 @atexit(void (...)* %9)
ret void
}