#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 */
struct sigaction {
  scalar_t__ sa_handler;
};
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int NSIG;
int /*<<< orphan*/ SIG_BLOCK;
scalar_t__ SIG_DFL;
scalar_t__ SIG_IGN;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sigaction(int, int /*<<< orphan*/ *, struct sigaction *);
int sigismember(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int main() {
  int open = 0, i;
  sigset_t blockedsigs;
  printf("ChildInfo { masked = [");
  sigprocmask(SIG_BLOCK, NULL, &blockedsigs);
  for (i = 0; i < NSIG; ++i) {
    int ret = sigismember(&blockedsigs, i);
    if (ret >= 0) {
      if (!open)
        open = 1;
      else
        printf(",");
      printf("(%d,%s)", i, ret == 1 ? "True" : "False");
    }
  }
  printf("], handlers = [");
  open = 0;
  for (i = 0; i < NSIG; ++i) {
    struct sigaction old;
    if (sigaction(i, NULL, &old) >= 0) {
      if (!open)
        open = 1;
      else
        printf(",");
      printf("(%d,%s)", i,
             old.sa_handler == SIG_IGN
                 ? "Ignored"
                 : (old.sa_handler == SIG_DFL ? "Default" : "Handled"));
    }
  }
  printf("]}");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x10(%rbp),%rdx
call   1030 <sigprocmask@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%eax
jge    120c <main+0xcc>
mov    -0xc(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1060 <sigismember@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11f9 <main+0xb9>
cmpl   $0x0,-0x8(%rbp)
jne    11c2 <main+0x82>
movl   $0x1,-0x8(%rbp)
jmp    11d0 <main+0x90>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%ecx
lea    0xe49(%rip),%rdx
lea    0xe3d(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11fe <main+0xbe>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1181 <main+0x41>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2d96(%rip),%rcx
cmp    (%rcx),%eax
jge    12f1 <main+0x1b1>
mov    -0xc(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x20(%rbp),%rdx
call   1040 <sigaction@plt>
cmp    $0x0,%rax
jl     12de <main+0x19e>
cmpl   $0x0,-0x8(%rbp)
jne    126a <main+0x12a>
movl   $0x1,-0x8(%rbp)
jmp    1278 <main+0x138>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2d5f(%rip),%rcx
cmp    (%rcx),%rax
jne    12a2 <main+0x162>
lea    0xda3(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    12c9 <main+0x189>
mov    -0x20(%rbp),%rdx
mov    0x2d23(%rip),%rax
mov    (%rax),%rsi
lea    0xd95(%rip),%rax
lea    0xd86(%rip),%rcx
cmp    %rsi,%rdx
cmove  %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12e3 <main+0x1a3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1228 <main+0xe8>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rdx
xor    %esi,%esi
call   1030 <sigprocmask@plt>
mov    0x2e40(%rip),%r12
cmpl   $0x0,(%r12)
jle    1201 <main+0xb1>
lea    0xc(%rsp),%r15
lea    0xe7c(%rip),%r14
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    11e0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x1,%ebx
lea    0xe6a(%rip),%rdx
lea    0xe5e(%rip),%rax
cmove  %rax,%rdx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%r13d
add    $0x1,%ebp
cmp    (%r12),%ebp
jge    1201 <main+0xb1>
mov    %r15,%rdi
mov    %ebp,%esi
call   1070 <sigismember@plt>
test   %eax,%eax
js     11d7 <main+0x87>
mov    %eax,%ebx
test   %r13d,%r13d
je     11b0 <main+0x60>
mov    $0x2c,%edi
call   1040 <putchar@plt>
jmp    11b0 <main+0x60>
lea    0xe22(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,(%r12)
jle    12aa <main+0x15a>
lea    0x10(%rsp),%rbx
lea    0xe14(%rip),%r13
lea    0xdea(%rip),%r14
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    1269 <main+0x119>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2da1(%rip),%rcx
cmp    (%rcx),%rax
cmove  %r13,%rdx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%r15d
add    $0x1,%ebp
cmp    (%r12),%ebp
jge    12aa <main+0x15a>
mov    %ebp,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1050 <sigaction@plt>
test   %rax,%rax
js     1260 <main+0x110>
test   %r15d,%r15d
je     1289 <main+0x139>
mov    $0x2c,%edi
call   1040 <putchar@plt>
mov    0x10(%rsp),%rax
lea    0xdad(%rip),%rdx
mov    0x2d34(%rip),%rcx
cmp    (%rcx),%rax
je     1240 <main+0xf0>
lea    0xda2(%rip),%rdx
jmp    1240 <main+0xf0>
lea    0xda1(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sigaction = type { i64 }
@.str = [23 x i8] c"ChildInfo { masked = [\00"
@SIG_BLOCK = global i32 0
@NSIG = global i32 0
@.str.1 = [2 x i8] c",\00"
@.str.2 = [8 x i8] c"(%d,%s)\00"
@.str.3 = [5 x i8] c"True\00"
@.str.4 = [6 x i8] c"False\00"
@.str.5 = [16 x i8] c"], handlers = [\00"
@SIG_IGN = global i64 0
@.str.6 = [8 x i8] c"Ignored\00"
@SIG_DFL = global i64 0
@.str.7 = [8 x i8] c"Default\00"
@.str.8 = [8 x i8] c"Handled\00"
@.str.9 = [3 x i8] c"]}\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sigaction
store i32 0, i32* %1
store i32 0, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @SIG_BLOCK
%9 = call i32 @sigprocmask(i32 %8, i32* null, i32* %4)
store i32 0, i32* %3
br label %10
10: ; preds = %33, %0
%11 = load i32, i32* %3
%12 = load i32, i32* @NSIG
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %36
14: ; preds = %10
%15 = load i32, i32* %3
%16 = call i32 @sigismember(i32* %4, i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %32
19: ; preds = %14
%20 = load i32, i32* %2
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %19
store i32 1, i32* %2
br label %25
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %22
%26 = load i32, i32* %3
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 1
%29 = zext i1 %28 to i64
%30 = select i1 %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %26, i8* %30)
br label %32
32: ; preds = %25, %14
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %10
36: ; preds = %10
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
store i32 0, i32* %3
br label %38
38: ; preds = %70, %36
%39 = load i32, i32* %3
%40 = load i32, i32* @NSIG
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %73
42: ; preds = %38
%43 = load i32, i32* %3
%44 = call i64 @sigaction(i32 %43, i32* null, %struct.sigaction* %6)
%45 = icmp sge i64 %44, 0
br i1 %45, label %46, label %69
46: ; preds = %42
%47 = load i32, i32* %2
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %46
store i32 1, i32* %2
br label %52
50: ; preds = %46
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %52
52: ; preds = %50, %49
%53 = load i32, i32* %3
%54 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %6, i32 0, i32 0
%55 = load i64, i64* %54
%56 = load i64, i64* @SIG_IGN
%57 = icmp eq i64 %55, %56
br i1 %57, label %58, label %59
58: ; preds = %52
br label %66
59: ; preds = %52
%60 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %6, i32 0, i32 0
%61 = load i64, i64* %60
%62 = load i64, i64* @SIG_DFL
%63 = icmp eq i64 %61, %62
%64 = zext i1 %63 to i64
%65 = select i1 %63, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0)
br label %66
66: ; preds = %59, %58
%67 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %58 ], [ %65, %59 ]
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %53, i8* %67)
br label %69
69: ; preds = %66, %42
br label %70
70: ; preds = %69
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
br label %38
73: ; preds = %38
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.sigaction = type { i64 }
@.str = [23 x i8] c"ChildInfo { masked = [\00"
@SIG_BLOCK = global i32 0
@NSIG = global i32 0
@.str.2 = [8 x i8] c"(%d,%s)\00"
@.str.3 = [5 x i8] c"True\00"
@.str.4 = [6 x i8] c"False\00"
@.str.5 = [16 x i8] c"], handlers = [\00"
@SIG_IGN = global i64 0
@.str.6 = [8 x i8] c"Ignored\00"
@SIG_DFL = global i64 0
@.str.7 = [8 x i8] c"Default\00"
@.str.8 = [8 x i8] c"Handled\00"
@.str.9 = [3 x i8] c"]}\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @SIG_BLOCK
%6 = call i32 @sigprocmask(i32 %5, i32* null, i32* %1)
%7 = load i32, i32* @NSIG
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %0, %22
%10 = phi i32 [ %23, %22 ], [ 0, %0 ]
%11 = phi i32 [ %24, %22 ], [ 0, %0 ]
%12 = call i32 @sigismember(i32* %1, i32 %11)
%13 = icmp sgt i32 %12, -1
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = icmp eq i32 %10, 0
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = call i32 @putchar(i32 44)
br label %18
18: ; preds = %14, %16
%19 = icmp eq i32 %12, 1
%20 = select i1 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %11, i8* %20)
br label %22
22: ; preds = %18, %9
%23 = phi i32 [ 1, %18 ], [ %10, %9 ]
%24 = add nuw nsw i32 %11, 1
%25 = load i32, i32* @NSIG
%26 = icmp slt i32 %24, %25
br i1 %26, label %9, label %27
27: ; preds = %22, %0
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%29 = load i32, i32* @NSIG
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %57
31: ; preds = %27
%32 = bitcast %struct.sigaction* %2 to i8*
%33 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
br label %34
34: ; preds = %31, %52
%35 = phi i32 [ 0, %31 ], [ %53, %52 ]
%36 = phi i32 [ 0, %31 ], [ %54, %52 ]
%37 = call i64 @sigaction(i32 %36, i32* null, %struct.sigaction* %2)
%38 = icmp sgt i64 %37, -1
br i1 %38, label %39, label %52
39: ; preds = %34
%40 = icmp eq i32 %35, 0
br i1 %40, label %43, label %41
41: ; preds = %39
%42 = call i32 @putchar(i32 44)
br label %43
43: ; preds = %39, %41
%44 = load i64, i64* %33
%45 = load i64, i64* @SIG_IGN
%46 = icmp eq i64 %44, %45
%47 = load i64, i64* @SIG_DFL
%48 = icmp eq i64 %44, %47
%49 = select i1 %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0)
%50 = select i1 %46, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %49
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %36, i8* %50)
br label %52
52: ; preds = %43, %34
%53 = phi i32 [ 1, %43 ], [ %35, %34 ]
%54 = add nuw nsw i32 %36, 1
%55 = load i32, i32* @NSIG
%56 = icmp slt i32 %54, %55
br i1 %56, label %34, label %57
57: ; preds = %52, %27
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}