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

/* Variables and functions */
int /*<<< orphan*/ SA_NOCLDWAIT;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_DFL;
int /*<<< orphan*/ fatal(char *);
int /*<<< orphan*/ memset(struct sigaction *, int /*<<< orphan*/, int);
scalar_t__ sigaction(int /*<<< orphan*/, struct sigaction *,
                     int /*<<< orphan*/ *);
void init(void) {
  struct sigaction s;
  memset(&s, 0, sizeof s);
  s.sa_handler = SIG_DFL;
  s.sa_flags = SA_NOCLDWAIT;
  if (sigaction(SIGCHLD, &s, NULL) < 0)
    fatal("init: could not install SIGCHLD handler");
}


x86 assembly (clang, -O0):
<init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jge    118c <init+0x5c>
lea    0xe79(%rip),%rdi
call   1050 <fatal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jns    1187 <init+0x57>
lea    0xe7e(%rip),%rdi
call   1050 <fatal@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sigaction = type { i32, i32 }
@SIG_DFL = global i32 0
@SA_NOCLDWAIT = global i32 0
@SIGCHLD = global i32 0
@.str = [40 x i8] c"init: could not install SIGCHLD handler\00"
define void @init() {
%1 = alloca %struct.sigaction
%2 = call i32 @memset(%struct.sigaction* %1, i32 0, i32 8)
%3 = load i32, i32* @SIG_DFL
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 1
store i32 %3, i32* %4
%5 = load i32, i32* @SA_NOCLDWAIT
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 0
store i32 %5, i32* %6
%7 = load i32, i32* @SIGCHLD
%8 = call i64 @sigaction(i32 %7, %struct.sigaction* %1, i32* null)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @fatal(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { i32, i32 }
@SIG_DFL = global i32 0
@SA_NOCLDWAIT = global i32 0
@SIGCHLD = global i32 0
@.str = [40 x i8] c"init: could not install SIGCHLD handler\00"
define void @init() {
%1 = alloca %struct.sigaction
%2 = bitcast %struct.sigaction* %1 to i8*
%3 = call i32 @memset(%struct.sigaction* %1, i32 0, i32 8)
%4 = load i32, i32* @SIG_DFL
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 1
store i32 %4, i32* %5
%6 = load i32, i32* @SA_NOCLDWAIT
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 0
store i32 %6, i32* %7
%8 = load i32, i32* @SIGCHLD
%9 = call i64 @sigaction(i32 %8, %struct.sigaction* %1, i32* null)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @fatal(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
ret void
}