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

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
scalar_t__ SIG_IGN;
scalar_t__ sigaction(int /*<<< orphan*/, struct sigaction *,
                     struct sigaction *);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
void ignore_sigint() {
  struct sigaction new_sa;
  struct sigaction old_sa;
  sigfillset(&new_sa.sa_mask);
  new_sa.sa_handler = SIG_IGN;
  new_sa.sa_flags = 0;
  if (sigaction(SIGINT, &new_sa, &old_sa) == 0 && old_sa.sa_handler != SIG_IGN)
    sigaction(SIGINT, &new_sa, 0);
}


x86 assembly (clang, -O0):
<ignore_sigint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x18(%rbp),%rdi
add    $0x10,%rdi
call   1040 <sigfillset@plt>
mov    0x2ea4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jne    1195 <ignore_sigint+0x75>
mov    -0x30(%rbp),%rax
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%rax
je     1195 <ignore_sigint+0x75>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ignore_sigint>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0x18(%rsp),%rdi
call   1040 <sigfillset@plt>
mov    0x2ea8(%rip),%rbx
mov    (%rbx),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e98(%rip),%r14
mov    (%r14),%edi
lea    0x8(%rsp),%rsi
lea    0x20(%rsp),%rdx
call   1030 <sigaction@plt>
test   %rax,%rax
jne    1180 <ignore_sigint+0x60>
mov    0x20(%rsp),%rax
cmp    (%rbx),%rax
je     1180 <ignore_sigint+0x60>
mov    (%r14),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sigaction = type { i64, i64, i32 }
@SIG_IGN = global i64 0
@SIGINT = global i32 0
define void @ignore_sigint() {
%1 = alloca %struct.sigaction
%2 = alloca %struct.sigaction
%3 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 2
%4 = call i32 @sigfillset(i32* %3)
%5 = load i64, i64* @SIG_IGN
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 0
store i64 %5, i64* %6
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 1
store i64 0, i64* %7
%8 = load i32, i32* @SIGINT
%9 = call i64 @sigaction(i32 %8, %struct.sigaction* %1, %struct.sigaction* %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %0
%12 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @SIG_IGN
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* @SIGINT
%18 = call i64 @sigaction(i32 %17, %struct.sigaction* %1, %struct.sigaction* null)
br label %19
19: ; preds = %16, %11, %0
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { i64, i64, i32 }
@SIG_IGN = global i64 0
@SIGINT = global i32 0
define void @ignore_sigint() {
%1 = alloca %struct.sigaction
%2 = alloca %struct.sigaction
%3 = bitcast %struct.sigaction* %1 to i8*
%4 = bitcast %struct.sigaction* %2 to i8*
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 2
%6 = call i32 @sigfillset(i32* %5)
%7 = load i64, i64* @SIG_IGN
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 0
store i64 %7, i64* %8
%9 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 1
store i64 0, i64* %9
%10 = load i32, i32* @SIGINT
%11 = call i64 @sigaction(i32 %10, %struct.sigaction* %1, %struct.sigaction* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %0
%14 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
%15 = load i64, i64* %14
%16 = load i64, i64* @SIG_IGN
%17 = icmp eq i64 %15, %16
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = load i32, i32* @SIGINT
%20 = call i64 @sigaction(i32 %19, %struct.sigaction* %1, %struct.sigaction* null)
br label %21
21: ; preds = %18, %13, %0
ret void
}