#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*/ SIGKILL;
int /*<<< orphan*/ SIGSTOP;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int pthread_sigmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *);
int /*<<< orphan*/ sigdelset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int setup_signal_thread(void) {
  sigset_t sig_mask;
  int err;
  sigfillset(&sig_mask);
  sigdelset(&sig_mask, SIGKILL);
  sigdelset(&sig_mask, SIGSTOP);
  err = pthread_sigmask(SIG_SETMASK, &sig_mask, NULL);
  if (err) {
    fprintf(stderr, "pthread_sigmask: %s", strerror(err));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<setup_signal_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1040 <sigfillset@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigdelset@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigdelset@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <pthread_sigmask@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11da <setup_signal_thread+0x8a>
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <strerror@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%rdx
lea    0xe37(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e1 <setup_signal_thread+0x91>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_signal_thread>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1040 <sigfillset@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1060 <sigdelset@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1060 <sigdelset@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <pthread_sigmask@plt>
test   %eax,%eax
je     11c2 <setup_signal_thread+0x72>
mov    0x2e35(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <strerror@plt>
lea    0xe4d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1030 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SIGKILL = global i32 0
@SIGSTOP = global i32 0
@SIG_SETMASK = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"pthread_sigmask: %s\00"
define i32 @setup_signal_thread() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @sigfillset(i32* %2)
%5 = load i32, i32* @SIGKILL
%6 = call i32 @sigdelset(i32* %2, i32 %5)
%7 = load i32, i32* @SIGSTOP
%8 = call i32 @sigdelset(i32* %2, i32 %7)
%9 = load i32, i32* @SIG_SETMASK
%10 = call i32 @pthread_sigmask(i32 %9, i32* %2, i32* null)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = load i32, i32* %3
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 -1, i32* %1
br label %19
18: ; preds = %0
store i32 0, i32* %1
br label %19
19: ; preds = %18, %13
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@SIGKILL = global i32 0
@SIGSTOP = global i32 0
@SIG_SETMASK = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"pthread_sigmask: %s\00"
define i32 @setup_signal_thread() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigfillset(i32* %1)
%4 = load i32, i32* @SIGKILL
%5 = call i32 @sigdelset(i32* %1, i32 %4)
%6 = load i32, i32* @SIGSTOP
%7 = call i32 @sigdelset(i32* %1, i32 %6)
%8 = load i32, i32* @SIG_SETMASK
%9 = call i32 @pthread_sigmask(i32 %8, i32* %1, i32* null)
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i8* @strerror(i32 %9)
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %0, %11
%16 = phi i32 [ -1, %11 ], [ 0, %0 ]
ret i32 %16
}