#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*/ CloseFileIfNeeded(void *, int /*<<< orphan*/ *, int *, int *,
                                     int, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
void CloseDeftemplateFiles(void *theEnv, FILE *moduleFile, FILE *templateFile,
                           FILE *slotFile, int maxIndices) {
  int count = maxIndices;
  int arrayVersion = 0;
  if (slotFile != NULL) {
    count = maxIndices;
    CloseFileIfNeeded(theEnv, slotFile, &count, &arrayVersion, maxIndices, NULL,
                      NULL);
  }
  if (templateFile != NULL) {
    count = maxIndices;
    CloseFileIfNeeded(theEnv, templateFile, &count, &arrayVersion, maxIndices,
                      NULL, NULL);
  }
  if (moduleFile != NULL) {
    count = maxIndices;
    CloseFileIfNeeded(theEnv, moduleFile, &count, &arrayVersion, maxIndices,
                      NULL, NULL);
  }
}


x86 assembly (clang, -O0):
<CloseDeftemplateFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1170 <CloseDeftemplateFiles+0x60>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%r8d
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r9d
movq   $0x0,(%rsp)
call   1030 <CloseFileIfNeeded@plt>
cmpq   $0x0,-0x18(%rbp)
je     11a7 <CloseDeftemplateFiles+0x97>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%r8d
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r9d
movq   $0x0,(%rsp)
call   1030 <CloseFileIfNeeded@plt>
cmpq   $0x0,-0x10(%rbp)
je     11de <CloseDeftemplateFiles+0xce>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%r8d
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r9d
movq   $0x0,(%rsp)
call   1030 <CloseFileIfNeeded@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CloseDeftemplateFiles>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%ebx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
movl   $0x0,0x14(%rsp)
test   %rcx,%rcx
je     115e <CloseDeftemplateFiles+0x4e>
mov    %ebx,0x10(%rsp)
movq   $0x0,(%rsp)
lea    0x10(%rsp),%rdx
lea    0x14(%rsp),%rax
mov    %r15,%rdi
mov    %rcx,%rsi
mov    %rax,%rcx
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1030 <CloseFileIfNeeded@plt>
test   %r12,%r12
je     118a <CloseDeftemplateFiles+0x7a>
mov    %ebx,0x10(%rsp)
movq   $0x0,(%rsp)
lea    0x10(%rsp),%rdx
lea    0x14(%rsp),%rcx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1030 <CloseFileIfNeeded@plt>
test   %r14,%r14
je     11b6 <CloseDeftemplateFiles+0xa6>
mov    %ebx,0x10(%rsp)
movq   $0x0,(%rsp)
lea    0x10(%rsp),%rdx
lea    0x14(%rsp),%rcx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1030 <CloseFileIfNeeded@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @CloseDeftemplateFiles(i8* %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %6 to i8*
%9 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%10 = icmp eq i32* %3, null
br i1 %10, label %13, label %11
11: ; preds = %5
store i32 %4, i32* %6
%12 = call i32 @CloseFileIfNeeded(i8* %0, i32* %3, i32* %6, i32* %7, i32 %4, i32* null, i32* null)
br label %13
13: ; preds = %11, %5
%14 = icmp eq i32* %2, null
br i1 %14, label %17, label %15
15: ; preds = %13
store i32 %4, i32* %6
%16 = call i32 @CloseFileIfNeeded(i8* %0, i32* %2, i32* %6, i32* %7, i32 %4, i32* null, i32* null)
br label %17
17: ; preds = %15, %13
%18 = icmp eq i32* %1, null
br i1 %18, label %21, label %19
19: ; preds = %17
store i32 %4, i32* %6
%20 = call i32 @CloseFileIfNeeded(i8* %0, i32* %1, i32* %6, i32* %7, i32 %4, i32* null, i32* null)
br label %21
21: ; preds = %19, %17
ret void
}