#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 */

/* Variables and functions */
int /*<<< orphan*/ close(int);
void close_all_fd(int fd) {
  int i;
  for (i = 0; i <= 16; i++) {
    if (i != fd)
      close(i);
  }
}


x86 assembly (clang, -O0):
<close_all_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x10,-0x8(%rbp)
jg     1153 <close_all_fd+0x43>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     1140 <close_all_fd+0x30>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
jmp    1145 <close_all_fd+0x35>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <close_all_fd+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_all_fd>:
push   %rbx
test   %edi,%edi
je     124a <close_all_fd+0x13a>
mov    %edi,%ebx
xor    %edi,%edi
call   1030 <close@plt>
cmp    $0x1,%ebx
je     1254 <close_all_fd+0x144>
mov    $0x1,%edi
call   1030 <close@plt>
cmp    $0x2,%ebx
je     125e <close_all_fd+0x14e>
mov    $0x2,%edi
call   1030 <close@plt>
cmp    $0x3,%ebx
je     1268 <close_all_fd+0x158>
mov    $0x3,%edi
call   1030 <close@plt>
cmp    $0x4,%ebx
je     1272 <close_all_fd+0x162>
mov    $0x4,%edi
call   1030 <close@plt>
cmp    $0x5,%ebx
je     127c <close_all_fd+0x16c>
mov    $0x5,%edi
call   1030 <close@plt>
cmp    $0x6,%ebx
je     1286 <close_all_fd+0x176>
mov    $0x6,%edi
call   1030 <close@plt>
cmp    $0x7,%ebx
je     1290 <close_all_fd+0x180>
mov    $0x7,%edi
call   1030 <close@plt>
cmp    $0x8,%ebx
je     129a <close_all_fd+0x18a>
mov    $0x8,%edi
call   1030 <close@plt>
cmp    $0x9,%ebx
je     12a4 <close_all_fd+0x194>
mov    $0x9,%edi
call   1030 <close@plt>
cmp    $0xa,%ebx
je     12ae <close_all_fd+0x19e>
mov    $0xa,%edi
call   1030 <close@plt>
cmp    $0xb,%ebx
je     12b8 <close_all_fd+0x1a8>
mov    $0xb,%edi
call   1030 <close@plt>
cmp    $0xc,%ebx
je     12c2 <close_all_fd+0x1b2>
mov    $0xc,%edi
call   1030 <close@plt>
cmp    $0xd,%ebx
je     12cc <close_all_fd+0x1bc>
mov    $0xd,%edi
call   1030 <close@plt>
cmp    $0xe,%ebx
je     12d6 <close_all_fd+0x1c6>
mov    $0xe,%edi
call   1030 <close@plt>
cmp    $0xf,%ebx
je     12e0 <close_all_fd+0x1d0>
mov    $0xf,%edi
call   1030 <close@plt>
cmp    $0x10,%ebx
jne    12e0 <close_all_fd+0x1d0>
pop    %rbx
ret
mov    $0x1,%edi
call   1030 <close@plt>
mov    $0x2,%edi
call   1030 <close@plt>
mov    $0x3,%edi
call   1030 <close@plt>
mov    $0x4,%edi
call   1030 <close@plt>
mov    $0x5,%edi
call   1030 <close@plt>
mov    $0x6,%edi
call   1030 <close@plt>
mov    $0x7,%edi
call   1030 <close@plt>
mov    $0x8,%edi
call   1030 <close@plt>
mov    $0x9,%edi
call   1030 <close@plt>
mov    $0xa,%edi
call   1030 <close@plt>
mov    $0xb,%edi
call   1030 <close@plt>
mov    $0xc,%edi
call   1030 <close@plt>
mov    $0xd,%edi
call   1030 <close@plt>
mov    $0xe,%edi
call   1030 <close@plt>
mov    $0xf,%edi
call   1030 <close@plt>
mov    $0x10,%edi
pop    %rbx
jmp    1030 <close@plt>

