#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);
int closeFileInBatch(int fileHandlerArray[], int fileHandlerArraySize) {
  int retValue = 0;
  if (fileHandlerArray != NULL && fileHandlerArraySize > 0) {
    for (int i = 0; i < fileHandlerArraySize; i++) {
      int fd = fileHandlerArray[i];
      if (fd >= 0) {
        close(fd);
        fileHandlerArray[i] = -1;
      }
    }
  }
  return retValue;
}


x86 assembly (clang, -O0):
<closeFileInBatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1195 <closeFileInBatch+0x85>
cmpl   $0x0,-0xc(%rbp)
jle    1195 <closeFileInBatch+0x85>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1190 <closeFileInBatch+0x80>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     117d <closeFileInBatch+0x6d>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    1182 <closeFileInBatch+0x72>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1142 <closeFileInBatch+0x32>
jmp    1195 <closeFileInBatch+0x85>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closeFileInBatch>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1150 <closeFileInBatch+0x40>
test   %esi,%esi
jle    1150 <closeFileInBatch+0x40>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
jmp    1139 <closeFileInBatch+0x29>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r14
je     1150 <closeFileInBatch+0x40>
mov    (%r15,%rbx,4),%edi
test   %edi,%edi
js     1130 <closeFileInBatch+0x20>
call   1030 <close@plt>
movl   $0xffffffff,(%r15,%rbx,4)
ff
jmp    1130 <closeFileInBatch+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @closeFileInBatch(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%8 = load i32*, i32** %3
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %38
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %38
13: ; preds = %10
store i32 0, i32* %6
br label %14
14: ; preds = %34, %13
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %37
18: ; preds = %14
%19 = load i32*, i32** %3
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %18
%27 = load i32, i32* %7
%28 = call i32 @close(i32 %27)
%29 = load i32*, i32** %3
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 -1, i32* %32
br label %33
33: ; preds = %26, %18
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %14
37: ; preds = %14
br label %38
38: ; preds = %37, %10, %2
%39 = load i32, i32* %5
ret i32 %39
}

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