#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*/ SIG_SETMASK;
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int sigsetmask(int mask) {
  int n;
  union {
    int the_mask;
    sigset_t the_sigset;
  } in, out;
  sigemptyset(&in.the_sigset);
  in.the_mask = mask;
  n = sigprocmask(SIG_SETMASK, &in.the_sigset, &out.the_sigset);
  if (n)
    return n;
  return out.the_mask;
}


x86 assembly (clang, -O0):
<sigsetmask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1168 <sigsetmask+0x48>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    116e <sigsetmask+0x4e>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigsetmask>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <sigemptyset@plt>
mov    %ebx,0x10(%rsp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rdx
mov    %r14,%rsi
call   1030 <sigprocmask@plt>
test   %eax,%eax
jne    1158 <sigsetmask+0x38>
mov    0x8(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%union.anon = type { i32 }
@SIG_SETMASK = global i32 0
define i32 @sigsetmask(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %union.anon
%6 = alloca %union.anon
store i32 %0, i32* %3
%7 = bitcast %union.anon* %5 to i32*
%8 = call i32 @sigemptyset(i32* %7)
%9 = load i32, i32* %3
%10 = bitcast %union.anon* %5 to i32*
store i32 %9, i32* %10
%11 = load i32, i32* @SIG_SETMASK
%12 = bitcast %union.anon* %5 to i32*
%13 = bitcast %union.anon* %6 to i32*
%14 = call i32 @sigprocmask(i32 %11, i32* %12, i32* %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = load i32, i32* %4
store i32 %18, i32* %2
br label %22
19: ; preds = %1
%20 = bitcast %union.anon* %6 to i32*
%21 = load i32, i32* %20
store i32 %21, i32* %2
br label %22
22: ; preds = %19, %17
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
%union.anon = type { i32 }
@SIG_SETMASK = global i32 0
define i32 @sigsetmask(i32 %0) {
%2 = alloca %union.anon
%3 = alloca %union.anon
%4 = bitcast %union.anon* %2 to i8*
%5 = bitcast %union.anon* %3 to i8*
%6 = getelementptr inbounds %union.anon, %union.anon* %2, i64 0, i32 0
%7 = call i32 @sigemptyset(i32* %6)
store i32 %0, i32* %6
%8 = load i32, i32* @SIG_SETMASK
%9 = getelementptr inbounds %union.anon, %union.anon* %3, i64 0, i32 0
%10 = call i32 @sigprocmask(i32 %8, i32* %6, i32* %9)
%11 = icmp eq i32 %10, 0
%12 = load i32, i32* %9
%13 = select i1 %11, i32 %12, i32 %10
ret i32 %13
}