// File: /workspace/github_c_makefile_star2_O1/haxlang[P]hax/haxHash.c
// Function: Hax_HashStats
char *
Hax_HashStats(
    Hax_Interp *interp,
    Hax_HashTable *tablePtr		/* Table for which to produce stats. */)
{
    Interp *iPtr = (Interp *)interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
#define NUM_COUNTERS 10
    int count[NUM_COUNTERS], overflow, i, j;
    double average, tmp;
    Hax_HashEntry *hPtr;
    char *result, *p;

    /*
     * Compute a histogram of bucket usage.
     */

    for (i = 0; i < NUM_COUNTERS; i++) {
	count[i] = 0;
    }
    overflow = 0;
    average = 0.0;
    for (i = 0; i < tablePtr->numBuckets; i++) {
	j = 0;
	for (hPtr = tablePtr->buckets[i]; hPtr != NULL; hPtr = hPtr->nextPtr) {
	    j++;
	}
	if (j < NUM_COUNTERS) {
	    count[j]++;
	} else {
	    overflow++;
	}
	tmp = j;
	average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0;
    }

    /*
     * Print out the histogram and a few other pieces of information.
     */

    result = (char *) ckalloc(memoryp, (unsigned) ((NUM_COUNTERS*60) + 300));
    sprintf(result, "%d entries in table, %d buckets\n",
	    tablePtr->numEntries, tablePtr->numBuckets);
    p = result + strlen(result);
    for (i = 0; i < NUM_COUNTERS; i++) {
	sprintf(p, "number of buckets with %d entries: %d\n",
		i, count[i]);
	p += strlen(p);
    }
    sprintf(p, "number of buckets with more %d or more entries: %d\n",
	    NUM_COUNTERS, overflow);
    p += strlen(p);
    sprintf(p, "average search distance for entry: %.1f", average);
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq 0x280(%rdi), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x30(%rsp)
movslq 0x28(%rsi), %rax
testq %rax, %rax
jle 0xde61
movq (%r14), %rcx
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%r14), %xmm0
xorpd %xmm4, %xmm4
xorl %edx, %edx
movsd 0x8e00(%rip), %xmm1     # 0x16c10
xorl %ebx, %ebx
leaq (%rcx,%rdx,8), %r8
xorl %esi, %esi
movq (%r8), %r8
incq %rsi
testq %r8, %r8
jne 0xde18
leaq -0x1(%rsi), %r8
cmpl $0x9, %r8d
ja 0xde33
incl 0xc(%rsp,%rsi,4)
jmp 0xde35
incl %ebx
xorps %xmm2, %xmm2
cvtsi2sd %r8d, %xmm2
divsd %xmm0, %xmm2
movl %esi, %esi
xorps %xmm3, %xmm3
cvtsi2sd %rsi, %xmm3
mulsd %xmm2, %xmm3
mulsd %xmm1, %xmm3
addsd %xmm3, %xmm4
incq %rdx
cmpq %rax, %rdx
jne 0xde12
jmp 0xde67
xorl %ebx, %ebx
xorpd %xmm4, %xmm4
movsd %xmm4, 0x8(%rsp)
leaq 0x75ea(%rip), %rdx      # 0x1545e
movl $0x384, %esi            # imm = 0x384
movl $0x162, %ecx            # imm = 0x162
callq 0x44c0
movq %rax, %r15
movl 0x28(%r14), %ecx
movl 0x2c(%r14), %edx
leaq 0x8db1(%rip), %rsi      # 0x16c46
movq %rax, %rdi
xorl %eax, %eax
callq 0x45d0
movq %r15, %rdi
callq 0x41d0
movq %rax, %r14
addq %r15, %r14
leaq 0x8db3(%rip), %r12      # 0x16c67
xorl %r13d, %r13d
movq %r14, %rbp
movl 0x10(%rsp,%r13,4), %ecx
movq %r14, %rdi
movq %r12, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0x45d0
movq %r14, %rdi
callq 0x41d0
movq %rax, %r14
addq %rbp, %r14
incq %r13
cmpq $0xa, %r13
jne 0xdeb7
leaq 0x8da1(%rip), %rsi      # 0x16c8e
movq %r14, %rdi
movl $0xa, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x45d0
movq %r14, %rdi
callq 0x41d0
addq %rax, %r14
leaq 0x8db2(%rip), %rsi      # 0x16cc2
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x1, %al
callq 0x45d0
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq