#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*/ assert(int);
int empty_fds(int nfds, fd_set *fds) {
  int i;
  assert(fds != NULL && nfds > 0);
  for (i = 0; i < nfds; i++)
    if (FD_ISSET(i, fds))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<empty_fds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x15(%rbp)
je     1149 <empty_fds+0x29>
cmpl   $0x0,-0x8(%rbp)
setg   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119e <empty_fds+0x7e>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     118b <empty_fds+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    11a5 <empty_fds+0x85>
jmp    1190 <empty_fds+0x70>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <empty_fds+0x3d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<empty_fds>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
test   %rsi,%rsi
setne  %al
test   %edi,%edi
setg   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
mov    $0x1,%r14d
test   %ebp,%ebp
jle    116b <empty_fds+0x4b>
xor    %ebx,%ebx
nopl   (%rax)
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
jne    1168 <empty_fds+0x48>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1150 <empty_fds+0x30>
jmp    116b <empty_fds+0x4b>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @empty_fds(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
%7 = load i32*, i32** %5
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 0
br label %12
12: ; preds = %9, %2
%13 = phi i1 [ false, %2 ], [ %11, %9 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
store i32 0, i32* %6
br label %16
16: ; preds = %27, %12
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i32, i32* %6
%22 = load i32*, i32** %5
%23 = call i64 @FD_ISSET(i32 %21, i32* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 0, i32* %3
br label %31
26: ; preds = %20
br label %27
27: ; preds = %26
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %16
30: ; preds = %16
store i32 1, i32* %3
br label %31
31: ; preds = %30, %25
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @empty_fds(i32 %0, i32* %1) {
%3 = icmp ne i32* %1, null
%4 = icmp sgt i32 %0, 0
%5 = and i1 %4, %3
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
br i1 %4, label %10, label %15
8: ; preds = %10
%9 = icmp eq i32 %14, %0
br i1 %9, label %15, label %10
10: ; preds = %2, %8
%11 = phi i32 [ %14, %8 ], [ 0, %2 ]
%12 = tail call i64 @FD_ISSET(i32 %11, i32* %1)
%13 = icmp eq i64 %12, 0
%14 = add nuw nsw i32 %11, 1
br i1 %13, label %8, label %15
15: ; preds = %10, %8, %2
%16 = phi i32 [ 1, %2 ], [ 1, %8 ], [ 0, %10 ]
ret i32 %16
}