#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*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int main(void) {
  sigset_t set;
  sigaddset(&set, SIGABRT);
  if (sigprocmask(SIG_SETMASK, &set, NULL) != 0) {
    perror("sigprocmask failed -- returned -- test aborted");
    return 1;
  }
  printf("Test 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   1030 <sigprocmask@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    0xe8f(%rip),%rdi
call   1040 <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   1030 <sigprocmask@plt>
test   %rax,%rax
jne    118a <main+0x4a>
lea    0xeb4(%rip),%rdi
call   1040 <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 = [47 x i8] c"sigprocmask failed -- returned -- test aborted\00"
@.str.1 = [13 x i8] c"Test 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 @sigprocmask(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 ([47 x i8], [47 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 ([13 x i8], [13 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 = [47 x i8] c"sigprocmask failed -- returned -- test aborted\00"
@str = [12 x i8] c"Test 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 @sigprocmask(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 ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ 1, %8 ], [ 0, %10 ]
ret i32 %13
}