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

/* Variables and functions */
int /*<<< orphan*/ SIGCONT;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIG_DFL;
int /*<<< orphan*/ xsigaction(int /*<<< orphan*/, struct sigaction const *,
                              int /*<<< orphan*/);
int /*<<< orphan*/ xsigemptyset(int /*<<< orphan*/ *);
void sig_restore(const struct sigaction *old_int,
                 const struct sigaction *old_term) {
  {
    struct sigaction sa;
    sa.sa_handler = SIG_DFL;
    xsigemptyset(&sa.sa_mask);
    sa.sa_flags = 0;
    xsigaction(SIGCONT, &sa, 0);
  }
  xsigaction(SIGINT, old_int, 0);
  xsigaction(SIGTERM, old_term, 0);
}


x86 assembly (clang, -O0):
<sig_restore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
add    $0x8,%rdi
call   1030 <xsigemptyset@plt>
movq   $0x0,-0x20(%rbp)
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1040 <xsigaction@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1040 <xsigaction@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1040 <xsigaction@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_restore>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <xsigemptyset@plt>
movq   $0x0,0x8(%rsp)
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1040 <xsigaction@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <xsigaction@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <xsigaction@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sigaction = type { i64, i32, i32 }
@SIG_DFL = global i32 0
@SIGCONT = global i32 0
@SIGINT = global i32 0
@SIGTERM = global i32 0
define void @sig_restore(%struct.sigaction* %0, %struct.sigaction* %1) {
%3 = alloca %struct.sigaction*
%4 = alloca %struct.sigaction*
%5 = alloca %struct.sigaction
store %struct.sigaction* %0, %struct.sigaction** %3
store %struct.sigaction* %1, %struct.sigaction** %4
%6 = load i32, i32* @SIG_DFL
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 2
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 1
%9 = call i32 @xsigemptyset(i32* %8)
%10 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 0
store i64 0, i64* %10
%11 = load i32, i32* @SIGCONT
%12 = call i32 @xsigaction(i32 %11, %struct.sigaction* %5, i32 0)
%13 = load i32, i32* @SIGINT
%14 = load %struct.sigaction*, %struct.sigaction** %3
%15 = call i32 @xsigaction(i32 %13, %struct.sigaction* %14, i32 0)
%16 = load i32, i32* @SIGTERM
%17 = load %struct.sigaction*, %struct.sigaction** %4
%18 = call i32 @xsigaction(i32 %16, %struct.sigaction* %17, i32 0)
ret void
}

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