#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 STDERR_FILENO;
int STDIN_FILENO;
int STDOUT_FILENO;
int /*<<< orphan*/ close(int);
void closeUninheritableFds(int const stdinFd, int const stdoutFd) {
  int fd;
  for (fd = 0; fd < 64; ++fd) {
    if (fd == stdinFd) {
    } else if (fd == stdoutFd) {
    } else if (fd == STDIN_FILENO) {
    } else if (fd == STDOUT_FILENO) {
    } else if (fd == STDERR_FILENO) {
    } else {
      close(fd);
    }
  }
}


x86 assembly (clang, -O0):
<closeUninheritableFds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x40,-0xc(%rbp)
jge    11c5 <closeUninheritableFds+0xb5>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    1140 <closeUninheritableFds+0x30>
jmp    11b2 <closeUninheritableFds+0xa2>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1151 <closeUninheritableFds+0x41>
jmp    11ad <closeUninheritableFds+0x9d>
mov    -0xc(%rbp),%eax
mov    0x2e75(%rip),%rcx
cmp    (%rcx),%eax
jne    1168 <closeUninheritableFds+0x58>
jmp    11a8 <closeUninheritableFds+0x98>
mov    -0xc(%rbp),%eax
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%eax
jne    117f <closeUninheritableFds+0x6f>
jmp    11a3 <closeUninheritableFds+0x93>
mov    -0xc(%rbp),%eax
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%eax
jne    1196 <closeUninheritableFds+0x86>
jmp    119e <closeUninheritableFds+0x8e>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
jmp    11a3 <closeUninheritableFds+0x93>
jmp    11a8 <closeUninheritableFds+0x98>
jmp    11ad <closeUninheritableFds+0x9d>
jmp    11b2 <closeUninheritableFds+0xa2>
jmp    11b7 <closeUninheritableFds+0xa7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1125 <closeUninheritableFds+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closeUninheritableFds>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
mov    0x2ea9(%rip),%r15
mov    (%r15),%eax
mov    0x2ebf(%rip),%r12
mov    (%r12),%ecx
mov    0x2e9c(%rip),%r13
mov    0x0(%r13),%edx
xor    %ebx,%ebx
jmp    1158 <closeUninheritableFds+0x48>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebx
cmp    $0x40,%ebx
je     1181 <closeUninheritableFds+0x71>
cmp    %ebx,%ebp
je     1150 <closeUninheritableFds+0x40>
cmp    %ebx,%r14d
je     1150 <closeUninheritableFds+0x40>
cmp    %eax,%ebx
je     1150 <closeUninheritableFds+0x40>
cmp    %ecx,%ebx
je     1150 <closeUninheritableFds+0x40>
cmp    %edx,%ebx
je     1150 <closeUninheritableFds+0x40>
mov    %ebx,%edi
call   1030 <close@plt>
mov    (%r15),%eax
mov    (%r12),%ecx
mov    0x0(%r13),%edx
jmp    1150 <closeUninheritableFds+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
define void @closeUninheritableFds(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %42, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 64
br i1 %8, label %9, label %45
9: ; preds = %6
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %9
br label %41
14: ; preds = %9
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
br label %40
19: ; preds = %14
%20 = load i32, i32* %5
%21 = load i32, i32* @STDIN_FILENO
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %19
br label %39
24: ; preds = %19
%25 = load i32, i32* %5
%26 = load i32, i32* @STDOUT_FILENO
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %24
br label %38
29: ; preds = %24
%30 = load i32, i32* %5
%31 = load i32, i32* @STDERR_FILENO
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29
br label %37
34: ; preds = %29
%35 = load i32, i32* %5
%36 = call i32 @close(i32 %35)
br label %37
37: ; preds = %34, %33
br label %38
38: ; preds = %37, %28
br label %39
39: ; preds = %38, %23
br label %40
40: ; preds = %39, %18
br label %41
41: ; preds = %40, %13
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %6
45: ; preds = %6
ret void
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
define void @closeUninheritableFds(i32 %0, i32 %1) {
%3 = load i32, i32* @STDIN_FILENO
%4 = load i32, i32* @STDOUT_FILENO
%5 = load i32, i32* @STDERR_FILENO
br label %6
6: ; preds = %2, %25
%7 = phi i32 [ %5, %2 ], [ %26, %25 ]
%8 = phi i32 [ %4, %2 ], [ %27, %25 ]
%9 = phi i32 [ %3, %2 ], [ %28, %25 ]
%10 = phi i32 [ 0, %2 ], [ %29, %25 ]
%11 = icmp eq i32 %10, %0
%12 = icmp eq i32 %10, %1
%13 = or i1 %11, %12
%14 = icmp eq i32 %10, %9
%15 = select i1 %13, i1 true, i1 %14
%16 = icmp eq i32 %10, %8
%17 = select i1 %15, i1 true, i1 %16
%18 = icmp eq i32 %10, %7
%19 = select i1 %17, i1 true, i1 %18
br i1 %19, label %25, label %20
20: ; preds = %6
%21 = tail call i32 @close(i32 %10)
%22 = load i32, i32* @STDIN_FILENO
%23 = load i32, i32* @STDOUT_FILENO
%24 = load i32, i32* @STDERR_FILENO
br label %25
25: ; preds = %6, %20
%26 = phi i32 [ %7, %6 ], [ %24, %20 ]
%27 = phi i32 [ %8, %6 ], [ %23, %20 ]
%28 = phi i32 [ %9, %6 ], [ %22, %20 ]
%29 = add nuw nsw i32 %10, 1
%30 = icmp eq i32 %29, 64
br i1 %30, label %31, label %6
31: ; preds = %25
ret void
}