#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*/ XSUM_benchMem(void *const, size_t const);
int /*<<< orphan*/ *XSUM_fopen(char const *const, char *);
int /*<<< orphan*/ XSUM_log(char *, ...);
size_t XSUM_selectBenchedSize(char const *const);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
scalar_t__ calloc(size_t const, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *const);
size_t fread(void *const, int, size_t const, int /*<<< orphan*/ *const);
int /*<<< orphan*/ free(char *const);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int XSUM_benchFiles(char *const *fileNamesTable, int nbFiles) {
  int fileIdx;
  for (fileIdx = 0; fileIdx < nbFiles; fileIdx++) {
    const char *const inFileName = fileNamesTable[fileIdx];
    assert(inFileName != NULL);
    {
      FILE *const inFile = XSUM_fopen(inFileName, "rb");
      size_t const benchedSize = XSUM_selectBenchedSize(inFileName);
      char *const buffer = (char *)calloc(benchedSize + 16 + 3, 1);
      void *const alignedBuffer =
          (buffer + 15) - (((size_t)(buffer + 15)) & 0xF);
      if (inFile == NULL) {
        XSUM_log("Error: Could not open '%s': %s.\n", inFileName,
                 strerror(errno));
        free(buffer);
        exit(11);
      }
      if (!buffer) {
        XSUM_log("\nError: Out of memory.\n");
        fclose(inFile);
        exit(12);
      }
      {
        size_t const readSize = fread(alignedBuffer, 1, benchedSize, inFile);
        fclose(inFile);
        if (readSize != benchedSize) {
          XSUM_log("\nError: Could not read '%s': %s.\n", inFileName,
                   strerror(errno));
          free(buffer);
          exit(13);
        }
      }
      XSUM_benchMem(alignedBuffer, benchedSize);
      free(buffer);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<XSUM_benchFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1355 <XSUM_benchFiles+0x1a5>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x18(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1070 <XSUM_fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <XSUM_selectBenchedSize@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x10,%rdi
add    $0x3,%rdi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0xf,%rax
mov    -0x30(%rbp),%rdx
add    $0xf,%rdx
and    $0xf,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1297 <XSUM_benchFiles+0xe7>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   10b0 <XSUM_log@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    $0xb,%edi
call   10c0 <exit@plt>
cmpq   $0x0,-0x30(%rbp)
jne    12c3 <XSUM_benchFiles+0x113>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   10b0 <XSUM_log@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    $0xc,%edi
call   10c0 <exit@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x40(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1331 <XSUM_benchFiles+0x181>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   10b0 <XSUM_log@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    $0xd,%edi
call   10c0 <exit@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10a0 <XSUM_benchMem@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c6 <XSUM_benchFiles+0x16>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XSUM_benchFiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
sub    $0x20,%rsp
mov    %rdi,0x18(%rsp)
test   %esi,%esi
jle    128e <XSUM_benchFiles+0xde>
mov    %esi,%eax
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x18(%rsp),%rax
mov    (%rax,%r12,8),%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1090 <assert@plt>
mov    %r14,%rdi
lea    0xdff(%rip),%rsi
call   1070 <XSUM_fopen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <XSUM_selectBenchedSize@plt>
mov    %rax,%rbp
lea    0x13(%rax),%rdi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r13
test   %r15,%r15
je     129e <XSUM_benchFiles+0xee>
mov    %r14,0x8(%rsp)
test   %r13,%r13
je     12d1 <XSUM_benchFiles+0x121>
mov    %r13,(%rsp)
add    $0xf,%r13
and    $0xfffffffffffffff0,%r13
mov    %r13,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %r15,%rcx
call   1050 <fread@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1060 <fclose@plt>
cmp    %rbp,%r14
jne    12f1 <XSUM_benchFiles+0x141>
mov    %r13,%rdi
mov    %rbp,%rsi
call   10a0 <XSUM_benchMem@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
add    $0x1,%r12
cmp    %r12,0x10(%rsp)
jne    11e0 <XSUM_benchFiles+0x30>
xor    %eax,%eax
add    $0x20,%rsp
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd50(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <XSUM_log@plt>
mov    %r13,%rdi
call   1040 <free@plt>
mov    $0xb,%edi
call   10c0 <exit@plt>
lea    0xd4c(%rip),%rdi
xor    %eax,%eax
call   10b0 <XSUM_log@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    $0xc,%edi
call   10c0 <exit@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd36(%rip),%rdi
mov    0x8(%rsp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <XSUM_log@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    $0xd,%edi
call   10c0 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [33 x i8] c"Error: Could not open '%s': %s.\0A\00"
@errno = global i32 0
@.str.2 = [24 x i8] c"\0AError: Out of memory.\0A\00"
@.str.3 = [34 x i8] c"\0AError: Could not read '%s': %s.\0A\00"
define i32 @XSUM_benchFiles(i8** nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %53
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %48
%7 = phi i64 [ 0, %4 ], [ %51, %48 ]
%8 = getelementptr inbounds i8*, i8** %0, i64 %7
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32* @XSUM_fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = tail call i64 @XSUM_selectBenchedSize(i8* %9)
%15 = add i64 %14, 19
%16 = tail call i64 @calloc(i64 %15, i32 1)
%17 = inttoptr i64 %16 to i8*
%18 = getelementptr inbounds i8, i8* %17, i64 15
%19 = ptrtoint i8* %18 to i64
%20 = and i64 %19, 15
%21 = sub nsw i64 0, %20
%22 = getelementptr inbounds i8, i8* %18, i64 %21
%23 = icmp eq i32* %13, null
br i1 %23, label %24, label %31
24: ; preds = %6
%25 = inttoptr i64 %16 to i8*
%26 = load i32, i32* @errno
%27 = tail call i32 @strerror(i32 %26)
%28 = tail call i32 (i8*, ...) @XSUM_log(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 %27)
%29 = tail call i32 @free(i8* %25)
%30 = tail call i32 @exit(i32 11)
unreachable
31: ; preds = %6
%32 = icmp eq i64 %16, 0
br i1 %32, label %33, label %37
33: ; preds = %31
%34 = tail call i32 (i8*, ...) @XSUM_log(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%35 = tail call i32 @fclose(i32* %13)
%36 = tail call i32 @exit(i32 12)
unreachable
37: ; preds = %31
%38 = tail call i64 @fread(i8* %22, i32 1, i64 %14, i32* %13)
%39 = tail call i32 @fclose(i32* %13)
%40 = icmp eq i64 %38, %14
br i1 %40, label %48, label %41
41: ; preds = %37
%42 = inttoptr i64 %16 to i8*
%43 = load i32, i32* @errno
%44 = tail call i32 @strerror(i32 %43)
%45 = tail call i32 (i8*, ...) @XSUM_log(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %44)
%46 = tail call i32 @free(i8* %42)
%47 = tail call i32 @exit(i32 13)
unreachable
48: ; preds = %37
%49 = tail call i32 @XSUM_benchMem(i8* %22, i64 %14)
%50 = tail call i32 @free(i8* %17)
%51 = add nuw nsw i64 %7, 1
%52 = icmp eq i64 %51, %5
br i1 %52, label %53, label %6
53: ; preds = %48, %2
ret i32 0
}