#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*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ FD_CLR(int, int /*<<< orphan*/ *);
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int FD_SETSIZE;
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdout;
int main(void) {
  int retval = 0;
  int i;
  fd_set set;
  FD_ZERO(&set);
  for (i = 0; i < FD_SETSIZE; ++i) {
    printf("%d =>  check:", i);
    if (FD_ISSET(i, &set) == 0)
      fputs("ok", stdout);
    else {
      fputs("nok", stdout);
      retval = 1;
    }
    fputs(", set", stdout);
    FD_SET(i, &set);
    fputs(", check:", stdout);
    if (FD_ISSET(i, &set))
      fputs("ok", stdout);
    else {
      fputs("nok", stdout);
      retval = 1;
    }
    fputs(", clear", stdout);
    FD_CLR(i, &set);
    fputs(", check:", stdout);
    if (FD_ISSET(i, &set) == 0)
      puts("ok");
    else {
      puts("nok");
      retval = 1;
    }
  }
  return retval;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1070 <FD_ZERO@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%eax
jge    1308 <main+0x198>
mov    -0xc(%rbp),%esi
lea    0xe4e(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
jne    11e7 <main+0x77>
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
lea    0xe32(%rip),%rdi
call   1060 <fputs@plt>
jmp    1203 <main+0x93>
mov    0x2dea(%rip),%rax
mov    (%rax),%esi
lea    0xe17(%rip),%rdi
call   1060 <fputs@plt>
movl   $0x1,-0x8(%rbp)
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
lea    0xdff(%rip),%rdi
call   1060 <fputs@plt>
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1090 <FD_SET@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%esi
lea    0xde4(%rip),%rdi
call   1060 <fputs@plt>
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1269 <main+0xf9>
mov    0x2d82(%rip),%rax
mov    (%rax),%esi
lea    0xdb0(%rip),%rdi
call   1060 <fputs@plt>
jmp    1285 <main+0x115>
mov    0x2d68(%rip),%rax
mov    (%rax),%esi
lea    0xd95(%rip),%rdi
call   1060 <fputs@plt>
movl   $0x1,-0x8(%rbp)
mov    0x2d4c(%rip),%rax
mov    (%rax),%esi
lea    0xd8c(%rip),%rdi
call   1060 <fputs@plt>
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1080 <FD_CLR@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
lea    0xd62(%rip),%rdi
call   1060 <fputs@plt>
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
jne    12e2 <main+0x172>
lea    0xd37(%rip),%rdi
call   1030 <puts@plt>
jmp    12f5 <main+0x185>
lea    0xd25(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x8(%rbp)
jmp    12fa <main+0x18a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x26>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0x4(%rsp),%rdi
call   1070 <FD_ZERO@plt>
mov    0x2e54(%rip),%rax
cmpl   $0x0,(%rax)
jle    12a5 <main+0x135>
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
lea    0xe59(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %ebx,%edi
lea    0x4(%rsp),%r14
mov    %r14,%rsi
call   1040 <FD_ISSET@plt>
test   %rax,%rax
mov    0x2e11(%rip),%r12
mov    (%r12),%esi
lea    0xe3c(%rip),%rdi
lea    0xe36(%rip),%r13
cmove  %r13,%rdi
mov    $0x1,%eax
cmovne %eax,%ebp
call   1060 <fputs@plt>
mov    (%r12),%esi
lea    0xe1d(%rip),%rdi
call   1060 <fputs@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1090 <FD_SET@plt>
mov    (%r12),%esi
lea    0xe09(%rip),%r15
mov    %r15,%rdi
call   1060 <fputs@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <FD_ISSET@plt>
test   %rax,%rax
mov    %r13,%rdi
lea    0xde0(%rip),%r13
cmove  %r13,%rdi
mov    $0x1,%eax
cmove  %eax,%ebp
mov    (%r12),%esi
call   1060 <fputs@plt>
mov    (%r12),%esi
lea    0xdd3(%rip),%rdi
call   1060 <fputs@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1080 <FD_CLR@plt>
mov    (%r12),%esi
mov    %r15,%rdi
call   1060 <fputs@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <FD_ISSET@plt>
test   %rax,%rax
lea    0xd92(%rip),%rax
cmove  %rax,%r13
mov    $0x1,%eax
cmovne %eax,%ebp
mov    %r13,%rdi
call   1030 <puts@plt>
mov    0x2d48(%rip),%rax
add    $0x1,%ebx
cmp    (%rax),%ebx
jl     11a0 <main+0x30>
jmp    12a7 <main+0x137>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@FD_SETSIZE = global i32 0
@.str = [14 x i8] c"%d => check:\00"
@.str.1 = [3 x i8] c"ok\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"nok\00"
@.str.3 = [6 x i8] c", set\00"
@.str.4 = [9 x i8] c", check:\00"
@.str.5 = [8 x i8] c", clear\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 @FD_ZERO(i32* %4)
store i32 0, i32* %3
br label %6
6: ; preds = %53, %0
%7 = load i32, i32* %3
%8 = load i32, i32* @FD_SETSIZE
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %56
10: ; preds = %6
%11 = load i32, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %3
%14 = call i64 @FD_ISSET(i32 %13, i32* %4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* @stdout
%18 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %22
19: ; preds = %10
%20 = load i32, i32* @stdout
%21 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
store i32 1, i32* %2
br label %22
22: ; preds = %19, %16
%23 = load i32, i32* @stdout
%24 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %3
%26 = call i32 @FD_SET(i32 %25, i32* %4)
%27 = load i32, i32* @stdout
%28 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %3
%30 = call i64 @FD_ISSET(i32 %29, i32* %4)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %22
%33 = load i32, i32* @stdout
%34 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %38
35: ; preds = %22
%36 = load i32, i32* @stdout
%37 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %36)
store i32 1, i32* %2
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* @stdout
%40 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %3
%42 = call i32 @FD_CLR(i32 %41, i32* %4)
%43 = load i32, i32* @stdout
%44 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %3
%46 = call i64 @FD_ISSET(i32 %45, i32* %4)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %38
%49 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %52
50: ; preds = %38
%51 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %52
52: ; preds = %50, %48
br label %53
53: ; preds = %52
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %6
56: ; preds = %6
%57 = load i32, i32* %2
ret i32 %57
}

LLVM IR (-O2):
@FD_SETSIZE = global i32 0
@.str = [14 x i8] c"%d => check:\00"
@.str.1 = [3 x i8] c"ok\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"nok\00"
@.str.3 = [6 x i8] c", set\00"
@.str.4 = [9 x i8] c", check:\00"
@.str.5 = [8 x i8] c", clear\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @FD_ZERO(i32* %1)
%4 = load i32, i32* @FD_SETSIZE
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %40
6: ; preds = %0, %6
%7 = phi i32 [ %37, %6 ], [ 0, %0 ]
%8 = phi i32 [ %35, %6 ], [ 0, %0 ]
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %7)
%10 = call i64 @FD_ISSET(i32 %7, i32* %1)
%11 = icmp eq i64 %10, 0
%12 = load i32, i32* @stdout
%13 = select i1 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%14 = select i1 %11, i32 %8, i32 1
%15 = call i32 @fputs(i8* %13, i32 %12)
%16 = load i32, i32* @stdout
%17 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = call i32 @FD_SET(i32 %7, i32* %1)
%19 = load i32, i32* @stdout
%20 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = call i64 @FD_ISSET(i32 %7, i32* %1)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%24 = select i1 %22, i32 1, i32 %14
%25 = load i32, i32* @stdout
%26 = call i32 @fputs(i8* %23, i32 %25)
%27 = load i32, i32* @stdout
%28 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = call i32 @FD_CLR(i32 %7, i32* %1)
%30 = load i32, i32* @stdout
%31 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = call i64 @FD_ISSET(i32 %7, i32* %1)
%33 = icmp eq i64 %32, 0
%34 = select i1 %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%35 = select i1 %33, i32 %24, i32 1
%36 = call i32 @puts(i8* dereferenceable(1) %34)
%37 = add nuw nsw i32 %7, 1
%38 = load i32, i32* @FD_SETSIZE
%39 = icmp slt i32 %37, %38
br i1 %39, label %6, label %40
40: ; preds = %6, %0
%41 = phi i32 [ 0, %0 ], [ %35, %6 ]
ret i32 %41
}