#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*/ SIGUSR1;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ __sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ __sigemptyset(int /*<<< orphan*/ *);
int __sigsetequal(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ assert(int);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int test_signal_mask_nonmaskable(void) {
  sigset_t set, old;
  __sigemptyset(&set);
  __sigaddset(&set, SIGSTOP);
  __sigaddset(&set, SIGKILL);
  __sigaddset(&set, SIGUSR1);
  assert(sigprocmask(SIG_BLOCK, &set, &old) == 0);
  assert(sigprocmask(SIG_BLOCK, NULL, &set) == 0);
  __sigaddset(&old, SIGUSR1);
  assert(__sigsetequal(&set, &old));
  return 0;
}


x86 assembly (clang, -O0):
<test_signal_mask_nonmaskable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1050 <__sigemptyset@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1060 <__sigaddset@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1060 <__sigaddset@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1060 <__sigaddset@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x4(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <__sigaddset@plt>
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <__sigsetequal@plt>
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_signal_mask_nonmaskable>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <__sigemptyset@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <__sigaddset@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <__sigaddset@plt>
mov    0x2e5a(%rip),%r15
mov    (%r15),%esi
mov    %rbx,%rdi
call   1060 <__sigaddset@plt>
mov    0x2e38(%rip),%r12
mov    (%r12),%edi
mov    %rsp,%r14
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <sigprocmask@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
mov    (%r12),%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1030 <sigprocmask@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1060 <__sigaddset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <__sigsetequal@plt>
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SIGSTOP = global i32 0
@SIGKILL = global i32 0
@SIGUSR1 = global i32 0
@SIG_BLOCK = global i32 0
define i32 @test_signal_mask_nonmaskable() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @__sigemptyset(i32* %1)
%4 = load i32, i32* @SIGSTOP
%5 = call i32 @__sigaddset(i32* %1, i32 %4)
%6 = load i32, i32* @SIGKILL
%7 = call i32 @__sigaddset(i32* %1, i32 %6)
%8 = load i32, i32* @SIGUSR1
%9 = call i32 @__sigaddset(i32* %1, i32 %8)
%10 = load i32, i32* @SIG_BLOCK
%11 = call i64 @sigprocmask(i32 %10, i32* %1, i32* %2)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* @SIG_BLOCK
%16 = call i64 @sigprocmask(i32 %15, i32* null, i32* %1)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* @SIGUSR1
%21 = call i32 @__sigaddset(i32* %2, i32 %20)
%22 = call i32 @__sigsetequal(i32* %1, i32* %2)
%23 = call i32 @assert(i32 %22)
ret i32 0
}

LLVM IR (-O2):
@SIGSTOP = global i32 0
@SIGKILL = global i32 0
@SIGUSR1 = global i32 0
@SIG_BLOCK = global i32 0
define i32 @test_signal_mask_nonmaskable() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @__sigemptyset(i32* %1)
%6 = load i32, i32* @SIGSTOP
%7 = call i32 @__sigaddset(i32* %1, i32 %6)
%8 = load i32, i32* @SIGKILL
%9 = call i32 @__sigaddset(i32* %1, i32 %8)
%10 = load i32, i32* @SIGUSR1
%11 = call i32 @__sigaddset(i32* %1, i32 %10)
%12 = load i32, i32* @SIG_BLOCK
%13 = call i64 @sigprocmask(i32 %12, i32* %1, i32* %2)
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* @SIG_BLOCK
%18 = call i64 @sigprocmask(i32 %17, i32* null, i32* %1)
%19 = icmp eq i64 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* @SIGUSR1
%23 = call i32 @__sigaddset(i32* %2, i32 %22)
%24 = call i32 @__sigsetequal(i32* %1, i32* %2)
%25 = call i32 @assert(i32 %24)
ret i32 0
}