#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*/ SIGQUIT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIGTSTP;
int /*<<< orphan*/ set_signal(int /*<<< orphan*/, void (*)(int),
                              int /*<<< orphan*/);
void set_cleanup_handler(void (*handler)(int)) {
  set_signal(SIGQUIT, handler, 0);
  set_signal(SIGINT, handler, 0);
  set_signal(SIGTSTP, handler, 0);
  set_signal(SIGTERM, handler, 0);
}


x86 assembly (clang, -O0):
<set_cleanup_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <set_signal@plt>
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <set_signal@plt>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <set_signal@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <set_signal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_cleanup_handler>:
push   %rbx
mov    %rdi,%rbx
mov    0x2ebd(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <set_signal@plt>
mov    0x2eba(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <set_signal@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <set_signal@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
pop    %rbx
jmp    1030 <set_signal@plt>

LLVM IR (-O0):
@SIGQUIT = global i32 0
@SIGINT = global i32 0
@SIGTSTP = global i32 0
@SIGTERM = global i32 0
define void @set_cleanup_handler(void (i32)* %0) {
%2 = alloca void (i32)*
store void (i32)* %0, void (i32)** %2
%3 = load i32, i32* @SIGQUIT
%4 = load void (i32)*, void (i32)** %2
%5 = call i32 @set_signal(i32 %3, void (i32)* %4, i32 0)
%6 = load i32, i32* @SIGINT
%7 = load void (i32)*, void (i32)** %2
%8 = call i32 @set_signal(i32 %6, void (i32)* %7, i32 0)
%9 = load i32, i32* @SIGTSTP
%10 = load void (i32)*, void (i32)** %2
%11 = call i32 @set_signal(i32 %9, void (i32)* %10, i32 0)
%12 = load i32, i32* @SIGTERM
%13 = load void (i32)*, void (i32)** %2
%14 = call i32 @set_signal(i32 %12, void (i32)* %13, i32 0)
ret void
}

LLVM IR (-O2):
@SIGQUIT = global i32 0
@SIGINT = global i32 0
@SIGTSTP = global i32 0
@SIGTERM = global i32 0
define void @set_cleanup_handler(void (i32)* %0) {
%2 = load i32, i32* @SIGQUIT
%3 = tail call i32 @set_signal(i32 %2, void (i32)* %0, i32 0)
%4 = load i32, i32* @SIGINT
%5 = tail call i32 @set_signal(i32 %4, void (i32)* %0, i32 0)
%6 = load i32, i32* @SIGTSTP
%7 = tail call i32 @set_signal(i32 %6, void (i32)* %0, i32 0)
%8 = load i32, i32* @SIGTERM
%9 = tail call i32 @set_signal(i32 %8, void (i32)* %0, i32 0)
ret void
}