// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/src/dict.c
// Function: dictGetStatsHt
size_t _dictGetStatsHt(char *buf, size_t bufsize, dictht *ht, int tableid) {
    unsigned long i, slots = 0, chainlen, maxchainlen = 0;
    unsigned long totchainlen = 0;
    unsigned long clvector[DICT_STATS_VECTLEN];
    size_t l = 0;

    if (ht->used == 0) {
        return snprintf(buf,bufsize,
            "No stats available for empty dictionaries\n");
    }

    /* Compute stats. */
    for (i = 0; i < DICT_STATS_VECTLEN; i++) clvector[i] = 0;
    for (i = 0; i < ht->size; i++) {
        dictEntry *he;

        if (ht->table[i] == NULL) {
            clvector[0]++;
            continue;
        }
        slots++;
        /* For each hash entry on this slot... */
        chainlen = 0;
        he = ht->table[i];
        while(he) {
            chainlen++;
            he = he->next;
        }
        clvector[(chainlen < DICT_STATS_VECTLEN) ? chainlen : (DICT_STATS_VECTLEN-1)]++;
        if (chainlen > maxchainlen) maxchainlen = chainlen;
        totchainlen += chainlen;
    }

    /* Generate human readable stats. */
    l += snprintf(buf+l,bufsize-l,
        "Hash table %d stats (%s):\n"
        " table size: %ld\n"
        " number of elements: %ld\n"
        " different slots: %ld\n"
        " max chain length: %ld\n"
        " avg chain length (counted): %.02f\n"
        " avg chain length (computed): %.02f\n"
        " Chain length distribution:\n",
        tableid, (tableid == 0) ? "main hash table" : "rehashing target",
        ht->size, ht->used, slots, maxchainlen,
        (float)totchainlen/slots, (float)ht->used/slots);

    for (i = 0; i < DICT_STATS_VECTLEN-1; i++) {
        if (clvector[i] == 0) continue;
        if (l >= bufsize) break;
        l += snprintf(buf+l,bufsize-l,
            "   %s%ld: %ld (%.02f%%)\n",
            (i == DICT_STATS_VECTLEN-1)?">= ":"",
            i, clvector[i], ((float)clvector[i]/ht->size)*100);
    }

    /* Unlike snprintf(), teturn the number of characters actually written. */
    if (bufsize) buf[bufsize-1] = '\0';
    return strlen(buf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %rbx
movq 0x18(%rdx), %r12
testq %r12, %r12
je 0x198a8
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
xorl %r13d, %r13d
movl $0x190, %edx            # imm = 0x190
xorl %esi, %esi
callq 0x12380
movq 0x8(%r15), %r9
testq %r9, %r9
je 0x198cd
movq (%r15), %rcx
xorl %eax, %eax
xorl %r10d, %r10d
xorl %r13d, %r13d
xorl %edx, %edx
movq (%rcx,%rdx,8), %rdi
testq %rdi, %rdi
je 0x1988f
xorl %esi, %esi
incq %rsi
movq 0x10(%rdi), %rdi
testq %rdi, %rdi
jne 0x19860
incq %r13
cmpq $0x31, %rsi
movl $0x31, %edi
cmovbq %rsi, %rdi
movl %edi, %edi
incq 0x10(%rsp,%rdi,8)
cmpq %r10, %rsi
cmovaq %rsi, %r10
addq %rsi, %rax
jmp 0x19894
incq 0x10(%rsp)
incq %rdx
cmpq %r9, %rdx
jne 0x19855
testq %rax, %rax
js 0x198d5
cvtsi2ss %rax, %xmm0
jmp 0x198ea
leaq 0x3894a(%rip), %rdx     # 0x521f9
movq %rbx, %rdi
xorl %eax, %eax
callq 0x122d0
cltq
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
xorl %r10d, %r10d
jmp 0x198ea
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
testl %ebp, %ebp
leaq 0x38a06(%rip), %rax     # 0x522f9
leaq 0x38a0f(%rip), %r8      # 0x52309
cmoveq %rax, %r8
testq %r13, %r13
js 0x1990a
cvtsi2ss %r13, %xmm1
jmp 0x19922
movq %r13, %rax
shrq %rax
movl %r13d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
testq %r12, %r12
js 0x19936
cvtsi2ss %r12, %xmm2
jmp 0x1994e
movq %r12, %rax
shrq %rax
movl %r12d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm2
addss %xmm2, %xmm2
movq 0x8(%rsp), %rsi
divss %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
subq $0x8, %rsp
leaq 0x388bb(%rip), %rdx     # 0x52224
movq %rbx, %r14
movq %rbx, %rdi
movl %ebp, %ecx
movb $0x2, %al
pushq %r10
pushq %r13
pushq %r12
callq 0x122d0
addq $0x20, %rsp
movslq %eax, %rbx
movq 0x8(%rsp), %rax
xorl %r12d, %r12d
leaq 0x38986(%rip), %r13     # 0x5231a
leaq 0x3b86a(%rip), %rbp     # 0x55205
movq 0x10(%rsp,%r12,8), %r9
testq %r9, %r9
je 0x19a38
movq %rax, %rsi
subq %rbx, %rsi
jbe 0x19a45
testq %r9, %r9
js 0x199c4
xorps %xmm0, %xmm0
cvtsi2ss %r9, %xmm0
jmp 0x199df
movq %r9, %rax
shrq %rax
movl %r9d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
movq 0x8(%r15), %rax
testq %rax, %rax
js 0x199f2
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
jmp 0x19a0a
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
leaq (%r14,%rbx), %rdi
mulss 0x3877a(%rip), %xmm0    # 0x52194
cvtss2sd %xmm0, %xmm0
movq %r13, %rdx
movq %rbp, %rcx
movq %r12, %r8
movb $0x1, %al
callq 0x122d0
cltq
addq %rax, %rbx
movq 0x8(%rsp), %rax
incq %r12
cmpq $0x31, %r12
jne 0x1999b
testq %rax, %rax
je 0x19a50
movb $0x0, -0x1(%r14,%rax)
movq %r14, %rdi
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x12250