#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;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void iperf_dump_fdset(FILE *fp, char *str, int nfds, fd_set *fds) {
  int fd;
  int comma;
  fprintf(fp, "%s: [", str);
  comma = 0;
  for (fd = 0; fd < nfds; ++fd) {
    if (FD_ISSET(fd, fds)) {
      if (comma) {
        fprintf(fp, ", ");
      }
      fprintf(fp, "%d", fd);
      comma = 1;
    }
  }
  fprintf(fp, "]\n");
}


x86 assembly (clang, -O0):
<iperf_dump_fdset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c8 <iperf_dump_fdset+0xa8>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     11b5 <iperf_dump_fdset+0x95>
cmpl   $0x0,-0x28(%rbp)
je     1199 <iperf_dump_fdset+0x79>
mov    -0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x28(%rbp)
jmp    11ba <iperf_dump_fdset+0x9a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115b <iperf_dump_fdset+0x3b>
mov    -0x8(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iperf_dump_fdset>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%r13d
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xeb2(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r13d,%r13d
jle    11bc <iperf_dump_fdset+0x8c>
lea    0xea8(%rip),%r15
xor    %r12d,%r12d
xor    %ebp,%ebp
jmp    118d <iperf_dump_fdset+0x5d>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%r12d
add    $0x1,%ebp
cmp    %ebp,%r13d
je     11bc <iperf_dump_fdset+0x8c>
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
je     1185 <iperf_dump_fdset+0x55>
test   %r12d,%r12d
je     1170 <iperf_dump_fdset+0x40>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xe54(%rip),%rdi
mov    %rbx,%rcx
call   1050 <fwrite@plt>
jmp    1170 <iperf_dump_fdset+0x40>
lea    0xe49(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s: [\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"]\0A\00"
define void @iperf_dump_fdset(i32* %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%11 = load i32*, i32** %5
%12 = load i8*, i8** %6
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 0, i32* %10
store i32 0, i32* %9
br label %14
14: ; preds = %34, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %37
18: ; preds = %14
%19 = load i32, i32* %9
%20 = load i32*, i32** %8
%21 = call i64 @FD_ISSET(i32 %19, i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %18
%24 = load i32, i32* %10
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32*, i32** %5
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %26, %23
%30 = load i32*, i32** %5
%31 = load i32, i32* %9
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %31)
store i32 1, i32* %10
br label %33
33: ; preds = %29, %18
br label %34
34: ; preds = %33
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %14
37: ; preds = %14
%38 = load i32*, i32** %5
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s: [\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"]\0A\00"
define void @iperf_dump_fdset(i32* nocapture %0, i8* %1, i32 %2, i32* %3) {
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %22
7: ; preds = %4, %18
%8 = phi i32 [ %19, %18 ], [ 0, %4 ]
%9 = phi i32 [ %20, %18 ], [ 0, %4 ]
%10 = tail call i64 @FD_ISSET(i32 %9, i32* %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %7
%13 = icmp eq i32 %8, 0
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %16
16: ; preds = %14, %12
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %18
18: ; preds = %7, %16
%19 = phi i32 [ 1, %16 ], [ %8, %7 ]
%20 = add nuw nsw i32 %9, 1
%21 = icmp eq i32 %20, %2
br i1 %21, label %22, label %7
22: ; preds = %18, %4
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 2, i64 1, i32* %0)
ret void
}