// File: /workspace/github_c_makefile_star2_O0/Cyan4973[P]FiniteStateEntropy/programs/bench.c
// Function: BMK_benchCore_Mem
static void BMK_benchCore_Mem(char* dst,
                              char* src, unsigned benchedSize,
                              unsigned nbSymbols, unsigned tableLog, const char* inFileName,
                              U64* totalCompressedSize, double* totalCompressionTime, double* totalDecompressionTime)
{
    int loopNb;
    size_t cSize=0, dSize=0;
    double fastestC = 100000000., fastestD = 100000000.;
    double ratio=0.;
    U64 crcCheck=0;
    U64 crcOrig;
    U32 count[256];
    short norm[256];
    FSE_CTable* ct;
    FSE_DTable* dt;

    /* Init */
    crcOrig = XXH64(src, benchedSize,0);
    HIST_count(count, &nbSymbols, (BYTE*)src, benchedSize);
    tableLog = (U32)FSE_normalizeCount(norm, tableLog, count, benchedSize, nbSymbols);
    ct = FSE_createCTable(tableLog, nbSymbols);
    FSE_buildCTable(ct, norm, nbSymbols, tableLog);
    dt = FSE_createDTable(tableLog);
    FSE_buildDTable(dt, norm, nbSymbols, tableLog);

    DISPLAY("\r%79s\r", "");
    for (loopNb = 1; loopNb <= nbIterations; loopNb++) {
        int nbLoops;
        clock_t clockStart, clockDuration;

        /* Compression */
        DISPLAY("%1i-%-14.14s : %9u ->\r", loopNb, inFileName, benchedSize);
        { unsigned i; for (i=0; i<benchedSize; i++) dst[i]=(char)i; }     /* warming up memory */

        nbLoops = 0;
        clockStart = clock();
        while(clock() == clockStart);
        clockStart = clock();
        while(BMK_clockSpan(clockStart) < TIMELOOP) {
            cSize = FSE_compress_usingCTable(dst, FSE_compressBound(benchedSize), src, benchedSize, ct);
            nbLoops++;
        }
        clockDuration = BMK_clockSpan(clockStart);

        if (FSE_isError(cSize)) { DISPLAY("!!! Error compressing file %s !!!!    \n", inFileName); break; }

        if ((double)clockDuration < fastestC*nbLoops) fastestC = (double)clockDuration/nbLoops;
        ratio = (double)cSize/(double)benchedSize*100.;

        DISPLAY("%1i-%-14.14s : %9i -> %9i (%5.2f%%),%7.1f MB/s\r", loopNb, inFileName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / fastestC / 1000.);

        /* Decompression */
        { unsigned i; for (i=0; i<benchedSize; i++) src[i]=0; }     /* zeroing area, for CRC checking */

        nbLoops = 0;
        clockStart = clock();
        while(clock() == clockStart);
        clockStart = clock();
        while(BMK_clockSpan(clockStart) < TIMELOOP) {
            dSize = FSE_decompress_usingDTable(src, benchedSize, dst, cSize, dt);
            nbLoops++;
        }
        clockDuration = BMK_clockSpan(clockStart);

        if (FSE_isError(dSize)) { DISPLAY("\n!!! Error decompressing file %s !!!!    \n", inFileName); break; }
        if (dSize != benchedSize) { DISPLAY("\n!!! Error decompressing file %s !!!!    \n", inFileName); break; }

        if ((double)clockDuration < fastestD*nbLoops) fastestD = (double)clockDuration/nbLoops;
        DISPLAY("%1i-%-14.14s : %9i -> %9i (%5.2f%%),%7.1f MB/s ,%7.1f MB/s\r", loopNb, inFileName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / fastestC / 1000., (double)benchedSize / fastestD / 1000.);

        /* CRC Checking */
        crcCheck = XXH64(src, benchedSize, 0);
        if (crcOrig!=crcCheck) { DISPLAY("\n!!! WARNING !!! %14s : Invalid Checksum : %x != %x\n", inFileName, (unsigned)crcOrig, (unsigned)crcCheck); break; }
    }

    if (crcOrig==crcCheck) {
        if (ratio<100.)
            DISPLAY("%-16.16s : %9i -> %9i (%5.2f%%),%7.1f MB/s ,%7.1f MB/s\n", inFileName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / fastestC / 1000., (double)benchedSize / fastestD / 1000.);
        else
            DISPLAY("%-16.16s : %9i -> %9i (%5.1f%%),%7.1f MB/s ,%7.1f MB/s \n", inFileName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / fastestC / 1000., (double)benchedSize / fastestD / 1000.);
    }
    *totalCompressedSize    += cSize;
    *totalCompressionTime   += fastestC;
    *totalDecompressionTime += fastestD;

    free(ct);
    free(dt);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6b0, %rsp            # imm = 0x6B0
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq %r9, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movsd 0x220a3(%rip), %xmm0    # 0x25008
movsd %xmm0, -0x48(%rbp)
movsd 0x22096(%rip), %xmm0    # 0x25008
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x6b60
movq %rax, -0x68(%rbp)
leaq -0x470(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq -0x18(%rbp), %rsi
callq 0xf4e0
leaq -0x670(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq -0x470(%rbp), %rdx
movl -0x14(%rbp), %eax
movl %eax, %ecx
movl -0x18(%rbp), %r8d
callq 0x118f0
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x11760
movq %rax, -0x678(%rbp)
movq -0x678(%rbp), %rdi
leaq -0x670(%rbp), %rsi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
callq 0x11220
movl -0x1c(%rbp), %edi
callq 0xf540
movq %rax, -0x680(%rbp)
movq -0x680(%rbp), %rdi
leaq -0x670(%rbp), %rsi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
callq 0xf5a0
movq 0x28fc6(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x22049(%rip), %rsi     # 0x25085
leaq 0x22462(%rip), %rdx     # 0x254a5
movb $0x0, %al
callq 0x1100
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0x2908a(%rip), %eax     # 0x2c0e4
jg 0x345d
movq 0x28f91(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movl -0x2c(%rbp), %edx
movq -0x28(%rbp), %rcx
movl -0x14(%rbp), %r8d
leaq 0x224ee(%rip), %rsi     # 0x2556a
movb $0x0, %al
callq 0x1100
movl $0x0, -0x69c(%rbp)
movl -0x69c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x30be
movl -0x69c(%rbp), %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movl -0x69c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x69c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x69c(%rbp)
jmp 0x308d
movl $0x0, -0x684(%rbp)
callq 0x1070
movq %rax, -0x690(%rbp)
callq 0x1070
cmpq -0x690(%rbp), %rax
jne 0x30e4
jmp 0x30d4
callq 0x1070
movq %rax, -0x690(%rbp)
movq -0x690(%rbp), %rdi
callq 0x19a0
cmpq $0x1e8480, %rax         # imm = 0x1E8480
jge 0x314d
movq -0x8(%rbp), %rax
movq %rax, -0x6a8(%rbp)
movl -0x14(%rbp), %eax
movl %eax, %edi
callq 0x12490
movq -0x6a8(%rbp), %rdi
movq %rax, %rsi
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %eax
movl %eax, %ecx
movq -0x678(%rbp), %r8
callq 0x12110
movq %rax, -0x38(%rbp)
movl -0x684(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x684(%rbp)
jmp 0x30f0
movq -0x690(%rbp), %rdi
callq 0x19a0
movq %rax, -0x698(%rbp)
movq -0x38(%rbp), %rdi
callq 0xe390
cmpl $0x0, %eax
je 0x318f
movq 0x28e83(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x223fe(%rip), %rsi     # 0x25581
movb $0x0, %al
callq 0x1100
jmp 0x345d
cvtsi2sdq -0x698(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
cvtsi2sdl -0x684(%rbp), %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x31c9
cvtsi2sdq -0x698(%rbp), %xmm0
cvtsi2sdl -0x684(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movaps 0x21e70(%rip), %xmm1    # 0x25040
movq -0x38(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x21e6f(%rip), %xmm1    # 0x25050
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movl -0x14(%rbp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd 0x21e14(%rip), %xmm1    # 0x25018
mulsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movq 0x28de4(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movl -0x2c(%rbp), %edx
movq -0x28(%rbp), %rcx
movl -0x14(%rbp), %eax
movl %eax, %r8d
movl -0x38(%rbp), %r9d
movsd -0x58(%rbp), %xmm0
cvtsi2sd %rax, %xmm1
divsd -0x48(%rbp), %xmm1
movsd 0x21dd1(%rip), %xmm2    # 0x25010
divsd %xmm2, %xmm1
leaq 0x21e59(%rip), %rsi     # 0x250a3
movb $0x2, %al
callq 0x1100
movl $0x0, -0x6a0(%rbp)
movl -0x6a0(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x3285
movq -0x10(%rbp), %rax
movl -0x6a0(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x6a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6a0(%rbp)
jmp 0x325b
movl $0x0, -0x684(%rbp)
callq 0x1070
movq %rax, -0x690(%rbp)
callq 0x1070
cmpq -0x690(%rbp), %rax
jne 0x32ab
jmp 0x329b
callq 0x1070
movq %rax, -0x690(%rbp)
movq -0x690(%rbp), %rdi
callq 0x19a0
cmpq $0x1e8480, %rax         # imm = 0x1E8480
jge 0x32fd
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
movq -0x8(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x680(%rbp), %r8
callq 0xfa60
movq %rax, -0x40(%rbp)
movl -0x684(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x684(%rbp)
jmp 0x32b7
movq -0x690(%rbp), %rdi
callq 0x19a0
movq %rax, -0x698(%rbp)
movq -0x40(%rbp), %rdi
callq 0xe390
cmpl $0x0, %eax
je 0x333f
movq 0x28cd3(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x22276(%rip), %rsi     # 0x255a9
movb $0x0, %al
callq 0x1100
jmp 0x345d
movq -0x40(%rbp), %rax
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
je 0x336c
movq 0x28ca6(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x22249(%rip), %rsi     # 0x255a9
movb $0x0, %al
callq 0x1100
jmp 0x345d
cvtsi2sdq -0x698(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
cvtsi2sdl -0x684(%rbp), %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x33a6
cvtsi2sdq -0x698(%rbp), %xmm0
cvtsi2sdl -0x684(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq 0x28c4b(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movl -0x2c(%rbp), %edx
movq -0x28(%rbp), %rcx
movl -0x14(%rbp), %eax
movl %eax, %r8d
movl -0x38(%rbp), %r9d
movsd -0x58(%rbp), %xmm0
cvtsi2sd %rax, %xmm2
movsd -0x48(%rbp), %xmm3
movaps %xmm2, %xmm1
divsd %xmm3, %xmm1
movsd 0x21c31(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm1
divsd -0x50(%rbp), %xmm2
movsd 0x21c20(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm2
leaq 0x21cd8(%rip), %rsi     # 0x250d3
movb $0x3, %al
callq 0x1100
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x6b60
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0x344d
movq 0x28bcf(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq -0x60(%rbp), %rax
movl %eax, %r8d
leaq 0x22190(%rip), %rsi     # 0x255d4
movb $0x0, %al
callq 0x1100
jmp 0x345d
jmp 0x344f
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3051
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x352e
movsd 0x21ba5(%rip), %xmm0    # 0x25018
ucomisd -0x58(%rbp), %xmm0
jbe 0x34d4
movq 0x28b77(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
movl -0x14(%rbp), %eax
movl %eax, %ecx
movl -0x38(%rbp), %r8d
movsd -0x58(%rbp), %xmm0
cvtsi2sd %rax, %xmm2
movsd -0x48(%rbp), %xmm3
movaps %xmm2, %xmm1
divsd %xmm3, %xmm1
movsd 0x21b61(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm1
divsd -0x50(%rbp), %xmm2
movsd 0x21b50(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm2
leaq 0x21c70(%rip), %rsi     # 0x2513b
movb $0x3, %al
callq 0x1100
jmp 0x352c
movq 0x28b1d(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
movl -0x14(%rbp), %eax
movl %eax, %ecx
movl -0x38(%rbp), %r8d
movsd -0x58(%rbp), %xmm0
cvtsi2sd %rax, %xmm2
movsd -0x48(%rbp), %xmm3
movaps %xmm2, %xmm1
divsd %xmm3, %xmm1
movsd 0x21b07(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm1
divsd -0x50(%rbp), %xmm2
movsd 0x21af6(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm2
leaq 0x21c4e(%rip), %rsi     # 0x25173
movb $0x3, %al
callq 0x1100
jmp 0x352e
movq -0x38(%rbp), %rcx
movq 0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movsd -0x48(%rbp), %xmm0
movq 0x18(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movsd -0x50(%rbp), %xmm0
movq 0x20(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq -0x678(%rbp), %rdi
callq 0x1030
movq -0x680(%rbp), %rdi
callq 0x1030
addq $0x6b0, %rsp            # imm = 0x6B0
popq %rbp
retq
nop