#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ member_0;
};
struct sigaction {
  int /*<<< orphan*/ sa_handler;
  TYPE_1__ member_0;
};
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ perror(char *);
int sigaction(int /*<<< orphan*/, struct sigaction *, int /*<<< orphan*/ *);
int sigdelset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int sigfillset(int /*<<< orphan*/ *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int parent_signal_handling() {
  struct sigaction action_sigchld = {{0}};
  sigset_t signals_set;
  int return_value;
  return_value = sigfillset(&signals_set);
  if (return_value == -1) {
    perror("error, sigfillset");
    return -1;
  }
  return_value = sigdelset(&signals_set, SIGCHLD);
  if (return_value == -1) {
    perror("error, sigdelset");
    return -1;
  }
  return_value = sigprocmask(SIG_BLOCK, &signals_set, NULL);
  if (return_value == -1) {
    perror("error, sigprocmask");
    return -1;
  }
  action_sigchld.sa_handler = SIG_IGN;
  return_value = sigaction(SIGCHLD, &action_sigchld, NULL);
  if (return_value == -1) {
    perror("error, sigaction");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parent_signal_handling>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
lea    -0x14(%rbp),%rdi
call   1060 <sigfillset@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11a6 <parent_signal_handling+0x46>
lea    0xe6b(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <parent_signal_handling+0x106>
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
lea    -0x14(%rbp),%rdi
call   1070 <sigdelset@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11dd <parent_signal_handling+0x7d>
lea    0xe46(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <parent_signal_handling+0x106>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1218 <parent_signal_handling+0xb8>
lea    0xe1c(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <parent_signal_handling+0x106>
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <sigaction@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    125f <parent_signal_handling+0xff>
lea    0xde8(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <parent_signal_handling+0x106>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parent_signal_handling>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <sigfillset@plt>
cmp    $0xffffffff,%eax
je     11ce <parent_signal_handling+0x7e>
mov    0x2e72(%rip),%r14
mov    (%r14),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigdelset@plt>
cmp    $0xffffffff,%eax
je     11d7 <parent_signal_handling+0x87>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
je     11e0 <parent_signal_handling+0x90>
mov    0x2e35(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1040 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    11f1 <parent_signal_handling+0xa1>
lea    0xe6a(%rip),%rdi
jmp    11e7 <parent_signal_handling+0x97>
lea    0xe2b(%rip),%rdi
jmp    11e7 <parent_signal_handling+0x97>
lea    0xe34(%rip),%rdi
jmp    11e7 <parent_signal_handling+0x97>
lea    0xe3c(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sigaction = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [18 x i8] c"error, sigfillset\00"
@SIGCHLD = global i32 0
@.str.1 = [17 x i8] c"error, sigdelset\00"
@SIG_BLOCK = global i32 0
@.str.2 = [19 x i8] c"error, sigprocmask\00"
@SIG_IGN = global i32 0
@.str.3 = [17 x i8] c"error, sigaction\00"
define i32 @parent_signal_handling() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = alloca i32
%4 = alloca i32
%5 = bitcast %struct.sigaction* %2 to i8*
%6 = call i32 @sigfillset(i32* %3)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %35
11: ; preds = %0
%12 = load i32, i32* @SIGCHLD
%13 = call i32 @sigdelset(i32* %3, i32 %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %35
18: ; preds = %11
%19 = load i32, i32* @SIG_BLOCK
%20 = call i32 @sigprocmask(i32 %19, i32* %3, i32* null)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %35
25: ; preds = %18
%26 = load i32, i32* @SIG_IGN
%27 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
store i32 %26, i32* %27
%28 = load i32, i32* @SIGCHLD
%29 = call i32 @sigaction(i32 %28, %struct.sigaction* %2, i32* null)
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %25
%33 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %35
34: ; preds = %25
store i32 0, i32* %1
br label %35
35: ; preds = %34, %32, %23, %16, %9
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
%struct.sigaction = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [18 x i8] c"error, sigfillset\00"
@SIGCHLD = global i32 0
@.str.1 = [17 x i8] c"error, sigdelset\00"
@SIG_BLOCK = global i32 0
@.str.2 = [19 x i8] c"error, sigprocmask\00"
@SIG_IGN = global i32 0
@.str.3 = [17 x i8] c"error, sigaction\00"
define i32 @parent_signal_handling() {
%1 = alloca i64
%2 = bitcast i64* %1 to %struct.sigaction*
%3 = alloca i32
%4 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%5 = bitcast i32* %3 to i8*
%6 = call i32 @sigfillset(i32* %3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %22, label %8
8: ; preds = %0
%9 = load i32, i32* @SIGCHLD
%10 = call i32 @sigdelset(i32* %3, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %22, label %12
12: ; preds = %8
%13 = load i32, i32* @SIG_BLOCK
%14 = call i32 @sigprocmask(i32 %13, i32* %3, i32* null)
%15 = icmp eq i32 %14, -1
br i1 %15, label %22, label %16
16: ; preds = %12
%17 = load i32, i32* @SIG_IGN
%18 = bitcast i64* %1 to i32*
store i32 %17, i32* %18
%19 = load i32, i32* @SIGCHLD
%20 = call i32 @sigaction(i32 %19, %struct.sigaction* %2, i32* null)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %16, %12, %8, %0
%23 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), %12 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %16 ]
%24 = call i32 @perror(i8* %23)
br label %25
25: ; preds = %22, %16
%26 = phi i32 [ 0, %16 ], [ -1, %22 ]
ret i32 %26
}