LLVM IR (-O0):
define void @close_all_fd(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %15, %1
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 16
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* %3
%13 = call i32 @close(i32 %12)
br label %14
14: ; preds = %11, %7
br label %15
15: ; preds = %14
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %4
18: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @close_all_fd(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @close(i32 1)
br label %11
5: ; preds = %1
%6 = tail call i32 @close(i32 0)
%7 = icmp eq i32 %0, 1
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @close(i32 1)
%10 = icmp eq i32 %0, 2
br i1 %10, label %16, label %13
11: ; preds = %3, %5
%12 = tail call i32 @close(i32 2)
br label %16
13: ; preds = %8
%14 = tail call i32 @close(i32 2)
%15 = icmp eq i32 %0, 3
br i1 %15, label %21, label %18
16: ; preds = %11, %8
%17 = tail call i32 @close(i32 3)
br label %21
18: ; preds = %13
%19 = tail call i32 @close(i32 3)
%20 = icmp eq i32 %0, 4
br i1 %20, label %26, label %23
21: ; preds = %16, %13
%22 = tail call i32 @close(i32 4)
br label %26
23: ; preds = %18
%24 = tail call i32 @close(i32 4)
%25 = icmp eq i32 %0, 5
br i1 %25, label %31, label %28
26: ; preds = %21, %18
%27 = tail call i32 @close(i32 5)
br label %31
28: ; preds = %23
%29 = tail call i32 @close(i32 5)
%30 = icmp eq i32 %0, 6
br i1 %30, label %36, label %33
31: ; preds = %26, %23
%32 = tail call i32 @close(i32 6)
br label %36
33: ; preds = %28
%34 = tail call i32 @close(i32 6)
%35 = icmp eq i32 %0, 7
br i1 %35, label %41, label %38
36: ; preds = %31, %28
%37 = tail call i32 @close(i32 7)
br label %41
38: ; preds = %33
%39 = tail call i32 @close(i32 7)
%40 = icmp eq i32 %0, 8
br i1 %40, label %46, label %43
41: ; preds = %36, %33
%42 = tail call i32 @close(i32 8)
br label %46
43: ; preds = %38
%44 = tail call i32 @close(i32 8)
%45 = icmp eq i32 %0, 9
br i1 %45, label %51, label %48
46: ; preds = %41, %38
%47 = tail call i32 @close(i32 9)
br label %51
48: ; preds = %43
%49 = tail call i32 @close(i32 9)
%50 = icmp eq i32 %0, 10
br i1 %50, label %56, label %53
51: ; preds = %46, %43
%52 = tail call i32 @close(i32 10)
br label %56
53: ; preds = %48
%54 = tail call i32 @close(i32 10)
%55 = icmp eq i32 %0, 11
br i1 %55, label %61, label %58
56: ; preds = %51, %48
%57 = tail call i32 @close(i32 11)
br label %61
58: ; preds = %53
%59 = tail call i32 @close(i32 11)
%60 = icmp eq i32 %0, 12
br i1 %60, label %66, label %63
61: ; preds = %56, %53
%62 = tail call i32 @close(i32 12)
br label %66
63: ; preds = %58
%64 = tail call i32 @close(i32 12)
%65 = icmp eq i32 %0, 13
br i1 %65, label %71, label %68
66: ; preds = %61, %58
%67 = tail call i32 @close(i32 13)
br label %71
68: ; preds = %63
%69 = tail call i32 @close(i32 13)
%70 = icmp eq i32 %0, 14
br i1 %70, label %76, label %73
71: ; preds = %66, %63
%72 = tail call i32 @close(i32 14)
br label %76
73: ; preds = %68
%74 = tail call i32 @close(i32 14)
%75 = icmp eq i32 %0, 15
br i1 %75, label %81, label %78
76: ; preds = %71, %68
%77 = tail call i32 @close(i32 15)
br label %81
78: ; preds = %73
%79 = tail call i32 @close(i32 15)
%80 = icmp eq i32 %0, 16
br i1 %80, label %83, label %81
81: ; preds = %73, %76, %78
%82 = tail call i32 @close(i32 16)
br label %83
83: ; preds = %81, %78
ret void
}