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

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIG_DFL;
int /*<<< orphan*/ sigaction(int /*<<< orphan*/, struct sigaction *,
                             int /*<<< orphan*/);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
void restore_default_behaviour_on_interrupt(void) {
  struct sigaction act;
  act.sa_handler = SIG_DFL;
  act.sa_flags = 0;
  sigemptyset(&act.sa_mask);
  sigaddset(&act.sa_mask, SIGINT);
  sigaction(SIGINT, &act, 0);
}


x86 assembly (clang, -O0):
<restore_default_behaviour_on_interrupt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <sigemptyset@plt>
lea    -0x18(%rbp),%rdi
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
call   1050 <sigaddset@plt>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<restore_default_behaviour_on_interrupt>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e89(%rip),%r14
mov    (%r14),%esi
mov    %rbx,%rdi
call   1050 <sigaddset@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sigaction = type { i32, i64, i32 }
@SIG_DFL = global i32 0
@SIGINT = global i32 0
define void @restore_default_behaviour_on_interrupt() {
%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
store i64 0, i64* %4
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 0
%6 = call i32 @sigemptyset(i32* %5)
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 0
%8 = load i32, i32* @SIGINT
%9 = call i32 @sigaddset(i32* %7, i32 %8)
%10 = load i32, i32* @SIGINT
%11 = call i32 @sigaction(i32 %10, %struct.sigaction* %1, i32 0)
ret void
}

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