// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/../foreign/miniz-c.h
// Function: tdefl_calculate_minimum_redundancy
static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n)
{
    int root, leaf, next, avbl, used, dpth;
    if (n == 0)
        return;
    else if (n == 1)
    {
        A[0].m_key = 1;
        return;
    }
    A[0].m_key += A[1].m_key;
    root = 0;
    leaf = 2;
    for (next = 1; next < n - 1; next++)
    {
        if (leaf >= n || A[root].m_key < A[leaf].m_key)
        {
            A[next].m_key = A[root].m_key;
            A[root++].m_key = (mz_uint16)next;
        }
        else
            A[next].m_key = A[leaf++].m_key;
        if (leaf >= n || (root < next && A[root].m_key < A[leaf].m_key))
        {
            A[next].m_key = (mz_uint16)(A[next].m_key + A[root].m_key);
            A[root++].m_key = (mz_uint16)next;
        }
        else
            A[next].m_key = (mz_uint16)(A[next].m_key + A[leaf++].m_key);
    }
    A[n - 2].m_key = 0;
    for (next = n - 3; next >= 0; next--)
        A[next].m_key = A[A[next].m_key].m_key + 1;
    avbl = 1;
    used = dpth = 0;
    root = n - 2;
    next = n - 1;
    while (avbl > 0)
    {
        while (root >= 0 && (int)A[root].m_key == dpth)
        {
            used++;
            root--;
        }
        while (avbl > used)
        {
            A[next--].m_key = (mz_uint16)(dpth);
            avbl--;
        }
        avbl = 2 * used;
        dpth++;
        used = 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x19a286
jmp 0x19a519
cmpl $0x1, -0xc(%rbp)
jne 0x19a29a
movq -0x8(%rbp), %rax
movw $0x1, (%rax)
jmp 0x19a519
jmp 0x19a29c
movq -0x8(%rbp), %rax
movzwl 0x4(%rax), %edx
movq -0x8(%rbp), %rax
movzwl (%rax), %ecx
addl %edx, %ecx
movw %cx, (%rax)
movl $0x0, -0x10(%rbp)
movl $0x2, -0x14(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x19a408
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x19a2fa
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movzwl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movzwl (%rcx,%rdx,4), %ecx
cmpl %ecx, %eax
jge 0x19a330
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movw (%rax,%rcx,4), %dx
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movw %dx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
movw %ax, %dx
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x10(%rbp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,4)
jmp 0x19a352
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x14(%rbp)
movslq %ecx, %rcx
movw (%rax,%rcx,4), %dx
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movw %dx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x19a37e
movl -0x10(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x19a3c5
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movzwl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movzwl (%rcx,%rdx,4), %ecx
cmpl %ecx, %eax
jge 0x19a3c5
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
movslq -0x10(%rbp), %rdx
movzwl (%rcx,%rdx,4), %ecx
addl %ecx, %eax
movw %ax, %dx
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movw %dx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
movw %ax, %dx
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x10(%rbp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,4)
jmp 0x19a3f8
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
movl -0x14(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x14(%rbp)
movslq %edx, %rdx
movzwl (%rcx,%rdx,4), %ecx
addl %ecx, %eax
movw %ax, %dx
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movw %dx, (%rax,%rcx,4)
jmp 0x19a3fa
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x19a2c5
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movw $0x0, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jl 0x19a45b
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movslq -0x18(%rbp), %rdx
movzwl (%rcx,%rdx,4), %ecx
movzwl (%rax,%rcx,4), %eax
addl $0x1, %eax
movw %ax, %dx
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movw %dx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x19a424
movl $0x1, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl -0xc(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x1c(%rbp)
jle 0x19a519
jmp 0x19a48e
xorl %eax, %eax
cmpl $0x0, -0x10(%rbp)
movb %al, -0x25(%rbp)
jl 0x19a4ae
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movzwl (%rax,%rcx,4), %eax
cmpl -0x24(%rbp), %eax
sete %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
testb $0x1, %al
jne 0x19a4b7
jmp 0x19a4cb
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x19a48e
jmp 0x19a4cd
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jle 0x19a4fc
movl -0x24(%rbp), %eax
movw %ax, %dx
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x19a4cd
movl -0x20(%rbp), %eax
shll %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
jmp 0x19a482
popq %rbp
retq
nopl (%rax,%rax)