#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 /*<<< orphan*/ errno;
int /*<<< orphan*/ printf(char *, char *, int, char *);
scalar_t__ sigaddset(int /*<<< orphan*/ *, int);
scalar_t__ sigdelset(int /*<<< orphan*/ *, int);
scalar_t__ sigemptyset(int /*<<< orphan*/ *);
scalar_t__ sigismember(int /*<<< orphan*/ *, int);
char *strerror(int /*<<< orphan*/);
int do_test(void) {
  int result = 0;
  int sig = -1;
  sigset_t set;
  if (sigemptyset(&set) != 0) {
    printf("%s (sig = %d): %s\n", "sigemptyset (&set) != 0", sig,
           strerror(errno));
    result = 1;
  } else
    ;
  int max_sig = NSIG - 1;
  for (sig = 1; sig <= max_sig; ++sig) {
    if (sigismember(&set, sig) != 0) {
      printf("%s (sig = %d): %s\n", "sigismember (&set, sig) != 0", sig,
             strerror(errno));
      result = 1;
    } else
      ;
    if (sigaddset(&set, sig) != 0) {
      printf("%s (sig = %d): %s\n", "sigaddset (&set, sig) != 0", sig,
             strerror(errno));
      result = 1;
    } else
      ;
    if (sigismember(&set, sig) == 0) {
      printf("%s (sig = %d): %s\n", "sigismember (&set, sig) == 0", sig,
             strerror(errno));
      result = 1;
    } else
      ;
    if (sigdelset(&set, sig) != 0) {
      printf("%s (sig = %d): %s\n", "sigdelset (&set, sig) != 0", sig,
             strerror(errno));
      result = 1;
    } else
      ;
    if (sigismember(&set, sig) != 0) {
      printf("%s (sig = %d): %s\n", "sigismember (&set, sig) != 0", sig,
             strerror(errno));
      result = 1;
    } else
      ;
  }
  return result;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <sigemptyset@plt>
cmp    $0x0,%rax
je     11c2 <do_test+0x62>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x14(%rbp),%edx
mov    %rax,%rcx
lea    0xe56(%rip),%rdi
lea    0xe62(%rip),%rsi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <do_test+0x67>
jmp    11c7 <do_test+0x67>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     13a0 <do_test+0x240>
mov    -0x8(%rbp),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     1238 <do_test+0xd8>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x18(%rbp),%edx
mov    %rax,%rcx
lea    0xde0(%rip),%rdi
lea    0xe04(%rip),%rsi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123d <do_test+0xdd>
jmp    123d <do_test+0xdd>
mov    -0x8(%rbp),%esi
lea    -0xc(%rbp),%rdi
call   1080 <sigaddset@plt>
cmp    $0x0,%rax
je     128c <do_test+0x12c>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x1c(%rbp),%edx
mov    %rax,%rcx
lea    0xd8c(%rip),%rdi
lea    0xdcd(%rip),%rsi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1291 <do_test+0x131>
jmp    1291 <do_test+0x131>
mov    -0x8(%rbp),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
jne    12e0 <do_test+0x180>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x20(%rbp),%edx
mov    %rax,%rcx
lea    0xd38(%rip),%rdi
lea    0xd94(%rip),%rsi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e5 <do_test+0x185>
jmp    12e5 <do_test+0x185>
mov    -0x8(%rbp),%esi
lea    -0xc(%rbp),%rdi
call   1050 <sigdelset@plt>
cmp    $0x0,%rax
je     1334 <do_test+0x1d4>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x24(%rbp),%edx
mov    %rax,%rcx
lea    0xce4(%rip),%rdi
lea    0xd5d(%rip),%rsi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1339 <do_test+0x1d9>
jmp    1339 <do_test+0x1d9>
mov    -0x8(%rbp),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     1388 <do_test+0x228>
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x28(%rbp),%edx
mov    %rax,%rcx
lea    0xc90(%rip),%rdi
lea    0xcb4(%rip),%rsi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    138d <do_test+0x22d>
jmp    138d <do_test+0x22d>
jmp    1392 <do_test+0x232>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11dd <do_test+0x7d>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0x4(%rsp),%rdi
call   1040 <sigemptyset@plt>
test   %rax,%rax
je     11aa <do_test+0x4a>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe71(%rip),%rdi
lea    0xe7d(%rip),%rsi
mov    $0xffffffff,%edx
mov    %rax,%rcx
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    11ac <do_test+0x4c>
xor    %ebp,%ebp
mov    0x2e25(%rip),%rax
mov    (%rax),%r12d
cmp    $0x2,%r12d
jl     12ea <do_test+0x18a>
mov    $0x1,%ebx
lea    0x4(%rsp),%r14
mov    0x2e0f(%rip),%r13
lea    0xe28(%rip),%r15
jmp    11ec <do_test+0x8c>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%r12d
je     12ea <do_test+0x18a>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <sigismember@plt>
test   %rax,%rax
je     121d <do_test+0xbd>
mov    0x0(%r13),%edi
call   1070 <strerror@plt>
mov    %r15,%rdi
lea    0xe1d(%rip),%rsi
mov    %ebx,%edx
mov    %rax,%rcx
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
call   1080 <sigaddset@plt>
test   %rax,%rax
je     124e <do_test+0xee>
mov    0x0(%r13),%edi
call   1070 <strerror@plt>
mov    %r15,%rdi
lea    0xe09(%rip),%rsi
mov    %ebx,%edx
mov    %rax,%rcx
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <sigismember@plt>
test   %rax,%rax
jne    127f <do_test+0x11f>
mov    0x0(%r13),%edi
call   1070 <strerror@plt>
mov    %r15,%rdi
lea    0xdf3(%rip),%rsi
mov    %ebx,%edx
mov    %rax,%rcx
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <sigdelset@plt>
test   %rax,%rax
je     12b0 <do_test+0x150>
mov    0x0(%r13),%edi
call   1070 <strerror@plt>
mov    %r15,%rdi
lea    0xddf(%rip),%rsi
mov    %ebx,%edx
mov    %rax,%rcx
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <sigismember@plt>
test   %rax,%rax
je     11e0 <do_test+0x80>
mov    0x0(%r13),%edi
call   1070 <strerror@plt>
mov    %r15,%rdi
lea    0xd55(%rip),%rsi
mov    %ebx,%edx
mov    %rax,%rcx
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    11e0 <do_test+0x80>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"%s (sig = %d): %s\0A\00"
@.str.1 = [24 x i8] c"sigemptyset (&set) != 0\00"
@errno = global i32 0
@NSIG = global i32 0
@.str.2 = [29 x i8] c"sigismember (&set, sig) != 0\00"
@.str.3 = [27 x i8] c"sigaddset (&set, sig) != 0\00"
@.str.4 = [29 x i8] c"sigismember (&set, sig) == 0\00"
@.str.5 = [27 x i8] c"sigdelset (&set, sig) != 0\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
%5 = call i64 @sigemptyset(i32* %3)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = load i32, i32* %2
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %8, i8* %10)
store i32 1, i32* %1
br label %13
12: ; preds = %0
br label %13
13: ; preds = %12, %7
%14 = load i32, i32* @NSIG
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %4
store i32 1, i32* %2
br label %16
16: ; preds = %71, %13
%17 = load i32, i32* %2
%18 = load i32, i32* %4
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %74
20: ; preds = %16
%21 = load i32, i32* %2
%22 = call i64 @sigismember(i32* %3, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i32, i32* %2
%26 = load i32, i32* @errno
%27 = call i8* @strerror(i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %25, i8* %27)
store i32 1, i32* %1
br label %30
29: ; preds = %20
br label %30
30: ; preds = %29, %24
%31 = load i32, i32* %2
%32 = call i64 @sigaddset(i32* %3, i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load i32, i32* %2
%36 = load i32, i32* @errno
%37 = call i8* @strerror(i32 %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %35, i8* %37)
store i32 1, i32* %1
br label %40
39: ; preds = %30
br label %40
40: ; preds = %39, %34
%41 = load i32, i32* %2
%42 = call i64 @sigismember(i32* %3, i32 %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* %2
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %45, i8* %47)
store i32 1, i32* %1
br label %50
49: ; preds = %40
br label %50
50: ; preds = %49, %44
%51 = load i32, i32* %2
%52 = call i64 @sigdelset(i32* %3, i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = load i32, i32* %2
%56 = load i32, i32* @errno
%57 = call i8* @strerror(i32 %56)
%58 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %55, i8* %57)
store i32 1, i32* %1
br label %60
59: ; preds = %50
br label %60
60: ; preds = %59, %54
%61 = load i32, i32* %2
%62 = call i64 @sigismember(i32* %3, i32 %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %69
64: ; preds = %60
%65 = load i32, i32* %2
%66 = load i32, i32* @errno
%67 = call i8* @strerror(i32 %66)
%68 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %65, i8* %67)
store i32 1, i32* %1
br label %70
69: ; preds = %60
br label %70
70: ; preds = %69, %64
br label %71
71: ; preds = %70
%72 = load i32, i32* %2
%73 = add nsw i32 %72, 1
store i32 %73, i32* %2
br label %16
74: ; preds = %16
%75 = load i32, i32* %1
ret i32 %75
}

LLVM IR (-O2):
@.str = [19 x i8] c"%s (sig = %d): %s\0A\00"
@.str.1 = [24 x i8] c"sigemptyset (&set) != 0\00"
@errno = global i32 0
@NSIG = global i32 0
@.str.2 = [29 x i8] c"sigismember (&set, sig) != 0\00"
@.str.3 = [27 x i8] c"sigaddset (&set, sig) != 0\00"
@.str.4 = [29 x i8] c"sigismember (&set, sig) == 0\00"
@.str.5 = [27 x i8] c"sigdelset (&set, sig) != 0\00"
define i32 @do_test() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @sigemptyset(i32* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = load i32, i32* @errno
%7 = call i8* @strerror(i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 -1, i8* %7)
br label %9
9: ; preds = %0, %5
%10 = phi i32 [ 1, %5 ], [ 0, %0 ]
%11 = load i32, i32* @NSIG
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %58
13: ; preds = %9, %54
%14 = phi i32 [ %55, %54 ], [ %10, %9 ]
%15 = phi i32 [ %56, %54 ], [ 1, %9 ]
%16 = call i64 @sigismember(i32* %1, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %15, i8* %20)
br label %22
22: ; preds = %13, %18
%23 = phi i32 [ 1, %18 ], [ %14, %13 ]
%24 = call i64 @sigaddset(i32* %1, i32 %15)
%25 = icmp eq i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %15, i8* %28)
br label %30
30: ; preds = %22, %26
%31 = phi i32 [ 1, %26 ], [ %23, %22 ]
%32 = call i64 @sigismember(i32* %1, i32 %15)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* @errno
%36 = call i8* @strerror(i32 %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %15, i8* %36)
br label %38
38: ; preds = %30, %34
%39 = phi i32 [ 1, %34 ], [ %31, %30 ]
%40 = call i64 @sigdelset(i32* %1, i32 %15)
%41 = icmp eq i64 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %15, i8* %44)
br label %46
46: ; preds = %38, %42
%47 = phi i32 [ 1, %42 ], [ %39, %38 ]
%48 = call i64 @sigismember(i32* %1, i32 %15)
%49 = icmp eq i64 %48, 0
br i1 %49, label %54, label %50
50: ; preds = %46
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %15, i8* %52)
br label %54
54: ; preds = %50, %46
%55 = phi i32 [ 1, %50 ], [ %47, %46 ]
%56 = add nuw nsw i32 %15, 1
%57 = icmp eq i32 %56, %11
br i1 %57, label %58, label %13
58: ; preds = %54, %9
%59 = phi i32 [ %10, %9 ], [ %55, %54 ]
ret i32 %59
}