#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;
typedef int /*<<< orphan*/ sigjmp_buf;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
scalar_t__ sigismember(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ siglongjmp(int /*<<< orphan*/, int);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
scalar_t__ sigsetjmp(int /*<<< orphan*/, int /*<<< orphan*/);
int do_test(void) {
  sigjmp_buf sj;
  sigset_t m;
  sigemptyset(&m);
  sigprocmask(SIG_SETMASK, &m, NULL);
  if (sigsetjmp(sj, 0) == 0) {
    sigaddset(&m, SIGUSR1);
    sigprocmask(SIG_SETMASK, &m, NULL);
    siglongjmp(sj, 1);
    return EXIT_FAILURE;
  }
  sigprocmask(SIG_SETMASK, NULL, &m);
  return sigismember(&m, SIGUSR1) ? EXIT_SUCCESS : EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1060 <sigsetjmp@plt>
cmp    $0x0,%rax
jne    11d0 <do_test+0x70>
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1040 <siglongjmp@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x8(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1070 <sigismember@plt>
cmp    $0x0,%rax
je     1213 <do_test+0xb3>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    121f <do_test+0xbf>
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sigemptyset@plt>
mov    0x2e68(%rip),%r14
mov    (%r14),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
xor    %esi,%esi
call   1060 <sigsetjmp@plt>
test   %rax,%rax
je     11d3 <do_test+0x73>
mov    (%r14),%edi
lea    0x4(%rsp),%rbx
xor    %esi,%esi
mov    %rbx,%rdx
call   1030 <sigprocmask@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
jne    11c2 <do_test+0x62>
mov    0x2e10(%rip),%rax
jmp    11c9 <do_test+0x69>
mov    0x2dff(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <sigaddset@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    $0x1,%esi
call   1040 <siglongjmp@plt>

LLVM IR (-O0):
@SIG_SETMASK = global i32 0
@SIGUSR1 = global i32 0
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @sigemptyset(i32* %2)
%4 = load i32, i32* @SIG_SETMASK
%5 = call i32 @sigprocmask(i32 %4, i32* %2, i32* null)
%6 = load i32, i32* %1
%7 = call i64 @sigsetjmp(i32 %6, i32 0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = load i32, i32* @SIGUSR1
%11 = call i32 @sigaddset(i32* %2, i32 %10)
%12 = load i32, i32* @SIG_SETMASK
%13 = call i32 @sigprocmask(i32 %12, i32* %2, i32* null)
%14 = load i32, i32* %1
%15 = call i32 @siglongjmp(i32 %14, i32 1)
unreachable
16: ; preds = %0
%17 = load i32, i32* @SIG_SETMASK
%18 = call i32 @sigprocmask(i32 %17, i32* null, i32* %2)
%19 = load i32, i32* @SIGUSR1
%20 = call i64 @sigismember(i32* %2, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = load i32, i32* @EXIT_SUCCESS
br label %26
24: ; preds = %16
%25 = load i32, i32* @EXIT_FAILURE
br label %26
26: ; preds = %24, %22
%27 = phi i32 [ %23, %22 ], [ %25, %24 ]
ret i32 %27
}

LLVM IR (-O2):
@SIG_SETMASK = global i32 0
@SIGUSR1 = global i32 0
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @do_test() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigemptyset(i32* %1)
%4 = load i32, i32* @SIG_SETMASK
%5 = call i32 @sigprocmask(i32 %4, i32* %1, i32* null)
%6 = call i64 @sigsetjmp(i32 undef, i32 0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %0
%9 = load i32, i32* @SIGUSR1
%10 = call i32 @sigaddset(i32* %1, i32 %9)
%11 = load i32, i32* @SIG_SETMASK
%12 = call i32 @sigprocmask(i32 %11, i32* %1, i32* null)
%13 = call i32 @siglongjmp(i32 undef, i32 1)
unreachable
14: ; preds = %0
%15 = load i32, i32* @SIG_SETMASK
%16 = call i32 @sigprocmask(i32 %15, i32* null, i32* %1)
%17 = load i32, i32* @SIGUSR1
%18 = call i64 @sigismember(i32* %1, i32 %17)
%19 = icmp eq i64 %18, 0
%20 = load i32, i32* @EXIT_SUCCESS
%21 = load i32, i32* @EXIT_FAILURE
%22 = select i1 %19, i32 %21, i32 %20
ret i32 %22
}