#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*/ printf(char *, char const *, int);
scalar_t__ sigaddset(int /*<<< orphan*/ *, int);
scalar_t__ sigdelset(int /*<<< orphan*/ *, int);
scalar_t__ sigemptyset(int /*<<< orphan*/ *);
scalar_t__ sigfillset(int /*<<< orphan*/ *);
scalar_t__ sigismember(int /*<<< orphan*/ *, int);
int _sigismember(char const *progname, int signal) {
  sigset_t set;
  printf("%s: Testing sigismember(%d)\n", progname, signal);
  if (sigemptyset(&set) != 0 || sigismember(&set, signal))
    return 1;
  if (sigaddset(&set, signal) != 0 || sigismember(&set, signal) == 0)
    return 2;
  if (sigdelset(&set, signal) != 0 || sigismember(&set, signal))
    return 4;
  if (sigfillset(&set) != 0 || sigismember(&set, signal) == 0)
    return 8;
  return 0;
}


x86 assembly (clang, -O0):
<_sigismember>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1040 <sigemptyset@plt>
cmp    $0x0,%rax
jne    11ab <_sigismember+0x4b>
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1070 <sigismember@plt>
cmp    $0x0,%rax
je     11b7 <_sigismember+0x57>
movl   $0x1,-0x4(%rbp)
jmp    1263 <_sigismember+0x103>
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1080 <sigaddset@plt>
cmp    $0x0,%rax
jne    11e3 <_sigismember+0x83>
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1070 <sigismember@plt>
cmp    $0x0,%rax
jne    11ef <_sigismember+0x8f>
movl   $0x2,-0x4(%rbp)
jmp    1263 <_sigismember+0x103>
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1060 <sigdelset@plt>
cmp    $0x0,%rax
jne    121b <_sigismember+0xbb>
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1070 <sigismember@plt>
cmp    $0x0,%rax
je     1227 <_sigismember+0xc7>
movl   $0x4,-0x4(%rbp)
jmp    1263 <_sigismember+0x103>
lea    -0x18(%rbp),%rdi
call   1050 <sigfillset@plt>
cmp    $0x0,%rax
jne    1250 <_sigismember+0xf0>
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1070 <sigismember@plt>
cmp    $0x0,%rax
jne    125c <_sigismember+0xfc>
movl   $0x8,-0x4(%rbp)
jmp    1263 <_sigismember+0x103>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sigismember>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rsi
lea    0xe91(%rip),%rdi
mov    %ebx,%edx
call   1030 <printf@plt>
lea    0x4(%rsp),%rdi
call   1040 <sigemptyset@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11b1 <_sigismember+0x51>
lea    0x4(%rsp),%rdi
mov    %ebx,%esi
call   1070 <sigismember@plt>
test   %rax,%rax
jne    11b1 <_sigismember+0x51>
lea    0x4(%rsp),%rdi
mov    %ebx,%esi
call   1080 <sigaddset@plt>
mov    $0x2,%ebp
test   %rax,%rax
je     11ba <_sigismember+0x5a>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0x4(%rsp),%rdi
mov    %ebx,%esi
call   1070 <sigismember@plt>
test   %rax,%rax
je     11b1 <_sigismember+0x51>
lea    0x4(%rsp),%rdi
mov    %ebx,%esi
call   1060 <sigdelset@plt>
mov    $0x4,%ebp
test   %rax,%rax
jne    11b1 <_sigismember+0x51>
lea    0x4(%rsp),%rdi
mov    %ebx,%esi
call   1070 <sigismember@plt>
test   %rax,%rax
jne    11b1 <_sigismember+0x51>
lea    0x4(%rsp),%rdi
call   1050 <sigfillset@plt>
mov    $0x8,%ebp
test   %rax,%rax
jne    11b1 <_sigismember+0x51>
lea    0x4(%rsp),%rdi
mov    %ebx,%esi
call   1070 <sigismember@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
shl    $0x3,%ebp
jmp    11b1 <_sigismember+0x51>

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

LLVM IR (-O2):
@.str = [29 x i8] c"%s: Testing sigismember(%d)\0A\00"
define i32 @_sigismember(i8* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%6 = call i64 @sigemptyset(i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %30
8: ; preds = %2
%9 = call i64 @sigismember(i32* %3, i32 %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = call i64 @sigaddset(i32* %3, i32 %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = call i64 @sigismember(i32* %3, i32 %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %30, label %17
17: ; preds = %14
%18 = call i64 @sigdelset(i32* %3, i32 %1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = call i64 @sigismember(i32* %3, i32 %1)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = call i64 @sigfillset(i32* %3)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = call i64 @sigismember(i32* %3, i32 %1)
%28 = icmp eq i64 %27, 0
%29 = select i1 %28, i32 8, i32 0
br label %30
30: ; preds = %26, %23, %17, %20, %11, %14, %2, %8
%31 = phi i32 [ 1, %8 ], [ 1, %2 ], [ 2, %14 ], [ 2, %11 ], [ 4, %20 ], [ 4, %17 ], [ 8, %23 ], [ %29, %26 ]
ret i32 %31
}