#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*/ SIGABRT;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_exit(void *);
scalar_t__ pthread_sigmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/ *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
void *a_thread_func() {
  sigset_t actl;
  sigemptyset(&actl);
  sigaddset(&actl, SIGABRT);
  if (pthread_sigmask(SIG_SETMASK, &actl, NULL) != 0) {
    perror("pthread_sigmask() did not return 0\n");
    pthread_exit((void *)-1);
  }
  printf("PASS: pthread_sigmask returned 0.\n");
  pthread_exit(NULL);
  return NULL;
}


x86 assembly (clang, -O0):
<a_thread_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <pthread_sigmask@plt>
cmp    $0x0,%rax
je     11bb <a_thread_func+0x5b>
lea    0xe56(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffffffffffff,%rdi
call   1050 <pthread_exit@plt>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <pthread_exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a_thread_func>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigaddset@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1060 <pthread_sigmask@plt>
test   %rax,%rax
jne    11b6 <a_thread_func+0x56>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <pthread_exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe43(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffffffffffff,%rdi
call   1050 <pthread_exit@plt>
jmp    119b <a_thread_func+0x3b>

LLVM IR (-O0):
@SIGABRT = global i32 0
@SIG_SETMASK = global i32 0
@.str = [36 x i8] c"pthread_sigmask() did not return 0\0A\00"
@.str.1 = [35 x i8] c"PASS: pthread_sigmask returned 0.\0A\00"
define i8* @a_thread_func() {
%1 = alloca i32
%2 = call i32 @sigemptyset(i32* %1)
%3 = load i32, i32* @SIGABRT
%4 = call i32 @sigaddset(i32* %1, i32 %3)
%5 = load i32, i32* @SIG_SETMASK
%6 = call i64 @pthread_sigmask(i32 %5, i32* %1, i32* null)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @pthread_exit(i8* inttoptr (i64 -1 to i8*))
br label %11
11: ; preds = %8, %0
%12 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @pthread_exit(i8* null)
ret i8* null
}

LLVM IR (-O2):
@SIGABRT = global i32 0
@SIG_SETMASK = global i32 0
@.str = [36 x i8] c"pthread_sigmask() did not return 0\0A\00"
@str = [34 x i8] c"PASS: pthread_sigmask returned 0.\00"
define noalias i8* @a_thread_func() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigemptyset(i32* %1)
%4 = load i32, i32* @SIGABRT
%5 = call i32 @sigaddset(i32* %1, i32 %4)
%6 = load i32, i32* @SIG_SETMASK
%7 = call i64 @pthread_sigmask(i32 %6, i32* %1, i32* null)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @pthread_exit(i8* inttoptr (i64 -1 to i8*))
br label %12
12: ; preds = %9, %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%14 = call i32 @pthread_exit(i8* null)
ret i8* null
}