#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 NSIG;
int SIGKILL;
int SIGSTOP;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ do_exec(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
scalar_t__ sigismember(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc == 1) {
    sigset_t mask;
    sigfillset(&mask);
    do_exec(argv[0], "full", &mask);
    sigemptyset(&mask);
    do_exec(argv[0], "empty", &mask);
  } else {
    sigset_t mask;
    int i;
    int empty;
    if (strcmp(argv[1], "full") == 0)
      empty = 0;
    else if (strcmp(argv[1], "empty") == 0)
      empty = 1;
    else {
      fprintf(stderr, "empty or full?\n");
      exit(1);
    }
    sigprocmask(SIG_SETMASK, NULL, &mask);
    for (i = 1; i < NSIG; i++) {
      if (i == SIGKILL || i == SIGSTOP)
        continue;
      if (empty) {
        if (sigismember(&mask, i))
          printf("empty: signal %d added to mask\n", i);
      } else {
        if (!sigismember(&mask, i))
          printf("full: signal %d missing from mask\n", i);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11f5 <main+0x65>
lea    -0x14(%rbp),%rdi
call   1090 <sigfillset@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe39(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <do_exec@plt>
lea    -0x14(%rbp),%rdi
call   1080 <sigemptyset@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe1e(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <do_exec@plt>
jmp    133b <main+0x1ab>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfc(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    121f <main+0x8f>
movl   $0x0,-0x20(%rbp)
jmp    126d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd7(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1249 <main+0xb9>
movl   $0x1,-0x20(%rbp)
jmp    1268 <main+0xd8>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
lea    0xdb2(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    126d <main+0xdd>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x18(%rbp),%rdx
call   1030 <sigprocmask@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d2c(%rip),%rcx
cmp    (%rcx),%eax
jge    1336 <main+0x1a6>
mov    -0x1c(%rbp),%eax
mov    0x2d2a(%rip),%rcx
cmp    (%rcx),%eax
je     12c0 <main+0x130>
mov    -0x1c(%rbp),%eax
mov    0x2d10(%rip),%rcx
cmp    (%rcx),%eax
jne    12c5 <main+0x135>
jmp    1328 <main+0x198>
cmpl   $0x0,-0x20(%rbp)
je     12f9 <main+0x169>
mov    -0x1c(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   10a0 <sigismember@plt>
cmp    $0x0,%rax
je     12f4 <main+0x164>
mov    -0x1c(%rbp),%esi
lea    0xd2c(%rip),%rdi
call   1050 <printf@plt>
jmp    1323 <main+0x193>
mov    -0x1c(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   10a0 <sigismember@plt>
cmp    $0x0,%rax
jne    131e <main+0x18e>
mov    -0x1c(%rbp),%esi
lea    0xd22(%rip),%rdi
call   1050 <printf@plt>
jmp    1323 <main+0x193>
jmp    1328 <main+0x198>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    128a <main+0xfa>
jmp    133b <main+0x1ab>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
cmp    $0x1,%edi
jne    11e3 <main+0x53>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <sigfillset@plt>
mov    0x0(%rbp),%rdi
lea    0xe45(%rip),%rsi
mov    %rbx,%rdx
call   1040 <do_exec@plt>
mov    %rbx,%rdi
call   1080 <sigemptyset@plt>
mov    0x0(%rbp),%rdi
lea    0xe2f(%rip),%rsi
mov    %rbx,%rdx
call   1040 <do_exec@plt>
jmp    1295 <main+0x105>
mov    0x8(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1060 <strcmp@plt>
mov    %rax,%r15
test   %rax,%rax
je     1214 <main+0x84>
mov    0x8(%rbp),%rdi
lea    0xdff(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12a6 <main+0x116>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rdx
xor    %esi,%esi
call   1030 <sigprocmask@plt>
mov    0x2d92(%rip),%rbx
cmpl   $0x2,(%rbx)
jl     1295 <main+0x105>
mov    $0x1,%ebp
mov    0x2d91(%rip),%r12
mov    0x2d82(%rip),%r13
mov    %rsp,%r14
jmp    125e <main+0xce>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%esi
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    (%rbx),%ebp
jge    1295 <main+0x105>
cmp    (%r12),%ebp
je     1257 <main+0xc7>
cmp    0x0(%r13),%ebp
je     1257 <main+0xc7>
mov    %r14,%rdi
mov    %ebp,%esi
call   10a0 <sigismember@plt>
test   %r15,%r15
je     1287 <main+0xf7>
lea    0xd9b(%rip),%rdi
test   %rax,%rax
jne    1250 <main+0xc0>
jmp    1257 <main+0xc7>
lea    0xdad(%rip),%rdi
test   %rax,%rax
jne    1257 <main+0xc7>
jmp    1250 <main+0xc0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
lea    0xd55(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"full\00"
@.str.1 = [6 x i8] c"empty\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"empty or full?\0A\00"
@SIG_SETMASK = global i32 0
@NSIG = global i32 0
@SIGKILL = global i32 0
@SIGSTOP = global i32 0
@.str.3 = [32 x i8] c"empty: signal %d added to mask\0A\00"
@.str.4 = [35 x i8] c"full: signal %d missing from mask\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %23
12: ; preds = %2
%13 = call i32 @sigfillset(i32* %6)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @do_exec(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %6)
%18 = call i32 @sigemptyset(i32* %6)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @do_exec(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6)
br label %82
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %23
store i32 0, i32* %9
br label %42
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %30
store i32 1, i32* %9
br label %41
37: ; preds = %30
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %36
br label %42
42: ; preds = %41, %29
%43 = load i32, i32* @SIG_SETMASK
%44 = call i32 @sigprocmask(i32 %43, i32* null, i32* %7)
store i32 1, i32* %8
br label %45
45: ; preds = %78, %42
%46 = load i32, i32* %8
%47 = load i32, i32* @NSIG
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %81
49: ; preds = %45
%50 = load i32, i32* %8
%51 = load i32, i32* @SIGKILL
%52 = icmp eq i32 %50, %51
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = load i32, i32* %8
%55 = load i32, i32* @SIGSTOP
%56 = icmp eq i32 %54, %55
br i1 %56, label %57, label %58
57: ; preds = %53, %49
br label %78
58: ; preds = %53
%59 = load i32, i32* %9
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %69
61: ; preds = %58
%62 = load i32, i32* %8
%63 = call i64 @sigismember(i32* %7, i32 %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %61
%66 = load i32, i32* %8
%67 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %65, %61
br label %77
69: ; preds = %58
%70 = load i32, i32* %8
%71 = call i64 @sigismember(i32* %7, i32 %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %69
%74 = load i32, i32* %8
%75 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %73, %69
br label %77
77: ; preds = %76, %68
br label %78
78: ; preds = %77, %57
%79 = load i32, i32* %8
%80 = add nsw i32 %79, 1
store i32 %80, i32* %8
br label %45
81: ; preds = %45
br label %82
82: ; preds = %81, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"full\00"
@.str.1 = [6 x i8] c"empty\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"empty or full?\0A\00"
@SIG_SETMASK = global i32 0
@NSIG = global i32 0
@SIGKILL = global i32 0
@SIGSTOP = global i32 0
@.str.3 = [32 x i8] c"empty: signal %d added to mask\0A\00"
@.str.4 = [35 x i8] c"full: signal %d missing from mask\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = bitcast i32* %3 to i8*
%8 = call i32 @sigfillset(i32* %3)
%9 = load i8*, i8** %1
%10 = call i32 @do_exec(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3)
%11 = call i32 @sigemptyset(i32* %3)
%12 = load i8*, i8** %1
%13 = call i32 @do_exec(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %53
14: ; preds = %2
%15 = bitcast i32* %4 to i8*
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %14
%21 = load i8*, i8** %16
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %20, %14
%29 = load i32, i32* @SIG_SETMASK
%30 = call i32 @sigprocmask(i32 %29, i32* null, i32* %4)
%31 = load i32, i32* @NSIG
%32 = icmp sgt i32 %31, 1
br i1 %32, label %33, label %52
33: ; preds = %28, %48
%34 = phi i32 [ %49, %48 ], [ 1, %28 ]
%35 = load i32, i32* @SIGKILL
%36 = icmp eq i32 %34, %35
%37 = load i32, i32* @SIGSTOP
%38 = icmp eq i32 %34, %37
%39 = select i1 %36, i1 true, i1 %38
br i1 %39, label %48, label %40
40: ; preds = %33
%41 = call i64 @sigismember(i32* %4, i32 %34)
%42 = icmp eq i64 %41, 0
br i1 %19, label %44, label %43
43: ; preds = %40
br i1 %42, label %48, label %45
44: ; preds = %40
br i1 %42, label %45, label %48
45: ; preds = %44, %43
%46 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), %43 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), %44 ]
%47 = call i32 @printf(i8* %46, i32 %34)
br label %48
48: ; preds = %45, %43, %44, %33
%49 = add nuw nsw i32 %34, 1
%50 = load i32, i32* @NSIG
%51 = icmp slt i32 %49, %50
br i1 %51, label %33, label %52
52: ; preds = %48, %28
br label %53
53: ; preds = %52, %6
ret i32 0
}