// File: /workspace/github_c_makefile_star2_O2/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 $0x198, %rsp            # imm = 0x198
movq 0x18(%rdx), %r10
testq %r10, %r10
je 0x2af90
movq %rdx, %r15
xorl %eax, %eax
cmpq $0x32, %rax
je 0x2af13
andq $0x0, (%rsp,%rax,8)
incq %rax
jmp 0x2af03
movq 0x8(%r15), %r9
xorl %edx, %edx
pushq $0x31
popq %r14
xorl %r11d, %r11d
xorl %r12d, %r12d
xorl %eax, %eax
cmpq %r9, %rdx
je 0x2af70
movq (%r15), %r8
movq (%r8,%rdx,8), %r8
testq %r8, %r8
je 0x2af67
xorl %ebx, %ebx
testq %r8, %r8
je 0x2af46
incq %rbx
movq 0x10(%r8), %r8
jmp 0x2af38
incq %r11
cmpq $0x31, %rbx
movq %r14, %r8
cmovbq %rbx, %r8
movl %r8d, %r8d
incq (%rsp,%r8,8)
cmpq %r12, %rbx
cmovaq %rbx, %r12
addq %rbx, %rax
jmp 0x2af6b
incq (%rsp)
incq %rdx
jmp 0x2af25
testl %ecx, %ecx
leaq 0x833b5(%rip), %rdx     # 0xae32e
leaq 0x833be(%rip), %r8      # 0xae33e
cmoveq %rdx, %r8
testq %rax, %rax
js 0x2afb2
cvtsi2ss %rax, %xmm0
jmp 0x2afc7
leaq 0x83297(%rip), %rdx     # 0xae22e
xorl %eax, %eax
callq 0x26120
cltq
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdx
shrq %rdx
andl $0x1, %eax
orq %rdx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
testq %r11, %r11
js 0x2afd3
cvtsi2ss %r11, %xmm1
jmp 0x2afeb
movq %r11, %rax
shrq %rax
movl %r11d, %edx
andl $0x1, %edx
orq %rax, %rdx
cvtsi2ss %rdx, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
testq %r10, %r10
js 0x2afff
cvtsi2ss %r10, %xmm2
jmp 0x2b017
movq %r10, %rax
shrq %rax
movl %r10d, %edx
andl $0x1, %edx
orq %rax, %rdx
cvtsi2ss %rdx, %xmm2
addss %xmm2, %xmm2
divss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm1
subq $0x8, %rsp
leaq 0x8322f(%rip), %rdx     # 0xae259
movq %rdi, %r14
movq %rsi, %r13
movb $0x2, %al
pushq %r12
pushq %r11
pushq %r10
callq 0x26120
addq $0x20, %rsp
movslq %eax, %rbx
xorl %r12d, %r12d
leaq 0x873b7(%rip), %rbp     # 0xb2405
cmpq $0x31, %r12
je 0x2b0e7
movq (%rsp,%r12,8), %r9
testq %r9, %r9
je 0x2b0df
movq %r13, %rsi
subq %rbx, %rsi
jbe 0x2b0e7
testq %r9, %r9
js 0x2b075
cvtsi2ss %r9, %xmm0
jmp 0x2b08d
movq %r9, %rax
shrq %rax
movl %r9d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
movq 0x8(%r15), %rax
testq %rax, %rax
js 0x2b09d
cvtsi2ss %rax, %xmm1
jmp 0x2b0b2
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
leaq (%r14,%rbx), %rdi
mulss 0x8310e(%rip), %xmm0    # 0xae1d0
cvtss2sd %xmm0, %xmm0
leaq 0x83282(%rip), %rdx     # 0xae34f
movq %rbp, %rcx
movq %r12, %r8
movb $0x1, %al
callq 0x26120
cltq
addq %rax, %rbx
incq %r12
jmp 0x2b04e
testq %r13, %r13
je 0x2b0f2
movb $0x0, -0x1(%r14,%r13)
movq %r14, %rdi
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x26500