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

/* Variables and functions */
int /*<<< orphan*/ SIG_IGN;
scalar_t__ sigaction(int, struct sigaction *, struct sigaction *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ zfatal(char *);
void zsignal_ignore(int signum) {
  struct sigaction action;
  sigemptyset(&action.sa_mask);
  action.sa_flags = 0;
  action.sa_handler = SIG_IGN;
  if (sigaction(signum, &action, (struct sigaction *)0) < 0) {
    zfatal("FATAL sigaction: %m");
  }
}


x86 assembly (clang, -O0):
<zsignal_ignore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
add    $0x10,%rdi
call   1050 <sigemptyset@plt>
movq   $0x0,-0x18(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <sigaction@plt>
cmp    $0x0,%rax
jge    1182 <zsignal_ignore+0x52>
lea    0xe83(%rip),%rdi
call   1030 <zfatal@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zsignal_ignore>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
lea    0x18(%rsp),%rdi
call   1050 <sigemptyset@plt>
movq   $0x0,0x10(%rsp)
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1040 <sigaction@plt>
test   %rax,%rax
jns    1176 <zsignal_ignore+0x46>
lea    0xe8f(%rip),%rdi
call   1030 <zfatal@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sigaction = type { i32, i64, i32 }
@SIG_IGN = global i32 0
@.str = [20 x i8] c"FATAL sigaction: %m\00"
define void @zsignal_ignore(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sigaction
store i32 %0, i32* %2
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 2
%5 = call i32 @sigemptyset(i32* %4)
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 1
store i64 0, i64* %6
%7 = load i32, i32* @SIG_IGN
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 0
store i32 %7, i32* %8
%9 = load i32, i32* %2
%10 = call i64 @sigaction(i32 %9, %struct.sigaction* %3, %struct.sigaction* null)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 @zfatal(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %1
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { i32, i64, i32 }
@SIG_IGN = global i32 0
@.str = [20 x i8] c"FATAL sigaction: %m\00"
define void @zsignal_ignore(i32 %0) {
%2 = alloca %struct.sigaction
%3 = bitcast %struct.sigaction* %2 to i8*
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 2
%5 = call i32 @sigemptyset(i32* %4)
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 1
store i64 0, i64* %6
%7 = load i32, i32* @SIG_IGN
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
store i32 %7, i32* %8
%9 = call i64 @sigaction(i32 %0, %struct.sigaction* %2, %struct.sigaction* null)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @zfatal(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %1
ret void
}