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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
void close_files(FILE **objfiles, int n) {
  for (--n; n >= 0; --n) {
    if (objfiles[n])
      fclose(objfiles[n]);
  }
}


x86 assembly (clang, -O0):
<close_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1169 <close_files+0x59>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1156 <close_files+0x46>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <fclose@plt>
jmp    115b <close_files+0x4b>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <close_files+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_files>:
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    114d <close_files+0x3d>
mov    %rdi,%r14
mov    %esi,%ebx
add    $0x1,%rbx
jmp    113a <close_files+0x2a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
jbe    114d <close_files+0x3d>
lea    -0x2(%rbx),%eax
mov    (%r14,%rax,8),%rdi
test   %rdi,%rdi
je     1130 <close_files+0x20>
call   1030 <fclose@plt>
jmp    1130 <close_files+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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