#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*/ *);
bool empty(int *fds, fd_set *rfds, int n) {
  for (int i = 0; i < n; i++) {
    if (FD_ISSET(fds[i], rfds))
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<empty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1173 <empty+0x63>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x18(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1160 <empty+0x50>
movl   $0x0,-0x4(%rbp)
jmp    117a <empty+0x6a>
jmp    1165 <empty+0x55>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112a <empty+0x1a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<empty>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
jle    1167 <empty+0x57>
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%edi
call   1030 <FD_ISSET@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    116c <empty+0x5c>
mov    %ebp,%ebp
mov    $0x1,%ecx
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rbx
cmp    %rcx,%rbp
je     115d <empty+0x4d>
mov    (%r15,%rbx,4),%edi
mov    %r14,%rsi
call   1030 <FD_ISSET@plt>
lea    0x1(%rbx),%rcx
test   %rax,%rax
je     1140 <empty+0x30>
xor    %eax,%eax
cmp    %rbp,%rbx
setae  %al
jmp    116c <empty+0x5c>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @empty(i32* nocapture %0, i32* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %23
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = zext i32 %2 to i64
%8 = load i32, i32* %0
%9 = tail call i64 @FD_ISSET(i32 %8, i32* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %5, %14
%12 = phi i64 [ %19, %14 ], [ 1, %5 ]
%13 = icmp eq i64 %12, %7
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = getelementptr inbounds i32, i32* %0, i64 %12
%16 = load i32, i32* %15
%17 = tail call i64 @FD_ISSET(i32 %16, i32* %1)
%18 = icmp eq i64 %17, 0
%19 = add nuw nsw i64 %12, 1
br i1 %18, label %11, label %20
20: ; preds = %11, %14
%21 = icmp uge i64 %12, %6
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %20, %5, %3
%24 = phi i32 [ 1, %3 ], [ 0, %5 ], [ %22, %20 ]
ret i32 %24
}