#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*/ *);
int /*<<< orphan*/ close(int);
void exitClient(int fd, fd_set *readfds, int fd_array[], int *num_clients) {
  int i;
  close(fd);
  FD_CLR(fd, readfds);
  for (i = 0; i < (*num_clients) - 1; i++)
    if (fd_array[i] == fd)
      break;
  for (; i < (*num_clients) - 1; i++)
    (fd_array[i]) = (fd_array[i + 1]);
  (*num_clients)--;
}


x86 assembly (clang, -O0):
<exitClient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <FD_CLR@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1192 <exitClient+0x72>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x4(%rbp),%eax
jne    117f <exitClient+0x5f>
jmp    1192 <exitClient+0x72>
jmp    1184 <exitClient+0x64>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1152 <exitClient+0x32>
jmp    1197 <exitClient+0x77>
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d4 <exitClient+0xb4>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1197 <exitClient+0x77>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exitClient>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %edi,%ebp
call   1030 <close@plt>
mov    %ebp,%edi
mov    %r15,%rsi
call   1040 <FD_CLR@plt>
mov    (%r14),%edx
lea    -0x1(%rdx),%eax
xor    %ecx,%ecx
cmp    $0x2,%edx
jl     1170 <exitClient+0x50>
mov    %eax,%edx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %ebp,(%rbx,%rcx,4)
je     1170 <exitClient+0x50>
add    $0x1,%rcx
cmp    %rcx,%rdx
jne    1160 <exitClient+0x40>
jmp    1198 <exitClient+0x78>
cmp    %eax,%ecx
jge    1198 <exitClient+0x78>
mov    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
mov    0x4(%rbx,%rcx,4),%eax
mov    %eax,(%rbx,%rcx,4)
lea    0x1(%rcx),%rdx
mov    (%r14),%eax
add    $0xffffffff,%eax
mov    %rdx,%rcx
cmp    %edx,%eax
jg     1180 <exitClient+0x60>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @exitClient(i32 %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%10 = load i32, i32* %5
%11 = call i32 @close(i32 %10)
%12 = load i32, i32* %5
%13 = load i32*, i32** %6
%14 = call i32 @FD_CLR(i32 %12, i32* %13)
store i32 0, i32* %9
br label %15
15: ; preds = %31, %4
%16 = load i32, i32* %9
%17 = load i32*, i32** %8
%18 = load i32, i32* %17
%19 = sub nsw i32 %18, 1
%20 = icmp slt i32 %16, %19
br i1 %20, label %21, label %34
21: ; preds = %15
%22 = load i32*, i32** %7
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* %5
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %21
br label %34
30: ; preds = %21
br label %31
31: ; preds = %30
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %15
34: ; preds = %29, %15
br label %35
35: ; preds = %52, %34
%36 = load i32, i32* %9
%37 = load i32*, i32** %8
%38 = load i32, i32* %37
%39 = sub nsw i32 %38, 1
%40 = icmp slt i32 %36, %39
br i1 %40, label %41, label %55
41: ; preds = %35
%42 = load i32*, i32** %7
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %42, i64 %45
%47 = load i32, i32* %46
%48 = load i32*, i32** %7
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
store i32 %47, i32* %51
br label %52
52: ; preds = %41
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %35
55: ; preds = %35
%56 = load i32*, i32** %8
%57 = load i32, i32* %56
%58 = add nsw i32 %57, -1
store i32 %58, i32* %56
ret void
}

LLVM IR (-O2):
define void @exitClient(i32 %0, i32* %1, i32* nocapture %2, i32* nocapture %3) {
%5 = tail call i32 @close(i32 %0)
%6 = tail call i32 @FD_CLR(i32 %0, i32* %1)
%7 = load i32, i32* %3
%8 = add i32 %7, -1
%9 = icmp sgt i32 %7, 1
br i1 %9, label %10, label %22
10: ; preds = %4
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %17
%13 = phi i64 [ 0, %10 ], [ %18, %17 ]
%14 = getelementptr inbounds i32, i32* %2, i64 %13
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, %0
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %11
br i1 %19, label %37, label %12
20: ; preds = %12
%21 = trunc i64 %13 to i32
br label %22
22: ; preds = %20, %4
%23 = phi i32 [ 0, %4 ], [ %21, %20 ]
%24 = icmp slt i32 %23, %8
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = zext i32 %23 to i64
br label %27
27: ; preds = %25, %27
%28 = phi i64 [ %26, %25 ], [ %29, %27 ]
%29 = add nuw nsw i64 %28, 1
%30 = getelementptr inbounds i32, i32* %2, i64 %29
%31 = load i32, i32* %30
%32 = getelementptr inbounds i32, i32* %2, i64 %28
store i32 %31, i32* %32
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
%35 = trunc i64 %29 to i32
%36 = icmp sgt i32 %34, %35
br i1 %36, label %27, label %37
37: ; preds = %17, %27, %22
%38 = phi i32 [ %8, %22 ], [ %34, %27 ], [ %8, %17 ]
store i32 %38, i32* %3
ret void
}