#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 */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
void dump_fds(int nfds, fd_set *fds) {
  int i;
  if (fds != NULL && nfds > 0) {
    for (i = 0; i < nfds; i++)
      printf("%d ", (FD_ISSET(i, fds) ? 1 : 0));
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<dump_fds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119e <dump_fds+0x7e>
cmpl   $0x0,-0x4(%rbp)
jle    119e <dump_fds+0x7e>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1190 <dump_fds+0x70>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <FD_ISSET@plt>
mov    %rax,%rcx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%rcx
cmovne %eax,%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <dump_fds+0x2b>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_fds>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1188 <dump_fds+0x58>
mov    %rsi,%r15
test   %rsi,%rsi
je     1188 <dump_fds+0x58>
mov    %edi,%ebp
lea    0xeb4(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %ebx,%edi
mov    %r15,%rsi
call   1040 <FD_ISSET@plt>
xor    %esi,%esi
test   %rax,%rax
setne  %sil
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1150 <dump_fds+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @dump_fds(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %29
8: ; preds = %2
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %29
11: ; preds = %8
store i32 0, i32* %5
br label %12
12: ; preds = %24, %11
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i32, i32* %5
%18 = load i32*, i32** %4
%19 = call i64 @FD_ISSET(i32 %17, i32* %18)
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 1, i32 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %12
27: ; preds = %12
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %8, %2
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @dump_fds(i32 %0, i32* %1) {
%3 = icmp ne i32* %1, null
%4 = icmp sgt i32 %0, 0
%5 = and i1 %4, %3
br i1 %5, label %6, label %16
6: ; preds = %2, %6
%7 = phi i32 [ %12, %6 ], [ 0, %2 ]
%8 = tail call i64 @FD_ISSET(i32 %7, i32* %1)
%9 = icmp ne i64 %8, 0
%10 = zext i1 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = add nuw nsw i32 %7, 1
%13 = icmp eq i32 %12, %0
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = tail call i32 @putchar(i32 10)
br label %16
16: ; preds = %14, %2
ret void
}