// File: jimmiebergmann[P]fbx-file/miniz.c
// Function: tdefl_radix_sort_syms(unsigned int, tdefl_sym_freq*, tdefl_sym_freq*)
static tdefl_sym_freq *tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq *pSyms0, tdefl_sym_freq *pSyms1)
{
    mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2];
    tdefl_sym_freq *pCur_syms = pSyms0, *pNew_syms = pSyms1;
    MZ_CLEAR_OBJ(hist);
    for (i = 0; i < num_syms; i++)
    {
        mz_uint freq = pSyms0[i].m_key;
        hist[freq & 0xFF]++;
        hist[256 + ((freq >> 8) & 0xFF)]++;
    }
    while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256]))
        total_passes--;
    for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8)
    {
        const mz_uint32 *pHist = &hist[pass << 8];
        mz_uint offsets[256], cur_ofs = 0;
        for (i = 0; i < 256; i++)
        {
            offsets[i] = cur_ofs;
            cur_ofs += pHist[i];
        }
        for (i = 0; i < num_syms; i++)
            pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i];
        {
            tdefl_sym_freq *t = pCur_syms;
            pCur_syms = pNew_syms;
            pNew_syms = t;
        }
    }
    return pCur_syms;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc70, %rsp            # imm = 0xC70
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x2, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x838(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x840(%rbp)
leaq -0x830(%rbp), %rdi
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x3190
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x4(%rbp), %eax
jae 0x1ee75
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
movzwl (%rax,%rcx,4), %eax
movl %eax, -0x844(%rbp)
movl -0x844(%rbp), %eax
andl $0xff, %eax
movl %eax, %eax
movl -0x830(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x830(%rbp,%rax,4)
movl -0x844(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, %eax
movl -0x830(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x830(%rbp,%rax,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1ee0d
jmp 0x1ee77
xorl %eax, %eax
cmpl $0x1, -0x1c(%rbp)
movb %al, -0xc61(%rbp)
jbe 0x1eea3
movl -0x4(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
shll $0x8, %ecx
movl %ecx, %ecx
cmpl -0x830(%rbp,%rcx,4), %eax
sete %al
movb %al, -0xc61(%rbp)
movb -0xc61(%rbp), %al
testb $0x1, %al
jne 0x1eeaf
jmp 0x1eeba
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1ee77
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x1efeb
movl -0x24(%rbp), %eax
shll $0x8, %eax
movl %eax, %eax
movl %eax, %ecx
leaq -0x830(%rbp), %rax
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x850(%rbp)
movl $0x0, -0xc54(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x100, -0x28(%rbp)     # imm = 0x100
jae 0x1ef41
movl -0xc54(%rbp), %ecx
movl -0x28(%rbp), %eax
movl %ecx, -0xc50(%rbp,%rax,4)
movq -0x850(%rbp), %rax
movl -0x28(%rbp), %ecx
movl (%rax,%rcx,4), %eax
addl -0xc54(%rbp), %eax
movl %eax, -0xc54(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1ef04
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x4(%rbp), %eax
jae 0x1efaa
movq -0x838(%rbp), %rdx
movl -0x28(%rbp), %eax
movl %eax, %esi
movq -0x840(%rbp), %rax
movq -0x838(%rbp), %rcx
movl -0x28(%rbp), %edi
movzwl (%rcx,%rdi,4), %edi
movl -0x20(%rbp), %ecx
sarl %cl, %edi
movl %edi, %ecx
andl $0xff, %ecx
movslq %ecx, %rdi
movl -0xc50(%rbp,%rdi,4), %ecx
movl %ecx, %r8d
addl $0x1, %r8d
movl %r8d, -0xc50(%rbp,%rdi,4)
movl %ecx, %ecx
movl (%rdx,%rsi,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1ef48
movq -0x838(%rbp), %rax
movq %rax, -0xc60(%rbp)
movq -0x840(%rbp), %rax
movq %rax, -0x838(%rbp)
movq -0xc60(%rbp), %rax
movq %rax, -0x840(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x20(%rbp)
jmp 0x1eec8
movq -0x838(%rbp), %rax
addq $0xc70, %rsp            # imm = 0xC70
popq %rbp
retq
nopl (%rax,%rax)