#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*/ SIGQUIT;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ show_mask();
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int main(void) {
  sigset_t newmask, oldmask;
  sigemptyset(&newmask);
  sigaddset(&newmask, SIGQUIT);
  if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0)
    printf("sigprocmask error\n");
  show_mask();
  if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0)
    printf("sigprocmask error\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <sigemptyset@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1070 <sigaddset@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    11a6 <main+0x56>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <show_mask@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    11d9 <main+0x89>
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sigemptyset@plt>
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <sigaddset@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rdx
mov    %rbx,%rsi
call   1030 <sigprocmask@plt>
test   %rax,%rax
jns    119a <main+0x4a>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <show_mask@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
test   %rax,%rax
jns    11c7 <main+0x77>
lea    0xe3e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@SIGQUIT = global i32 0
@SIG_BLOCK = global i32 0
@SIG_SETMASK = global i32 0
@str.1 = [18 x i8] c"sigprocmask error\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 = load i32, i32* @SIGQUIT
%7 = call i32 @sigaddset(i32* %1, i32 %6)
%8 = load i32, i32* @SIG_BLOCK
%9 = call i64 @sigprocmask(i32 %8, i32* %1, i32* %2)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
%14 = call i32 (...) @show_mask()
%15 = load i32, i32* @SIG_SETMASK
%16 = call i64 @sigprocmask(i32 %15, i32* %2, i32* null)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
ret i32 0
}