// File: /workspace/github_c_makefile_star2_O0/Cyan4973[P]FiniteStateEntropy/programs/bench.c
// Function: BMK_benchMem285
void BMK_benchMem285(chunkParameters_t* chunkP, int nbChunks, const char* inFileName, int benchedSize,
                  U64* totalCompressedSize, double* totalCompressionTime, double* totalDecompressionTime,
                  int memLog)
{
    int loopNb, chunkNb;
    size_t cSize=0;
    double fastestC = 100000000., fastestD = 100000000.;
    double ratio=0.;
    U32 crcCheck=0;
    U32 crcOrig;

    /* Init */
    crcOrig = XXH32(chunkP[0].origBuffer, benchedSize,0);

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

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

        nbLoops = 0;
        clockStart = clock();
        while(clock() == clockStart);
        clockStart = clock();
        while(BMK_clockSpan(clockStart) < TIMELOOP) {
            for (chunkNb=0; chunkNb<nbChunks; chunkNb++) {
                const void* rawPtr = chunkP[chunkNb].origBuffer;
                const U16* U16chunkPtr = (const U16*) rawPtr;
                chunkP[chunkNb].compressedSize = FSE_compressU16(chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].origSize, U16chunkPtr, chunkP[chunkNb].origSize/2, 0, memLog);
            }
            nbLoops++;
        }
        clockDuration = BMK_clockSpan(clockStart);

        if ((double)clockDuration < fastestC*nbLoops) fastestC = (double)clockDuration/nbLoops;
        cSize=0; for (chunkNb=0; chunkNb<nbChunks; chunkNb++) cSize += chunkP[chunkNb].compressedSize;
        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.);

        //DISPLAY("\n"); continue;   // skip decompression
        // Decompression
        //{ size_t i; for (i=0; i<benchedSize; i++) orig_buff[i]=0; }     // zeroing area, for CRC checking

        nbLoops = 0;
        clockStart = clock();
        while(clock() == clockStart);
        clockStart = clock();
        while(BMK_clockSpan(clockStart) < TIMELOOP) {
            for (chunkNb=0; chunkNb<nbChunks; chunkNb++) {
                void* rawPtr = chunkP[chunkNb].destBuffer;
                U16* U16dstPtr = (U16*)rawPtr;
                chunkP[chunkNb].compressedSize = FSE_decompressU16(U16dstPtr, chunkP[chunkNb].origSize/2, chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].compressedSize);
            }
            nbLoops++;
        }
        clockDuration = BMK_clockSpan(clockStart);

        if ((double)clockDuration < fastestC*nbLoops) fastestC = (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 = XXH32(chunkP[0].destBuffer, benchedSize,0);
        if (crcOrig!=crcCheck) {
            const char* src = chunkP[0].origBuffer;
            const char* fin = chunkP[0].destBuffer;
            const char* const srcStart = src;
            while (*src==*fin) src++, fin++;
            DISPLAY("\n!!! %14s : Invalid Checksum !!! pos %i/%i\n", inFileName, (int)(src-srcStart), benchedSize);
            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;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movsd 0x23c80(%rip), %xmm0    # 0x25008
movsd %xmm0, -0x48(%rbp)
movsd 0x23c73(%rip), %xmm0    # 0x25008
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movslq -0x1c(%rbp), %rsi
xorl %edx, %edx
callq 0x5e60
movl %eax, -0x60(%rbp)
movq 0x2ac32(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
leaq 0x23cb5(%rip), %rsi     # 0x25085
leaq 0x240ce(%rip), %rdx     # 0x254a5
movb $0x0, %al
callq 0x1100
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x2acf6(%rip), %eax     # 0x2c0e4
jg 0x1891
movq 0x2abfd(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rcx
movl -0x1c(%rbp), %r8d
leaq 0x23c7c(%rip), %rsi     # 0x2508c
movb $0x0, %al
callq 0x1100
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1445
movl -0x7c(%rbp), %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x7c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x141e
movl $0x0, -0x64(%rbp)
callq 0x1070
movq %rax, -0x70(%rbp)
callq 0x1070
cmpq -0x70(%rbp), %rax
jne 0x1462
jmp 0x1455
callq 0x1070
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x19a0
cmpq $0x1e8480, %rax         # imm = 0x1E8480
jge 0x153c
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x152e
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
movq -0x90(%rbp), %rdx
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
shrq %rcx
movl 0x18(%rbp), %r9d
xorl %r8d, %r8d
callq 0x13ee0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x20(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1487
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x146b
movq -0x70(%rbp), %rdi
callq 0x19a0
movq %rax, -0x78(%rbp)
cvtsi2sdq -0x78(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
cvtsi2sdl -0x64(%rbp), %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1577
cvtsi2sdq -0x78(%rbp), %xmm0
cvtsi2sdl -0x64(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x15b4
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1586
movaps 0x23a85(%rip), %xmm1    # 0x25040
movq -0x40(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x23a84(%rip), %xmm1    # 0x25050
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x23a2c(%rip), %xmm1    # 0x25018
mulsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movq 0x2a9fc(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rcx
movl -0x1c(%rbp), %r8d
movq -0x40(%rbp), %rax
movl %eax, %r9d
movsd -0x58(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd -0x48(%rbp), %xmm1
movsd 0x239e8(%rip), %xmm2    # 0x25010
divsd %xmm2, %xmm1
leaq 0x23a70(%rip), %rsi     # 0x250a3
movb $0x2, %al
callq 0x1100
movl $0x0, -0x64(%rbp)
callq 0x1070
movq %rax, -0x70(%rbp)
callq 0x1070
cmpq -0x70(%rbp), %rax
jne 0x1657
jmp 0x164a
callq 0x1070
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x19a0
cmpq $0x1e8480, %rax         # imm = 0x1E8480
jge 0x172a
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x171c
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
shrq %rsi
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdx
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rcx
callq 0x147b0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x20(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x167c
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x1660
movq -0x70(%rbp), %rdi
callq 0x19a0
movq %rax, -0x78(%rbp)
cvtsi2sdq -0x78(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
cvtsi2sdl -0x64(%rbp), %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1765
cvtsi2sdq -0x78(%rbp), %xmm0
cvtsi2sdl -0x64(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movq 0x2a88c(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rcx
movl -0x1c(%rbp), %r8d
movq -0x40(%rbp), %rax
movl %eax, %r9d
movsd -0x58(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd -0x48(%rbp), %xmm1
movsd 0x23878(%rip), %xmm2    # 0x25010
divsd %xmm2, %xmm1
cvtsi2sdl -0x1c(%rbp), %xmm2
divsd -0x50(%rbp), %xmm2
movsd 0x23862(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm2
leaq 0x2391a(%rip), %rsi     # 0x250d3
movb $0x3, %al
callq 0x1100
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
movslq -0x1c(%rbp), %rsi
xorl %edx, %edx
callq 0x5e60
movl %eax, -0x5c(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x5c(%rbp), %eax
je 0x1881
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xa8(%rbp), %rax
movsbl (%rax), %eax
movq -0xb0(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x184c
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x180e
movq 0x2a7a5(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
movq -0xa8(%rbp), %rax
movq -0xb8(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movl -0x1c(%rbp), %r8d
leaq 0x23897(%rip), %rsi     # 0x2510f
movb $0x0, %al
callq 0x1100
jmp 0x1891
jmp 0x1883
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x13e5
movl -0x60(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jne 0x195e
movsd 0x23773(%rip), %xmm0    # 0x25018
ucomisd -0x58(%rbp), %xmm0
jbe 0x1905
movq 0x2a745(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %eax, %r8d
movsd -0x58(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd -0x48(%rbp), %xmm1
movsd 0x23735(%rip), %xmm2    # 0x25010
divsd %xmm2, %xmm1
cvtsi2sdl -0x1c(%rbp), %xmm2
divsd -0x50(%rbp), %xmm2
movsd 0x2371f(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm2
leaq 0x2383f(%rip), %rsi     # 0x2513b
movb $0x3, %al
callq 0x1100
jmp 0x195c
movq 0x2a6ec(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %eax, %r8d
movsd -0x58(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd -0x48(%rbp), %xmm1
movsd 0x236dc(%rip), %xmm2    # 0x25010
divsd %xmm2, %xmm1
cvtsi2sdl -0x1c(%rbp), %xmm2
divsd -0x50(%rbp), %xmm2
movsd 0x236c6(%rip), %xmm3    # 0x25010
divsd %xmm3, %xmm2
leaq 0x2381e(%rip), %rsi     # 0x25173
movb $0x3, %al
callq 0x1100
jmp 0x195e
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movsd -0x48(%rbp), %xmm0
movq -0x30(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movsd -0x50(%rbp), %xmm0
movq 0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)