// File: /workspace/github_c_makefile_star2_O0/hoobaa[P]ficl/tools.c
// Function: ficlPrimitiveHashSummary
void ficlPrimitiveHashSummary(ficlVm *vm)
{
    ficlDictionary *dictionary = ficlVmGetDictionary(vm);
    ficlHash *pFHash;
    ficlWord **hash;
    unsigned size;
    ficlWord *word;
    unsigned i;
    int nMax = 0;
    int nWords = 0;
    int nFilled;
    double avg = 0.0;
    double best;
    int nAvg, nRem, nDepth;

    FICL_VM_DICTIONARY_CHECK(vm, dictionary, 0);

    pFHash = dictionary->wordlists[dictionary->wordlistCount - 1];
    hash  = pFHash->table;
    size   = pFHash->size;
    nFilled = size;

    for (i = 0; i < size; i++)
    {
        int n = 0;
        word = hash[i];

        while (word)
        {
            ++n;
            ++nWords;
            word = word->link;
        }

        avg += (double)(n * (n+1)) / 2.0;

        if (n > nMax)
            nMax = n;
        if (n == 0)
            --nFilled;
    }

    /* Calc actual avg search depth for this hash */
    avg = avg / nWords;

    /* Calc best possible performance with this size hash */
    nAvg = nWords / size;
    nRem = nWords % size;
    nDepth = size * (nAvg * (nAvg+1))/2 + (nAvg+1)*nRem;
    best = (double)nDepth/nWords;

    sprintf(vm->pad, 
        "%d bins, %2.0f%% filled, Depth: Max=%d, Avg=%2.1f, Best=%2.1f, Score: %2.0f%%\n", 
        size,
        (double)nFilled * 100.0 / size, nMax,
        avg, 
        best,
        100.0 * best / avg);

    ficlVmTextOut(vm, vm->pad);

    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8f80
movq %rax, -0x10(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0xa8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq 0x28(%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x505a
movl $0x0, -0x60(%rbp)
movq -0x20(%rbp), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x5007
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x4fe1
movl -0x60(%rbp), %eax
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0x102a1(%rip), %xmm1    # 0x152c0
divsd %xmm1, %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x503b
movl -0x60(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x60(%rbp)
jne 0x504a
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x504c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4fbf
movsd -0x48(%rbp), %xmm0
cvtsi2sdl -0x3c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x3c(%rbp), %eax
movl -0x24(%rbp), %ecx
xorl %edx, %edx
movl %edx, -0x64(%rbp)
divl %ecx
movl -0x64(%rbp), %edx
movl %eax, -0x54(%rbp)
movl -0x3c(%rbp), %eax
movl -0x24(%rbp), %ecx
divl %ecx
movl %edx, -0x58(%rbp)
movl -0x24(%rbp), %eax
movl -0x54(%rbp), %edx
movl %edx, %ecx
incl %ecx
imull %ecx, %edx
imull %edx, %eax
shrl %eax
movl -0x58(%rbp), %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp), %xmm0
cvtsi2sdl -0x3c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x8(%rbp), %rdi
addq $0x118, %rdi            # imm = 0x118
movl -0x24(%rbp), %eax
movl %eax, %edx
cvtsi2sdl -0x40(%rbp), %xmm0
movsd 0x101e0(%rip), %xmm1    # 0x152b8
mulsd %xmm1, %xmm0
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movl -0x38(%rbp), %ecx
movsd -0x48(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
movsd 0x101be(%rip), %xmm3    # 0x152b8
mulsd -0x50(%rbp), %xmm3
divsd -0x48(%rbp), %xmm3
leaq 0x1024d(%rip), %rsi     # 0x15358
movb $0x4, %al
callq 0x32d0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x118, %rsi            # imm = 0x118
callq 0x95e0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)