// File: /workspace/github_c_makefile_star2_O0/Cyan4973[P]FiniteStateEntropy/programs/../lib/fse_compress.c
// Function: FSE_compress_wksp
size_t FSE_compress_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize)
{
    BYTE* const ostart = (BYTE*) dst;
    BYTE* op = ostart;
    BYTE* const oend = ostart + dstSize;

    unsigned count[FSE_MAX_SYMBOL_VALUE+1];
    S16   norm[FSE_MAX_SYMBOL_VALUE+1];
    FSE_CTable* CTable = (FSE_CTable*)workSpace;
    size_t const CTableSize = FSE_CTABLE_SIZE_U32(tableLog, maxSymbolValue);
    void* scratchBuffer = (void*)(CTable + CTableSize);
    size_t const scratchBufferSize = wkspSize - (CTableSize * sizeof(FSE_CTable));

    /* init conditions */
    if (wkspSize < FSE_WKSP_SIZE_U32(tableLog, maxSymbolValue)) return ERROR(tableLog_tooLarge);
    if (srcSize <= 1) return 0;  /* Not compressible */
    if (!maxSymbolValue) maxSymbolValue = FSE_MAX_SYMBOL_VALUE;
    if (!tableLog) tableLog = FSE_DEFAULT_TABLELOG;

    /* Scan input and build symbol stats */
    {   CHECK_V_F(maxCount, HIST_count_wksp(count, &maxSymbolValue, src, srcSize, scratchBuffer, scratchBufferSize) );
        if (maxCount == srcSize) return 1;   /* only a single symbol in src : rle */
        if (maxCount == 1) return 0;         /* each symbol present maximum once => not compressible */
        if (maxCount < (srcSize >> 7)) return 0;   /* Heuristic : not compressible enough */
    }

    tableLog = FSE_optimalTableLog(tableLog, srcSize, maxSymbolValue);
    CHECK_F( FSE_normalizeCount(norm, tableLog, count, srcSize, maxSymbolValue) );

    /* Write table description header */
    {   CHECK_V_F(nc_err, FSE_writeNCount(op, oend-op, norm, maxSymbolValue, tableLog) );
        op += nc_err;
    }

    /* Compress */
    CHECK_F( FSE_buildCTable_wksp(CTable, norm, maxSymbolValue, tableLog, scratchBuffer, scratchBufferSize) );
    {   CHECK_V_F(cSize, FSE_compress_usingCTable(op, oend - op, src, srcSize, CTable) );
        if (cSize == 0) return 0;   /* not enough space for compressed data */
        op += cSize;
    }

    /* check compressibility */
    if ( (size_t)(op-ostart) >= srcSize-1 ) return 0;

    return op-ostart;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6b0, %rsp            # imm = 0x6B0
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x658(%rbp)
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movl $0x1, %eax
shll %cl, %eax
addl $0x1, %eax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
shll %ecx
addl %ecx, %eax
movl %eax, %eax
movq %rax, -0x660(%rbp)
movq -0x658(%rbp), %rax
movq -0x660(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x668(%rbp)
movq 0x18(%rbp), %rax
movq -0x660(%rbp), %rcx
shlq $0x2, %rcx
subq %rcx, %rax
movq %rax, -0x670(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0x6a8(%rbp)
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movl $0x1, %eax
shll %cl, %eax
addl $0x1, %eax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
shll %ecx
addl %ecx, %eax
movl %eax, -0x69c(%rbp)
cmpl $0xc, -0x30(%rbp)
jbe 0x125b0
movl -0x30(%rbp), %ecx
subl $0x2, %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x6ac(%rbp)
jmp 0x125bd
movl $0x400, %eax            # imm = 0x400
movl %eax, -0x6ac(%rbp)
jmp 0x125bd
movq -0x6a8(%rbp), %rax
movl -0x69c(%rbp), %ecx
movl -0x6ac(%rbp), %edx
addl %edx, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x125e6
movq $-0x5, -0x8(%rbp)
jmp 0x12850
cmpq $0x1, -0x28(%rbp)
ja 0x125fa
movq $0x0, -0x8(%rbp)
jmp 0x12850
cmpl $0x0, -0x2c(%rbp)
jne 0x12607
movl $0xff, -0x2c(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x12614
movl $0xb, -0x30(%rbp)
leaq -0x450(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x668(%rbp), %r8
movq -0x670(%rbp), %r9
leaq -0x2c(%rbp), %rsi
callq 0xf420
movq %rax, -0x678(%rbp)
movq -0x678(%rbp), %rdi
callq 0x11f40
cmpl $0x0, %eax
je 0x12662
movq -0x678(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x12850
movq -0x678(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x1267c
movq $0x1, -0x8(%rbp)
jmp 0x12850
cmpq $0x1, -0x678(%rbp)
jne 0x12693
movq $0x0, -0x8(%rbp)
jmp 0x12850
movq -0x678(%rbp), %rax
movq -0x28(%rbp), %rcx
shrq $0x7, %rcx
cmpq %rcx, %rax
jae 0x126b4
movq $0x0, -0x8(%rbp)
jmp 0x12850
movl -0x30(%rbp), %edi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x118c0
movl %eax, -0x30(%rbp)
leaq -0x650(%rbp), %rdi
movl -0x30(%rbp), %esi
leaq -0x450(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
callq 0x118f0
movq %rax, -0x680(%rbp)
movq -0x680(%rbp), %rdi
callq 0x11f40
cmpl $0x0, %eax
je 0x1270c
movq -0x680(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x12850
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rax
subq %rax, %rsi
leaq -0x650(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq 0x112c0
movq %rax, -0x688(%rbp)
movq -0x688(%rbp), %rdi
callq 0x11f40
cmpl $0x0, %eax
je 0x12756
movq -0x688(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x12850
movq -0x688(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x658(%rbp), %rdi
leaq -0x650(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
movq -0x668(%rbp), %r8
movq -0x670(%rbp), %r9
callq 0x10d40
movq %rax, -0x690(%rbp)
movq -0x690(%rbp), %rdi
callq 0x11f40
cmpl $0x0, %eax
je 0x127b4
movq -0x690(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x12850
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rax
subq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x658(%rbp), %r8
callq 0x12110
movq %rax, -0x698(%rbp)
movq -0x698(%rbp), %rdi
callq 0x11f40
cmpl $0x0, %eax
je 0x127fc
movq -0x698(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x12850
cmpq $0x0, -0x698(%rbp)
jne 0x12810
movq $0x0, -0x8(%rbp)
jmp 0x12850
movq -0x698(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jb 0x12841
movq $0x0, -0x8(%rbp)
jmp 0x12850
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x6b0, %rsp            # imm = 0x6B0
popq %rbp
retq
nopl (%rax)