// File: /workspace/github_c_makefile_star2_O0/Cyan4973[P]FiniteStateEntropy/programs/../lib/huf_compress.c
// Function: HUF_compressWeights
static size_t HUF_compressWeights (void* dst, size_t dstSize, const void* weightTable, size_t wtSize)
{
    BYTE* const ostart = (BYTE*) dst;
    BYTE* op = ostart;
    BYTE* const oend = ostart + dstSize;

    unsigned maxSymbolValue = HUF_TABLELOG_MAX;
    U32 tableLog = MAX_FSE_TABLELOG_FOR_HUFF_HEADER;

    FSE_CTable CTable[FSE_CTABLE_SIZE_U32(MAX_FSE_TABLELOG_FOR_HUFF_HEADER, HUF_TABLELOG_MAX)];
    BYTE scratchBuffer[1<<MAX_FSE_TABLELOG_FOR_HUFF_HEADER];

    unsigned count[HUF_TABLELOG_MAX+1];
    S16 norm[HUF_TABLELOG_MAX+1];

    /* init conditions */
    if (wtSize <= 1) return 0;  /* Not compressible */

    /* Scan input and build symbol stats */
    {   unsigned const maxCount = HIST_count_simple(count, &maxSymbolValue, weightTable, wtSize);   /* never fails */
        if (maxCount == wtSize) return 1;   /* only a single symbol in src : rle */
        if (maxCount == 1) return 0;        /* each symbol present maximum once => not compressible */
    }

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

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

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

    return (size_t)(op-ostart);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0xc, -0x44(%rbp)
movl $0x6, -0x48(%rbp)
cmpq $0x1, -0x28(%rbp)
ja 0x15019
movq $0x0, -0x8(%rbp)
jmp 0x151dc
leaq -0x1c0(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0x44(%rbp), %rsi
callq 0xee10
movl %eax, -0x1e4(%rbp)
movl -0x1e4(%rbp), %eax
cmpq -0x28(%rbp), %rax
jne 0x15050
movq $0x1, -0x8(%rbp)
jmp 0x151dc
cmpl $0x1, -0x1e4(%rbp)
jne 0x15066
movq $0x0, -0x8(%rbp)
jmp 0x151dc
movl -0x48(%rbp), %edi
movq -0x28(%rbp), %rsi
movl -0x44(%rbp), %edx
callq 0x118c0
movl %eax, -0x48(%rbp)
leaq -0x1e0(%rbp), %rdi
movl -0x48(%rbp), %esi
leaq -0x1c0(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x44(%rbp), %r8d
callq 0x118f0
movq %rax, -0x1f0(%rbp)
movq -0x1f0(%rbp), %rdi
callq 0x151f0
cmpl $0x0, %eax
je 0x150be
movq -0x1f0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x151dc
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
subq %rax, %rsi
leaq -0x1e0(%rbp), %rdx
movl -0x44(%rbp), %ecx
movl -0x48(%rbp), %r8d
callq 0x112c0
movq %rax, -0x1f8(%rbp)
movq -0x1f8(%rbp), %rdi
callq 0x151f0
cmpl $0x0, %eax
je 0x15108
movq -0x1f8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x151dc
movq -0x1f8(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x140(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
leaq -0x180(%rbp), %r8
movl $0x40, %r9d
callq 0x10d40
movq %rax, -0x200(%rbp)
movq -0x200(%rbp), %rdi
callq 0x151f0
cmpl $0x0, %eax
je 0x15162
movq -0x200(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x151dc
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
subq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0x140(%rbp), %r8
callq 0x12110
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rdi
callq 0x151f0
cmpl $0x0, %eax
je 0x151aa
movq -0x208(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x151dc
cmpq $0x0, -0x208(%rbp)
jne 0x151be
movq $0x0, -0x8(%rbp)
jmp 0x151dc
movq -0x208(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopl (%rax)