// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2e5d
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x18(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x227aa(%rip), %rsi     # 0x253d4
callq 0x1110
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x2c62
movq 0x293b7(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x48(%rbp), %rdx
leaq 0x22788(%rip), %rsi     # 0x253d7
movb $0x0, %al
callq 0x1100
movl $0xb, -0x4(%rbp)
jmp 0x2f0d
movq -0x48(%rbp), %rdi
callq 0x2aa0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x2c9e
movq 0x2937b(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x48(%rbp), %rdx
leaq 0x22861(%rip), %rsi     # 0x254ec
movb $0x0, %al
callq 0x1100
movl $0xb, -0x4(%rbp)
jmp 0x2f0d
movq $0x10000000, -0x58(%rbp) # imm = 0x10000000
movq -0x58(%rbp), %rax
cmpq -0x50(%rbp), %rax
jbe 0x2cba
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x2cdc
movq 0x29337(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x58(%rbp), %rax
shrq $0xa, %rax
movl %eax, %edx
leaq 0x22824(%rip), %rsi     # 0x254f9
movb $0x0, %al
callq 0x1100
movq -0x58(%rbp), %rdi
callq 0x1140
movq %rax, -0x78(%rbp)
movl $0x1, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movslq %eax, %rdi
callq 0x12490
movq %rax, -0x68(%rbp)
movslq -0x5c(%rbp), %rax
imulq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x1140
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x2d2e
cmpq $0x0, -0x80(%rbp)
jne 0x2d6d
movq 0x292c3(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x226f3(%rip), %rsi     # 0x25432
movb $0x0, %al
callq 0x1100
movq -0x78(%rbp), %rdi
callq 0x1030
movq -0x80(%rbp), %rdi
callq 0x1030
movq -0x40(%rbp), %rdi
callq 0x1080
movl $0xc, -0x4(%rbp)
jmp 0x2f0d
movq 0x29284(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x48(%rbp), %rdx
leaq 0x226cc(%rip), %rsi     # 0x2544e
movb $0x0, %al
callq 0x1100
movq -0x78(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0x1, %esi
callq 0x1060
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1080
movq -0x70(%rbp), %rax
cmpq -0x58(%rbp), %rax
je 0x2dfd
movq 0x2923b(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x48(%rbp), %rdx
movq -0x70(%rbp), %rax
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %eax, %r8d
leaq 0x2268c(%rip), %rsi     # 0x25464
movb $0x0, %al
callq 0x1100
movq -0x78(%rbp), %rdi
callq 0x1030
movq -0x80(%rbp), %rdi
callq 0x1030
movl $0xd, -0x4(%rbp)
jmp 0x2f0d
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x58(%rbp), %rax
movl %eax, %edx
movl 0x292ce(%rip), %r8d     # 0x2c0e0
movq -0x48(%rbp), %r9
movl $0xff, %ecx
leaq -0x28(%rbp), %r11
leaq -0x30(%rbp), %r10
leaq -0x38(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2f20
movq -0x58(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x78(%rbp), %rdi
callq 0x1030
movq -0x80(%rbp), %rdi
callq 0x1030
jmp 0x2bf9
cmpl $0x1, -0x14(%rbp)
jle 0x2f06
movq 0x2918a(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq %r8, %xmm0
movaps 0x221bb(%rip), %xmm3    # 0x25040
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x221bf(%rip), %xmm1    # 0x25050
subpd %xmm1, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
movq %rcx, %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm1, %xmm2
movaps %xmm2, %xmm1
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd 0x22154(%rip), %xmm1    # 0x25018
mulsd %xmm1, %xmm0
movsd -0x30(%rbp), %xmm3
movaps %xmm2, %xmm1
divsd %xmm3, %xmm1
movsd 0x22134(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm1
divsd -0x38(%rbp), %xmm2
movsd 0x22123(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm2
leaq 0x22634(%rip), %rsi     # 0x2552c
leaq 0x225e5(%rip), %rdx     # 0x254e4
movb $0x3, %al
callq 0x1100
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)