// File: /workspace/github_c_makefile_star2_O0/Cyan4973[P]FiniteStateEntropy/programs/../lib/huf_decompress.c
// Function: HUF_fillDTableX2
static void HUF_fillDTableX2(HUF_DEltX2* DTable, const U32 targetLog,
                           const sortedSymbol_t* sortedList, const U32 sortedListSize,
                           const U32* rankStart, rankVal_t rankValOrigin, const U32 maxWeight,
                           const U32 nbBitsBaseline)
{
    U32 rankVal[HUF_TABLELOG_MAX + 1];
    const int scaleLog = nbBitsBaseline - targetLog;   /* note : targetLog >= srcLog, hence scaleLog <= 1 */
    const U32 minBits  = nbBitsBaseline - maxWeight;
    U32 s;

    memcpy(rankVal, rankValOrigin, sizeof(rankVal));

    /* fill DTable */
    for (s=0; s<sortedListSize; s++) {
        const U16 symbol = sortedList[s].symbol;
        const U32 weight = sortedList[s].weight;
        const U32 nbBits = nbBitsBaseline - weight;
        const U32 start = rankVal[weight];
        const U32 length = 1 << (targetLog-nbBits);

        if (targetLog-nbBits >= minBits) {   /* enough room for a second symbol */
            U32 sortedRank;
            int minWeight = nbBits + scaleLog;
            if (minWeight < 1) minWeight = 1;
            sortedRank = rankStart[minWeight];
            HUF_fillDTableX2Level2(DTable+start, targetLog-nbBits, nbBits,
                           rankValOrigin[nbBits], minWeight,
                           sortedList+sortedRank, sortedListSize-sortedRank,
                           nbBitsBaseline, symbol);
        } else {
            HUF_DEltX2 DElt;
            MEM_writeLE16(&(DElt.sequence), symbol);
            DElt.nbBits = (BYTE)(nbBits);
            DElt.length = 1;
            {   U32 const end = start + length;
                U32 u;
                for (u = start; u < end; u++) DTable[u] = DElt;
        }   }
        rankVal[weight] += length;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl 0x18(%rbp), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x74(%rbp)
movl 0x18(%rbp), %eax
subl 0x10(%rbp), %eax
movl %eax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl $0x34, %edx
callq 0x1120
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x188b0
movq -0x18(%rbp), %rax
movl -0x7c(%rbp), %ecx
movzbl (%rax,%rcx,2), %eax
movw %ax, -0x7e(%rbp)
movq -0x18(%rbp), %rax
movl -0x7c(%rbp), %ecx
movzbl 0x1(%rax,%rcx,2), %eax
movl %eax, -0x84(%rbp)
movl 0x18(%rbp), %eax
subl -0x84(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x84(%rbp), %eax
movl -0x70(%rbp,%rax,4), %eax
movl %eax, -0x8c(%rbp)
movl -0xc(%rbp), %ecx
subl -0x88(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x90(%rbp)
movl -0xc(%rbp), %eax
subl -0x88(%rbp), %eax
cmpl -0x78(%rbp), %eax
jb 0x18819
movl -0x88(%rbp), %eax
addl -0x74(%rbp), %eax
movl %eax, -0x98(%rbp)
cmpl $0x1, -0x98(%rbp)
jge 0x18798
movl $0x1, -0x98(%rbp)
movq -0x28(%rbp), %rax
movslq -0x98(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x94(%rbp)
movq -0x8(%rbp), %rdi
movl -0x8c(%rbp), %eax
shlq $0x2, %rax
addq %rax, %rdi
movl -0xc(%rbp), %esi
subl -0x88(%rbp), %esi
movl -0x88(%rbp), %edx
movq -0x30(%rbp), %rcx
movl -0x88(%rbp), %eax
imulq $0x34, %rax, %rax
addq %rax, %rcx
movl -0x98(%rbp), %r8d
movq -0x18(%rbp), %r9
movl -0x94(%rbp), %eax
shlq %rax
addq %rax, %r9
movl -0x1c(%rbp), %r10d
subl -0x94(%rbp), %r10d
movl 0x18(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movzwl -0x7e(%rbp), %eax
movl %eax, 0x10(%rsp)
callq 0x1eb00
jmp 0x1888e
leaq -0x9c(%rbp), %rdi
movzwl -0x7e(%rbp), %esi
callq 0x1ec70
movl -0x88(%rbp), %eax
movb %al, -0x9a(%rbp)
movb $0x1, -0x99(%rbp)
movl -0x8c(%rbp), %eax
addl -0x90(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0xa0(%rbp), %eax
jae 0x1888c
movq -0x8(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl -0x9c(%rbp), %edx
movl %edx, (%rax,%rcx,4)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x1885a
jmp 0x1888e
movl -0x90(%rbp), %ecx
movl -0x84(%rbp), %eax
addl -0x70(%rbp,%rax,4), %ecx
movl %ecx, -0x70(%rbp,%rax,4)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x18702
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)