// File: /workspace/github_c_makefile_star2_O2/Cyan4973[P]FiniteStateEntropy/programs/bench.c
// Function: BMK_benchCore_Files
int BMK_benchCore_Files(const char** fileNamesTable, int nbFiles)
{
    int fileIdx=0;

    U64 totals = 0;
    U64 totalz = 0;
    double totalc = 0.;
    double totald = 0.;

    // Loop for each file
    while (fileIdx<nbFiles) {
        FILE*  inFile;
        const char* inFileName;
        U64    inFileSize;
        size_t benchedSize;
        int nbChunks;
        size_t maxCompressedChunkSize;
        size_t readSize;
        char* orig_buff;
        char* compressedBuffer; size_t compressedBuffSize;

        /* Check file existence */
        inFileName = fileNamesTable[fileIdx++];
        inFile = fopen( inFileName, "rb" );
        if (inFile==NULL) { DISPLAY( "Pb opening %s\n", inFileName); return 11; }

        /* Memory allocation & restrictions */
        inFileSize = BMK_GetFileSize(inFileName);
        if (inFileSize==0) { DISPLAY( "%s is empty\n", inFileName); return 11; }
        benchedSize = 256 MB;
        if ((U64)benchedSize > inFileSize) benchedSize = (size_t)inFileSize;
        else DISPLAY("FSE Core Loop speed evaluation, testing %i KB ...\n", (int)(benchedSize>>10));

        /* Alloc */
        orig_buff = (char*)malloc(benchedSize);
        nbChunks = 1;
        maxCompressedChunkSize = FSE_compressBound((int)benchedSize);
        compressedBuffSize = nbChunks * maxCompressedChunkSize;
        compressedBuffer = (char*)malloc(compressedBuffSize);

        if (!orig_buff || !compressedBuffer) {
            DISPLAY("\nError: not enough memory!\n");
            free(orig_buff);
            free(compressedBuffer);
            fclose(inFile);
            return 12;
        }

        /* Fill input buffer */
        DISPLAY("Loading %s...       \r", inFileName);
        readSize = fread(orig_buff, 1, benchedSize, inFile);
        fclose(inFile);

        if (readSize != benchedSize) {
            DISPLAY("\nError: problem reading file '%s' (%i read, should be %i) !!    \n", inFileName, (int)readSize, (int)benchedSize);
            free(orig_buff);
            free(compressedBuffer);
            return 13;
        }

        /* Bench */
        BMK_benchCore_Mem(compressedBuffer, orig_buff, (int)benchedSize, 255, BMK_tableLog, inFileName, &totalz, &totalc, &totald);
        totals += benchedSize;

        free(orig_buff);
        free(compressedBuffer);
    }

    if (nbFiles > 1)
        DISPLAY("%-16.16s :%10llu ->%10llu (%5.2f%%), %6.1f MB/s , %6.1f MB/s\n", "  TOTAL", (long long unsigned int)totals, (long long unsigned int)totalz, (double)totalz/(double)totals*100., (double)totals/totalc/1000., (double)totals/totald/1000.);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6d8, %rsp            # imm = 0x6D8
movq %rdi, 0xb8(%rsp)
testl %esi, %esi
movl $0x0, %r14d
movl %esi, 0x6c(%rsp)
cmovgl %esi, %r14d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
movsd %xmm0, 0x38(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r15d, %r15d
movq %r14, 0xb0(%rsp)
cmpq %r14, %r12
je 0x2a80
movq %r15, 0x20(%rsp)
movq 0xb8(%rsp), %rax
movq (%rax,%r12,8), %r13
movq %r13, %rdi
leaq 0xcf47(%rip), %rsi      # 0xf3d4
callq 0x1120
testq %rax, %rax
je 0x2a9d
movq %rax, %r15
movq %r13, %rdi
callq 0x23ea
testq %rax, %rax
je 0x2b4b
movq %rax, %rbx
movq %r13, 0x10(%rsp)
cmpq $0x10000000, %rax       # imm = 0x10000000
jb 0x24e1
movq 0x13b32(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xd029(%rip), %rsi      # 0xf4f9
movl $0x40000, %edx          # imm = 0x40000
xorl %eax, %eax
callq 0x1110
movl $0x10000000, %ebx       # imm = 0x10000000
movq %rbx, %rdi
callq 0x1150
movq %rax, %r13
movq %rbx, %rdi
callq 0x816f
movq %rax, %rdi
callq 0x1150
movq %rax, %r14
movq 0x13af2(%rip), %rax     # 0x15ff8
movq (%rax), %rcx
testq %r13, %r13
je 0x2b6a
testq %r14, %r14
je 0x2b6a
movq %r12, 0x18(%rsp)
movq %rcx, %rdi
leaq 0xcf24(%rip), %rsi      # 0xf44e
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
pushq $0x1
popq %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x1060
movq %rax, %r12
movq %r15, %rdi
callq 0x1080
cmpq %rbx, %r12
jne 0x2b98
movq %rbp, 0xc0(%rsp)
incq 0x18(%rsp)
movl 0x13b7a(%rip), %ebp     # 0x160e8
movl $0xff, 0xc(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x4a6a
movq %rax, 0x50(%rsp)
leaq 0x2d0(%rsp), %r15
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x6f3a
movl 0xc(%rsp), %r8d
leaq 0xd0(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x7b4f
movq %rax, %r15
movl 0xc(%rsp), %esi
movl %r15d, %edi
callq 0x7adf
movl 0xc(%rsp), %edx
movq %rax, 0x78(%rsp)
movq %rax, %rdi
movq %r12, %rsi
movl %r15d, %ecx
callq 0x7856
movl %r15d, %edi
callq 0x6f58
movl 0xc(%rsp), %edx
movq %rax, 0x70(%rsp)
movq %rax, %rdi
movq %r12, %rsi
movl %r15d, %ecx
callq 0x6f73
movq 0x139ec(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xca6f(%rip), %rsi      # 0xf085
leaq 0xce88(%rip), %rdx      # 0xf4a5
xorl %eax, %eax
callq 0x1110
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x58(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xa0(%rsp)
movsd 0xc9c5(%rip), %xmm0     # 0xf008
movapd %xmm0, 0x90(%rsp)
movapd %xmm0, 0x80(%rsp)
xorl %ecx, %ecx
xorl %edx, %edx
xorl %ebp, %ebp
pushq $0x1
popq %r12
cmpl 0x13a86(%rip), %r12d    # 0x160ec
jg 0x2941
movq %rdx, 0x60(%rsp)
movq %rcx, 0x30(%rsp)
movq 0x1397b(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xcee3(%rip), %rsi      # 0xf56a
movl %r12d, %edx
movq 0x10(%rsp), %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x1110
xorl %eax, %eax
cmpq %rax, %rbx
je 0x26a9
movb %al, (%r14,%rax)
incq %rax
jmp 0x269b
movl %r12d, 0x2c(%rsp)
callq 0x1070
movq %rax, %r15
callq 0x1070
cmpq %r15, %rax
je 0x26b6
xorl %r12d, %r12d
callq 0x1070
movq %rax, %r15
callq 0x1070
subq %r15, %rax
cmpq $0x1e847f, %rax         # imm = 0x1E847F
jg 0x2701
movq %rbx, %rdi
callq 0x816f
movq %r14, %rdi
movq %rax, %rsi
movq %r13, %rdx
movq %rbx, %rcx
movq 0x78(%rsp), %r8
callq 0x7eeb
movq %rax, %rbp
incl %r12d
jmp 0x26cb
callq 0x1070
movq %rax, 0x48(%rsp)
movq %rbp, %rdi
callq 0x67fa
testl %eax, %eax
jne 0x2a4f
movq 0x48(%rsp), %rax
subq %r15, %rax
cvtsi2sd %rax, %xmm5
cvtsi2sd %r12d, %xmm1
movapd 0x90(%rsp), %xmm4
movapd %xmm4, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm5, %xmm3
divsd %xmm1, %xmm3
cmpltsd %xmm2, %xmm5
andpd %xmm5, %xmm3
andnpd %xmm4, %xmm5
orpd %xmm3, %xmm5
movapd %xmm5, 0x90(%rsp)
movq %rbp, %xmm1
punpckldq 0xc8d3(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xc8db(%rip), %xmm1     # 0xf050
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x58(%rsp), %xmm1
divsd %xmm1, %xmm0
mulsd 0xc885(%rip), %xmm0     # 0xf018
movq 0x1385e(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
divsd %xmm5, %xmm1
divsd 0xc867(%rip), %xmm1     # 0xf010
leaq 0xc8f3(%rip), %rsi      # 0xf0a3
movl 0x2c(%rsp), %edx
movq 0x10(%rsp), %rcx
movl %ebx, %r8d
movl %ebp, %r9d
movapd %xmm0, 0xa0(%rsp)
movsd %xmm1, 0x48(%rsp)
movb $0x2, %al
callq 0x1110
xorl %eax, %eax
cmpq %rax, %rbx
je 0x27e7
movb $0x0, (%r13,%rax)
incq %rax
jmp 0x27d7
callq 0x1070
movq %rax, %r15
callq 0x1070
cmpq %r15, %rax
je 0x27ef
xorl %r12d, %r12d
callq 0x1070
movq %rax, %r15
callq 0x1070
subq %r15, %rax
cmpq $0x1e847f, %rax         # imm = 0x1E847F
jg 0x2834
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq 0x70(%rsp), %r8
callq 0x70ff
movq %rax, 0x60(%rsp)
incl %r12d
jmp 0x2804
callq 0x1070
movq %rax, 0xc8(%rsp)
movq 0x60(%rsp), %rdi
callq 0x67fa
testl %eax, %eax
jne 0x29c2
cmpq %rbx, 0x60(%rsp)
jne 0x29c2
movq 0xc8(%rsp), %rax
subq %r15, %rax
cvtsi2sd %rax, %xmm0
cvtsi2sd %r12d, %xmm1
movapd 0x80(%rsp), %xmm4
movapd %xmm4, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm0, %xmm3
divsd %xmm1, %xmm3
cmpltsd %xmm2, %xmm0
andpd %xmm0, %xmm3
andnpd %xmm4, %xmm0
orpd %xmm3, %xmm0
movapd %xmm0, 0x80(%rsp)
movq 0x1374b(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
movsd 0x58(%rsp), %xmm2
divsd %xmm0, %xmm2
divsd 0xc74e(%rip), %xmm2     # 0xf010
leaq 0xc80a(%rip), %rsi      # 0xf0d3
movl 0x2c(%rsp), %r12d
movl %r12d, %edx
movq 0x10(%rsp), %rcx
movl %ebx, %r8d
movl %ebp, %r9d
movapd 0xa0(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movb $0x3, %al
callq 0x1110
movq %r13, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x4a6a
movq %rax, %r15
incl %r12d
movq 0x50(%rsp), %rax
movq %rax, %rcx
movq %rbx, %rdx
cmpq %r15, %rax
je 0x265f
movq 0x136d8(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xccaa(%rip), %rsi      # 0xf5d4
movq 0x10(%rsp), %rdx
movq 0x50(%rsp), %rcx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x1110
movq %r15, %rcx
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r12
cmpq %rcx, 0x50(%rsp)
je 0x29d8
movq 0xc0(%rsp), %rax
addq %rbp, %rax
movq %rax, %rbp
movsd 0x40(%rsp), %xmm0
addsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x38(%rsp), %xmm0
addsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x78(%rsp), %rdi
callq 0x1030
movq 0x70(%rsp), %rdi
callq 0x1030
addq %rbx, %r15
movq %r13, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movq 0xb0(%rsp), %r14
jmp 0x2469
movq 0x1362f(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xcbd6(%rip), %rsi      # 0xf5a9
jmp 0x2a60
movsd 0xc638(%rip), %xmm0     # 0xf018
movapd 0xa0(%rsp), %xmm3
ucomisd %xmm3, %xmm0
movq 0x13604(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
movsd 0x58(%rsp), %xmm2
movapd %xmm2, %xmm1
divsd 0x90(%rsp), %xmm1
movsd 0xc5fe(%rip), %xmm0     # 0xf010
divsd %xmm0, %xmm1
divsd 0x80(%rsp), %xmm2
divsd %xmm0, %xmm2
leaq 0xc749(%rip), %rsi      # 0xf173
leaq 0xc70a(%rip), %rax      # 0xf13b
cmovaq %rax, %rsi
movq 0x10(%rsp), %rdx
movl %ebx, %ecx
movl %ebp, %r8d
movapd %xmm3, %xmm0
movb $0x3, %al
callq 0x1110
jmp 0x2956
movq 0x135a2(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xcb21(%rip), %rsi      # 0xf581
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x1110
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r12
movq 0x30(%rsp), %rcx
jmp 0x294b
xorl %ebx, %ebx
cmpl $0x2, 0x6c(%rsp)
jge 0x2ab3
movl %ebx, %eax
addq $0x6d8, %rsp            # imm = 0x6D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x13554(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xc929(%rip), %rsi      # 0xf3d7
jmp 0x2b5c
movq 0x1353e(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
movq %rbp, %xmm1
movq 0xc576(%rip), %xmm3     # 0xf040
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xc57a(%rip), %xmm2     # 0xf050
subpd %xmm2, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %r15, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
mulsd 0xc50d(%rip), %xmm0     # 0xf018
movapd %xmm2, %xmm1
divsd 0x40(%rsp), %xmm1
movsd 0xc4f3(%rip), %xmm3     # 0xf010
divsd %xmm3, %xmm1
divsd 0x38(%rsp), %xmm2
divsd %xmm3, %xmm2
leaq 0xc9fa(%rip), %rsi      # 0xf52c
leaq 0xc9ab(%rip), %rdx      # 0xf4e4
movq %r15, %rcx
movq %rbp, %r8
movb $0x3, %al
callq 0x1110
jmp 0x2a89
movq 0x134a6(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xc990(%rip), %rsi      # 0xf4ec
movq %r13, %rdx
xorl %eax, %eax
callq 0x1110
pushq $0xb
jmp 0x2bcd
leaq 0xc8c1(%rip), %rdi      # 0xf432
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
movq %r13, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1080
pushq $0xc
jmp 0x2bcd
movq 0x13459(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xc8bb(%rip), %rsi      # 0xf464
movq 0x10(%rsp), %rdx
movl %r12d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
pushq $0xd
popq %rbx
jmp 0x2a89
nop