#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*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ sigemptyset(int /*<<< orphan*/ *);
scalar_t__ sigismember(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int main() {
  sigset_t set, pendset;
  if (sigemptyset(&set) < 0) {
    perror("sigemptyset");
    exit(1);
  }
  if (sigaddset(&set, SIGQUIT) < 0) {
    perror("sigaddset");
    exit(1);
  }
  if (sigaddset(&set, SIGINT) < 0) {
    perror("sigaddset");
    exit(1);
  }
  if (sigprocmask(SIG_BLOCK, &set, NULL) < 0) {
    perror("sigprocmask");
    exit(1);
  }
  if (sigprocmask(0, NULL, &pendset) < 0) {
    perror("sigprocmask");
    exit(1);
  }
  if (sigismember(&pendset, SIGINT)) {
    printf("Block SIGINT\n");
  }
  if (sigismember(&pendset, SIGQUIT)) {
    printf("Block SIGQUIT\n");
  }
}


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>
cmp    $0x0,%rax
jge    11a8 <main+0x38>
lea    0xe67(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1090 <sigaddset@plt>
cmp    $0x0,%rax
jge    11da <main+0x6a>
lea    0xe41(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1090 <sigaddset@plt>
cmp    $0x0,%rax
jge    120c <main+0x9c>
lea    0xe0f(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    1242 <main+0xd2>
lea    0xde3(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0xc(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    1271 <main+0x101>
lea    0xdb4(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1070 <sigismember@plt>
cmp    $0x0,%rax
je     1299 <main+0x129>
lea    0xd8e(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1070 <sigismember@plt>
cmp    $0x0,%rax
je     12c1 <main+0x151>
lea    0xd74(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsp,%rdi
call   1050 <sigemptyset@plt>
test   %rax,%rax
js     1238 <main+0xc8>
mov    0x2e54(%rip),%r14
mov    (%r14),%esi
mov    %rsp,%rdi
call   1090 <sigaddset@plt>
test   %rax,%rax
js     1226 <main+0xb6>
mov    0x2e41(%rip),%rbx
mov    (%rbx),%esi
mov    %rsp,%rdi
call   1090 <sigaddset@plt>
test   %rax,%rax
js     1226 <main+0xb6>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
test   %rax,%rax
js     122f <main+0xbf>
lea    0x4(%rsp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <sigprocmask@plt>
test   %rax,%rax
js     122f <main+0xbf>
mov    (%rbx),%esi
lea    0x4(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     11fe <main+0x8e>
lea    0xe37(%rip),%rdi
call   1040 <puts@plt>
mov    (%r14),%esi
lea    0x4(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     121c <main+0xac>
lea    0xe0b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xddf(%rip),%rdi
jmp    123f <main+0xcf>
lea    0xde0(%rip),%rdi
jmp    123f <main+0xcf>
lea    0xdc1(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"sigemptyset\00"
@SIGQUIT = global i32 0
@.str.1 = [10 x i8] c"sigaddset\00"
@SIGINT = global i32 0
@SIG_BLOCK = global i32 0
@.str.2 = [12 x i8] c"sigprocmask\00"
@.str.3 = [14 x i8] c"Block SIGINT\0A\00"
@.str.4 = [15 x i8] c"Block SIGQUIT\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 @sigemptyset(i32* %2)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i32, i32* @SIGQUIT
%11 = call i64 @sigaddset(i32* %2, i32 %10)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %9
%17 = load i32, i32* @SIGINT
%18 = call i64 @sigaddset(i32* %2, i32 %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %16
%24 = load i32, i32* @SIG_BLOCK
%25 = call i64 @sigprocmask(i32 %24, i32* %2, i32* null)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %23
%31 = call i64 @sigprocmask(i32 0, i32* null, i32* %3)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %30
%37 = load i32, i32* @SIGINT
%38 = call i64 @sigismember(i32* %3, i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
%43 = load i32, i32* @SIGQUIT
%44 = call i64 @sigismember(i32* %3, i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %46, %42
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [12 x i8] c"sigemptyset\00"
@SIGQUIT = global i32 0
@.str.1 = [10 x i8] c"sigaddset\00"
@SIGINT = global i32 0
@SIG_BLOCK = global i32 0
@.str.2 = [12 x i8] c"sigprocmask\00"
@str = [14 x i8] c"Block SIGQUIT\00"
@str.5 = [13 x i8] c"Block SIGINT\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i64 @sigemptyset(i32* %1)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = load i32, i32* @SIGQUIT
%12 = call i64 @sigaddset(i32* %1, i32 %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = load i32, i32* @SIGINT
%19 = call i64 @sigaddset(i32* %1, i32 %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %17
%25 = load i32, i32* @SIG_BLOCK
%26 = call i64 @sigprocmask(i32 %25, i32* %1, i32* null)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %24
%32 = call i64 @sigprocmask(i32 0, i32* null, i32* %2)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %31
%38 = load i32, i32* @SIGINT
%39 = call i64 @sigismember(i32* %2, i32 %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %37
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
br label %43
43: ; preds = %41, %37
%44 = load i32, i32* @SIGQUIT
%45 = call i64 @sigismember(i32* %2, i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %43
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
ret i32 0
}