#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;
scalar_t__ is_changed(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int main(void) {
  sigset_t actl, oactl;
  sigemptyset(&actl);
  sigemptyset(&oactl);
  sigaddset(&actl, SIGABRT);
  sigprocmask(SIG_SETMASK, &actl, NULL);
  sigprocmask(SIG_SETMASK, NULL, &oactl);
  if (is_changed(oactl, SIGABRT))
    return 1;
  printf("Test PASSED: signal mask was not changed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <sigemptyset@plt>
lea    -0xc(%rbp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1070 <sigaddset@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0xc(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    -0xc(%rbp),%edi
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
call   1060 <is_changed@plt>
cmp    $0x0,%rax
je     11d6 <main+0x86>
movl   $0x1,-0x4(%rbp)
jmp    11e9 <main+0x99>
lea    0xe23(%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   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sigemptyset@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <sigemptyset@plt>
mov    0x2e61(%rip),%r15
mov    (%r15),%esi
mov    %rbx,%rdi
call   1070 <sigaddset@plt>
mov    0x2e5f(%rip),%r12
mov    (%r12),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    (%r12),%edi
xor    %esi,%esi
mov    %r14,%rdx
call   1030 <sigprocmask@plt>
mov    (%rsp),%edi
mov    (%r15),%esi
call   1060 <is_changed@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11cb <main+0x7b>
lea    0xe3c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SIGABRT = global i32 0
@SIG_SETMASK = global i32 0
@.str = [43 x i8] c"Test PASSED: signal mask was not changed.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @sigemptyset(i32* %2)
%5 = call i32 @sigemptyset(i32* %3)
%6 = load i32, i32* @SIGABRT
%7 = call i32 @sigaddset(i32* %2, i32 %6)
%8 = load i32, i32* @SIG_SETMASK
%9 = call i32 @sigprocmask(i32 %8, i32* %2, i32* null)
%10 = load i32, i32* @SIG_SETMASK
%11 = call i32 @sigprocmask(i32 %10, i32* null, i32* %3)
%12 = load i32, i32* %3
%13 = load i32, i32* @SIGABRT
%14 = call i64 @is_changed(i32 %12, i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %0
store i32 1, i32* %1
br label %19
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %19
19: ; preds = %17, %16
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@SIGABRT = global i32 0
@SIG_SETMASK = global i32 0
@str = [42 x i8] c"Test PASSED: signal mask was not changed.\00"
define i32 @main() {
%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 = call i32 @sigemptyset(i32* %2)
%7 = load i32, i32* @SIGABRT
%8 = call i32 @sigaddset(i32* %1, i32 %7)
%9 = load i32, i32* @SIG_SETMASK
%10 = call i32 @sigprocmask(i32 %9, i32* %1, i32* null)
%11 = load i32, i32* @SIG_SETMASK
%12 = call i32 @sigprocmask(i32 %11, i32* null, i32* %2)
%13 = load i32, i32* %2
%14 = load i32, i32* @SIGABRT
%15 = call i64 @is_changed(i32 %13, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %0, %17
%20 = phi i32 [ 0, %17 ], [ 1, %0 ]
ret i32 %20
}