// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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 0x2f617
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 0x26110
movq 0x8(%r15), %r9
testq %r9, %r9
je 0x2f63c
movq (%r15), %rcx
xorl %eax, %eax
xorl %r10d, %r10d
xorl %r13d, %r13d
xorl %edx, %edx
movq (%rcx,%rdx,8), %rdi
testq %rdi, %rdi
je 0x2f5fe
xorl %esi, %esi
incq %rsi
movq 0x10(%rdi), %rdi
testq %rdi, %rdi
jne 0x2f5cf
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 0x2f603
incq 0x10(%rsp)
incq %rdx
cmpq %r9, %rdx
jne 0x2f5c4
testq %rax, %rax
js 0x2f644
cvtsi2ss %rax, %xmm0
jmp 0x2f659
leaq 0x8cc68(%rip), %rdx     # 0xbc286
movq %rbx, %rdi
xorl %eax, %eax
callq 0x26120
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 0x2f659
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
testl %ebp, %ebp
leaq 0x8cd24(%rip), %rax     # 0xbc386
leaq 0x8cd2d(%rip), %r8      # 0xbc396
cmoveq %rax, %r8
testq %r13, %r13
js 0x2f679
cvtsi2ss %r13, %xmm1
jmp 0x2f691
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 0x2f6a5
cvtsi2ss %r12, %xmm2
jmp 0x2f6bd
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 0x8cbd9(%rip), %rdx     # 0xbc2b1
movq %rbx, %r14
movq %rbx, %rdi
movl %ebp, %ecx
movb $0x2, %al
pushq %r10
pushq %r13
pushq %r12
callq 0x26120
addq $0x20, %rsp
movslq %eax, %rbx
movq 0x8(%rsp), %rax
xorl %r12d, %r12d
leaq 0x8cca4(%rip), %r13     # 0xbc3a7
leaq 0x913ab(%rip), %rbp     # 0xc0ab5
movq 0x10(%rsp,%r12,8), %r9
testq %r9, %r9
je 0x2f7a7
movq %rax, %rsi
subq %rbx, %rsi
jbe 0x2f7b4
testq %r9, %r9
js 0x2f733
xorps %xmm0, %xmm0
cvtsi2ss %r9, %xmm0
jmp 0x2f74e
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 0x2f761
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
jmp 0x2f779
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 0x8ca9f(%rip), %xmm0    # 0xbc228
cvtss2sd %xmm0, %xmm0
movq %r13, %rdx
movq %rbp, %rcx
movq %r12, %r8
movb $0x1, %al
callq 0x26120
cltq
addq %rax, %rbx
movq 0x8(%rsp), %rax
incq %r12
cmpq $0x31, %r12
jne 0x2f70a
testq %rax, %rax
je 0x2f7bf
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 0x26500