#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*/ BMK_benchMem(void *const, size_t const);
size_t BMK_selectBenchedSize(char const *const);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *const);
int /*<<< orphan*/ *fopen(char const *const, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(void *const, int, size_t const, int /*<<< orphan*/ *const);
int /*<<< orphan*/ free(char *const);
scalar_t__ malloc(size_t const);
int /*<<< orphan*/ stderr;
int BMK_benchFiles(const char **fileNamesTable, int nbFiles) {
  int fileIdx;
  for (fileIdx = 0; fileIdx < nbFiles; fileIdx++) {
    const char *const inFileName = fileNamesTable[fileIdx];
    FILE *const inFile = fopen(inFileName, "rb");
    size_t const benchedSize = BMK_selectBenchedSize(inFileName);
    char *const buffer = (char *)malloc(benchedSize + 16);
    void *const alignedBuffer = (buffer + 15) - (((size_t)(buffer + 15)) & 0xF);
    if ((inFile == NULL) || (inFileName == NULL)) {
      fprintf(stderr, "Pb opening %s\n", inFileName);
      free(buffer);
      return 11;
    }
    if (!buffer) {
      fprintf(stderr, "\nError: not enough memory!\n");
      fclose(inFile);
      return 12;
    }
    fprintf(stderr, "\rLoading %s...        \n", inFileName);
    {
      size_t const readSize = fread(alignedBuffer, 1, benchedSize, inFile);
      fclose(inFile);
      if (readSize != benchedSize) {
        fprintf(stderr, "\nError: problem reading file '%s' !!    \n",
                inFileName);
        free(buffer);
        return 13;
      }
    }
    BMK_benchMem(alignedBuffer, benchedSize);
    free(buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<BMK_benchFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1321 <BMK_benchFiles+0x1a1>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <BMK_selectBenchedSize@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x10,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    $0xf,%rax
mov    -0x38(%rbp),%rdx
add    $0xf,%rdx
and    $0xf,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     121a <BMK_benchFiles+0x9a>
cmpq   $0x0,-0x20(%rbp)
jne    124a <BMK_benchFiles+0xca>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdd5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0xb,-0x4(%rbp)
jmp    1328 <BMK_benchFiles+0x1a8>
cmpq   $0x0,-0x38(%rbp)
jne    1281 <BMK_benchFiles+0x101>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0xc,-0x4(%rbp)
jmp    1328 <BMK_benchFiles+0x1a8>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd99(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x48(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     12fd <BMK_benchFiles+0x17d>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd65(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0xd,-0x4(%rbp)
jmp    1328 <BMK_benchFiles+0x1a8>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10a0 <BMK_benchMem@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1196 <BMK_benchFiles+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BMK_benchFiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x8(%rsp)
test   %esi,%esi
jle    1262 <BMK_benchFiles+0xe2>
mov    %esi,%eax
mov    %rax,(%rsp)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rax
mov    (%rax,%r14,8),%rbx
mov    %rbx,%rdi
lea    0xe3d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1070 <BMK_selectBenchedSize@plt>
mov    %rax,%r15
lea    0x10(%rax),%rdi
call   1080 <malloc@plt>
mov    %rax,%r12
test   %rbx,%rbx
je     1266 <BMK_benchFiles+0xe6>
test   %rbp,%rbp
je     1266 <BMK_benchFiles+0xe6>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
test   %r12,%r12
je     128f <BMK_benchFiles+0x10f>
mov    %r12,%r13
add    $0xf,%r13
and    $0xfffffffffffffff0,%r13
lea    0xe1e(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rax,0x10(%rsp)
mov    %rbp,%rdi
call   1050 <fclose@plt>
cmp    %r15,0x10(%rsp)
jne    12ac <BMK_benchFiles+0x12c>
mov    %r13,%rdi
mov    %r15,%rsi
call   10a0 <BMK_benchMem@plt>
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x1,%r14
cmp    %r14,(%rsp)
jne    11b0 <BMK_benchFiles+0x30>
xor    %eax,%eax
jmp    12d3 <BMK_benchFiles+0x153>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xd8d(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    $0xb,%eax
jmp    12d3 <BMK_benchFiles+0x153>
lea    0xd7c(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    $0xc,%eax
jmp    12d3 <BMK_benchFiles+0x153>
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
lea    0xd8a(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    $0xd,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"Pb opening %s\0A\00"
@.str.2 = [28 x i8] c"\0AError: not enough memory!\0A\00"
@.str.3 = [24 x i8] c"\0DLoading %s... \0A\00"
@.str.4 = [42 x i8] c"\0AError: problem reading file '%s' !! \0A\00"
define i32 @BMK_benchFiles(i8** %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 0, i32* %6
br label %13
13: ; preds = %83, %2
%14 = load i32, i32* %6
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %86
17: ; preds = %13
%18 = load i8**, i8*** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %8
%25 = load i8*, i8** %7
%26 = call i64 @BMK_selectBenchedSize(i8* %25)
store i64 %26, i64* %9
%27 = load i64, i64* %9
%28 = add i64 %27, 16
%29 = call i64 @malloc(i64 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %10
%31 = load i8*, i8** %10
%32 = getelementptr inbounds i8, i8* %31, i64 15
%33 = load i8*, i8** %10
%34 = getelementptr inbounds i8, i8* %33, i64 15
%35 = ptrtoint i8* %34 to i64
%36 = and i64 %35, 15
%37 = sub i64 0, %36
%38 = getelementptr inbounds i8, i8* %32, i64 %37
store i8* %38, i8** %11
%39 = load i32*, i32** %8
%40 = icmp eq i32* %39, null
br i1 %40, label %44, label %41
41: ; preds = %17
%42 = load i8*, i8** %7
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %50
44: ; preds = %41, %17
%45 = load i32, i32* @stderr
%46 = load i8*, i8** %7
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %46)
%48 = load i8*, i8** %10
%49 = call i32 @free(i8* %48)
store i32 11, i32* %3
br label %87
50: ; preds = %41
%51 = load i8*, i8** %10
%52 = icmp ne i8* %51, null
br i1 %52, label %58, label %53
53: ; preds = %50
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%56 = load i32*, i32** %8
%57 = call i32 @fclose(i32* %56)
store i32 12, i32* %3
br label %87
58: ; preds = %50
%59 = load i32, i32* @stderr
%60 = load i8*, i8** %7
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %60)
%62 = load i8*, i8** %11
%63 = load i64, i64* %9
%64 = load i32*, i32** %8
%65 = call i64 @fread(i8* %62, i32 1, i64 %63, i32* %64)
store i64 %65, i64* %12
%66 = load i32*, i32** %8
%67 = call i32 @fclose(i32* %66)
%68 = load i64, i64* %12
%69 = load i64, i64* %9
%70 = icmp ne i64 %68, %69
br i1 %70, label %71, label %77
71: ; preds = %58
%72 = load i32, i32* @stderr
%73 = load i8*, i8** %7
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %73)
%75 = load i8*, i8** %10
%76 = call i32 @free(i8* %75)
store i32 13, i32* %3
br label %87
77: ; preds = %58
%78 = load i8*, i8** %11
%79 = load i64, i64* %9
%80 = call i32 @BMK_benchMem(i8* %78, i64 %79)
%81 = load i8*, i8** %10
%82 = call i32 @free(i8* %81)
br label %83
83: ; preds = %77
%84 = load i32, i32* %6
%85 = add nsw i32 %84, 1
store i32 %85, i32* %6
br label %13
86: ; preds = %13
store i32 0, i32* %3
br label %87
87: ; preds = %86, %71, %53, %44
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"Pb opening %s\0A\00"
@.str.2 = [28 x i8] c"\0AError: not enough memory!\0A\00"
@.str.3 = [24 x i8] c"\0DLoading %s... \0A\00"
@.str.4 = [42 x i8] c"\0AError: problem reading file '%s' !! \0A\00"
define i32 @BMK_benchFiles(i8** nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %49
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %44
%7 = phi i64 [ 0, %4 ], [ %47, %44 ]
%8 = getelementptr inbounds i8*, i8** %0, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = tail call i64 @BMK_selectBenchedSize(i8* %9)
%12 = add i64 %11, 16
%13 = tail call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
%15 = getelementptr inbounds i8, i8* %14, i64 15
%16 = ptrtoint i8* %15 to i64
%17 = and i64 %16, 15
%18 = sub nsw i64 0, %17
%19 = getelementptr inbounds i8, i8* %15, i64 %18
%20 = icmp eq i32* %10, null
%21 = icmp eq i8* %9, null
%22 = or i1 %21, %20
br i1 %22, label %23, label %28
23: ; preds = %6
%24 = inttoptr i64 %13 to i8*
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%27 = tail call i32 @free(i8* %24)
br label %49
28: ; preds = %6
%29 = icmp eq i64 %13, 0
%30 = load i32, i32* @stderr
br i1 %29, label %31, label %34
31: ; preds = %28
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%33 = tail call i32 @fclose(i32* %10)
br label %49
34: ; preds = %28
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%36 = tail call i64 @fread(i8* %19, i32 1, i64 %11, i32* %10)
%37 = tail call i32 @fclose(i32* %10)
%38 = icmp eq i64 %36, %11
br i1 %38, label %44, label %39
39: ; preds = %34
%40 = inttoptr i64 %13 to i8*
%41 = load i32, i32* @stderr
%42 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%43 = tail call i32 @free(i8* %40)
br label %49
44: ; preds = %34
%45 = tail call i32 @BMK_benchMem(i8* %19, i64 %11)
%46 = tail call i32 @free(i8* %14)
%47 = add nuw nsw i64 %7, 1
%48 = icmp eq i64 %47, %5
br i1 %48, label %49, label %6
49: ; preds = %44, %2, %23, %31, %39
%50 = phi i32 [ 11, %23 ], [ 12, %31 ], [ 13, %39 ], [ 0, %2 ], [ 0, %44 ]
ret i32 %50
}