#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*/ SIG_BLOCK;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int pthread_sigmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *);
int sigfillset(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int block_signals(void) {
  int status;
  sigset_t sigset;
  status = sigfillset(&sigset);
  if (status) {
    fprintf(stderr, "setting up full signal set %d\n", status);
    return -1;
  }
  status = pthread_sigmask(SIG_BLOCK, &sigset, NULL);
  if (status) {
    fprintf(stderr, "setting signal mask: %d\n", status);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<block_signals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xc(%rbp),%rdi
call   1040 <sigfillset@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1172 <block_signals+0x42>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe9f(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <block_signals+0x90>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <pthread_sigmask@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b9 <block_signals+0x89>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe77(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <block_signals+0x90>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<block_signals>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1040 <sigfillset@plt>
test   %eax,%eax
je     1155 <block_signals+0x25>
mov    0x2e96(%rip),%rcx
mov    (%rcx),%edi
lea    0xead(%rip),%rsi
jmp    1180 <block_signals+0x50>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1050 <pthread_sigmask@plt>
test   %eax,%eax
je     118c <block_signals+0x5c>
mov    0x2e69(%rip),%rcx
mov    (%rcx),%edi
lea    0xe9f(%rip),%rsi
mov    %eax,%edx
call   1030 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"setting up full signal set %d\0A\00"
@SIG_BLOCK = global i32 0
@.str.1 = [25 x i8] c"setting signal mask: %d\0A\00"
define i32 @block_signals() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @sigfillset(i32* %3)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* %2
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 -1, i32* %1
br label %21
11: ; preds = %0
%12 = load i32, i32* @SIG_BLOCK
%13 = call i32 @pthread_sigmask(i32 %12, i32* %3, i32* null)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i32, i32* %2
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %18)
store i32 -1, i32* %1
br label %21
20: ; preds = %11
store i32 0, i32* %1
br label %21
21: ; preds = %20, %16, %7
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"setting up full signal set %d\0A\00"
@SIG_BLOCK = global i32 0
@.str.1 = [25 x i8] c"setting signal mask: %d\0A\00"
define i32 @block_signals() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigfillset(i32* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %15
8: ; preds = %0
%9 = load i32, i32* @SIG_BLOCK
%10 = call i32 @pthread_sigmask(i32 %9, i32* %1, i32* null)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %15
15: ; preds = %8, %12, %5
%16 = phi i32 [ -1, %5 ], [ -1, %12 ], [ 0, %8 ]
ret i32 %16
}