#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 */
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SIGCONT;
int /*<<< orphan*/ SIGSTOP;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIG_UNBLOCK;
int /*<<< orphan*/ perror(char *);
int sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int sigemptyset(int /*<<< orphan*/ *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int child_signal_handling() {
  sigset_t signals_set;
  int return_value;
  return_value = sigemptyset(&signals_set);
  if (return_value == -1) {
    perror("error, sigemptyset");
    return -1;
  }
  return_value = sigaddset(&signals_set, SIGTERM);
  if (return_value == -1) {
    perror("error, sigaddset");
    return -1;
  }
  return_value = sigaddset(&signals_set, SIGSTOP);
  if (return_value == -1) {
    perror("error, sigaddset");
    return -1;
  }
  return_value = sigaddset(&signals_set, SIGCONT);
  if (return_value == -1) {
    perror("error, sigaddset");
    return -1;
  }
  return_value = sigaddset(&signals_set, SIGUSR1);
  if (return_value == -1) {
    perror("error, sigaddset");
    return -1;
  }
  return_value = sigprocmask(SIG_UNBLOCK, &signals_set, NULL);
  if (return_value == -1) {
    perror("error, sigprocmask");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<child_signal_handling>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1176 <child_signal_handling+0x36>
lea    0xe9b(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1294 <child_signal_handling+0x154>
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11ad <child_signal_handling+0x6d>
lea    0xe77(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1294 <child_signal_handling+0x154>
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11e4 <child_signal_handling+0xa4>
lea    0xe40(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1294 <child_signal_handling+0x154>
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    121b <child_signal_handling+0xdb>
lea    0xe09(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1294 <child_signal_handling+0x154>
mov    0x2dbe(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1252 <child_signal_handling+0x112>
lea    0xdd2(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1294 <child_signal_handling+0x154>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    128d <child_signal_handling+0x14d>
lea    0xda8(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1294 <child_signal_handling+0x154>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<child_signal_handling>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1040 <sigemptyset@plt>
cmp    $0xffffffff,%eax
je     11e4 <child_signal_handling+0xa4>
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigaddset@plt>
lea    0xea1(%rip),%rbx
cmp    $0xffffffff,%eax
je     11eb <child_signal_handling+0xab>
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11eb <child_signal_handling+0xab>
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11eb <child_signal_handling+0xab>
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11eb <child_signal_handling+0xab>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    11f8 <child_signal_handling+0xb8>
lea    0xe42(%rip),%rbx
jmp    11eb <child_signal_handling+0xab>
lea    0xe15(%rip),%rbx
mov    %rbx,%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"error, sigemptyset\00"
@SIGTERM = global i32 0
@.str.1 = [17 x i8] c"error, sigaddset\00"
@SIGSTOP = global i32 0
@SIGCONT = global i32 0
@SIGUSR1 = global i32 0
@SIG_UNBLOCK = global i32 0
@.str.2 = [19 x i8] c"error, sigprocmask\00"
define i32 @child_signal_handling() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @sigemptyset(i32* %2)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %45
9: ; preds = %0
%10 = load i32, i32* @SIGTERM
%11 = call i32 @sigaddset(i32* %2, i32 %10)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = 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 %45
16: ; preds = %9
%17 = load i32, i32* @SIGSTOP
%18 = call i32 @sigaddset(i32* %2, i32 %17)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = 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 %45
23: ; preds = %16
%24 = load i32, i32* @SIGCONT
%25 = call i32 @sigaddset(i32* %2, i32 %24)
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = 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 %45
30: ; preds = %23
%31 = load i32, i32* @SIGUSR1
%32 = call i32 @sigaddset(i32* %2, i32 %31)
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = 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 %45
37: ; preds = %30
%38 = load i32, i32* @SIG_UNBLOCK
%39 = call i32 @sigprocmask(i32 %38, i32* %2, i32* null)
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = 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 %45
44: ; preds = %37
store i32 0, i32* %1
br label %45
45: ; preds = %44, %42, %35, %28, %21, %14, %7
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [19 x i8] c"error, sigemptyset\00"
@SIGTERM = global i32 0
@.str.1 = [17 x i8] c"error, sigaddset\00"
@SIGSTOP = global i32 0
@SIGCONT = global i32 0
@SIGUSR1 = global i32 0
@SIG_UNBLOCK = global i32 0
@.str.2 = [19 x i8] c"error, sigprocmask\00"
define i32 @child_signal_handling() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigemptyset(i32* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %25, label %5
5: ; preds = %0
%6 = load i32, i32* @SIGTERM
%7 = call i32 @sigaddset(i32* %1, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %25, label %9
9: ; preds = %5
%10 = load i32, i32* @SIGSTOP
%11 = call i32 @sigaddset(i32* %1, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %25, label %13
13: ; preds = %9
%14 = load i32, i32* @SIGCONT
%15 = call i32 @sigaddset(i32* %1, i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %25, label %17
17: ; preds = %13
%18 = load i32, i32* @SIGUSR1
%19 = call i32 @sigaddset(i32* %1, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i32, i32* @SIG_UNBLOCK
%23 = call i32 @sigprocmask(i32 %22, i32* %1, i32* null)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %21, %17, %13, %9, %5, %0
%26 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %9 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %13 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %17 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), %21 ]
%27 = call i32 @perror(i8* %26)
br label %28
28: ; preds = %25, %21
%29 = phi i32 [ 0, %21 ], [ -1, %25 ]
ret i32 %29
}