#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;
};

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIG_DFL;
int /*<<< orphan*/ sigaction(int /*<<< orphan*/, struct sigaction *,
                             int /*<<< orphan*/ *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
void establish_child_signal_handlers(void) {
  struct sigaction dfl_action;
  dfl_action.sa_handler = SIG_DFL;
  sigemptyset(&dfl_action.sa_mask);
  dfl_action.sa_flags = 0;
  sigaction(SIGINT, &dfl_action, NULL);
  sigaction(SIGTERM, &dfl_action, NULL);
}


x86 assembly (clang, -O0):
<establish_child_signal_handlers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1040 <sigemptyset@plt>
movq   $0x0,-0x10(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
mov    0x2e7a(%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):
<establish_child_signal_handlers>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ea4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <sigemptyset@plt>
movq   $0x0,(%rsp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    0x2e7f(%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 }
@SIG_DFL = global i32 0
@SIGINT = global i32 0
@SIGTERM = global i32 0
define void @establish_child_signal_handlers() {
%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 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 0
store i64 0, i64* %6
%7 = load i32, i32* @SIGINT
%8 = call i32 @sigaction(i32 %7, %struct.sigaction* %1, i32* null)
%9 = load i32, i32* @SIGTERM
%10 = call i32 @sigaction(i32 %9, %struct.sigaction* %1, i32* null)
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { i64, i32, i32 }
@SIG_DFL = global i32 0
@SIGINT = global i32 0
@SIGTERM = global i32 0
define void @establish_child_signal_handlers() {
%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 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 0
store i64 0, i64* %7
%8 = load i32, i32* @SIGINT
%9 = call i32 @sigaction(i32 %8, %struct.sigaction* %1, i32* null)
%10 = load i32, i32* @SIGTERM
%11 = call i32 @sigaction(i32 %10, %struct.sigaction* %1, i32* null)
ret void
}