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

/* Variables and functions */
int SA_NODEFER;
int SA_SIGINFO;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIG_DFL;
int /*<<< orphan*/ sigaction(int /*<<< orphan*/, struct sigaction *,
                             int /*<<< orphan*/ *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
void uninstall_signal_handler() {
  struct sigaction sa_default;
  sa_default.sa_handler = SIG_DFL;
  sigemptyset(&sa_default.sa_mask);
  sa_default.sa_flags = SA_SIGINFO | SA_NODEFER;
  sigaction(SIGHUP, &sa_default, NULL);
  sigaction(SIGINT, &sa_default, NULL);
  sigaction(SIGQUIT, &sa_default, NULL);
  sigaction(SIGTERM, &sa_default, NULL);
}


x86 assembly (clang, -O0):
<uninstall_signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    0x2e5f(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uninstall_signal_handler>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e75(%rip),%rax
mov    0x2e66(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %ecx,(%rsp)
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    0x2e44(%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 { i32, i32, i32 }
@SIG_DFL = global i32 0
@SA_SIGINFO = global i32 0
@SA_NODEFER = global i32 0
@SIGHUP = global i32 0
@SIGINT = global i32 0
@SIGQUIT = global i32 0
@SIGTERM = global i32 0
define void @uninstall_signal_handler() {
%1 = alloca %struct.sigaction
%2 = load i32, i32* @SIG_DFL
%3 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 2
store i32 %2, i32* %3
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 1
%5 = call i32 @sigemptyset(i32* %4)
%6 = load i32, i32* @SA_SIGINFO
%7 = load i32, i32* @SA_NODEFER
%8 = or i32 %6, %7
%9 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 0
store i32 %8, i32* %9
%10 = load i32, i32* @SIGHUP
%11 = call i32 @sigaction(i32 %10, %struct.sigaction* %1, i32* null)
%12 = load i32, i32* @SIGINT
%13 = call i32 @sigaction(i32 %12, %struct.sigaction* %1, i32* null)
%14 = load i32, i32* @SIGQUIT
%15 = call i32 @sigaction(i32 %14, %struct.sigaction* %1, i32* null)
%16 = load i32, i32* @SIGTERM
%17 = call i32 @sigaction(i32 %16, %struct.sigaction* %1, i32* null)
ret void
}

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