#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 *);
scalar_t__ pthread_sigmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/ *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(void) {
  sigset_t set;
  sigaddset(&set, SIGABRT);
  if (pthread_sigmask(SIG_SETMASK, &set, NULL) != 0) {
    perror("pthread_sigmask failed -- returned -- test aborted");
    return 1;
  }
  printf("pthread_sigmask passed\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <pthread_sigmask@plt>
cmp    $0x0,%rax
je     1199 <main+0x59>
lea    0xe78(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ac <main+0x6c>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1060 <sigaddset@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <pthread_sigmask@plt>
test   %rax,%rax
jne    118a <main+0x4a>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe6f(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%ebx
jmp    1180 <main+0x40>

LLVM IR (-O0):
@SIGABRT = global i32 0
@SIG_SETMASK = global i32 0
@.str = [51 x i8] c"pthread_sigmask failed -- returned -- test aborted\00"
@.str.1 = [24 x i8] c"pthread_sigmask passed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @SIGABRT
%4 = call i32 @sigaddset(i32* %2, i32 %3)
%5 = load i32, i32* @SIG_SETMASK
%6 = call i64 @pthread_sigmask(i32 %5, i32* %2, i32* null)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %12
12: ; preds = %10, %8
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@SIGABRT = global i32 0
@SIG_SETMASK = global i32 0
@.str = [51 x i8] c"pthread_sigmask failed -- returned -- test aborted\00"
@str = [23 x i8] c"pthread_sigmask passed\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%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 eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ 1, %8 ], [ 0, %10 ]
ret i32 %13
}