// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %r14
movq 0x280(%rdi), %rdi
xorl %eax, %eax
cmpq $0xa, %rax
je 0xccc2
andl $0x0, 0x10(%rsp,%rax,4)
incq %rax
jmp 0xccb2
movl 0x28(%r14), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
xorpd %xmm4, %xmm4
movsd 0x7d17(%rip), %xmm0     # 0x149f0
xorl %ebx, %ebx
cmpq %rax, %rcx
je 0xcd2f
leaq (,%rcx,8), %rsi
addq (%r14), %rsi
xorl %edx, %edx
movq (%rsi), %rsi
incq %rdx
testq %rsi, %rsi
jne 0xcced
leaq -0x1(%rdx), %rsi
cmpl $0x9, %esi
ja 0xcd07
incl 0xc(%rsp,%rdx,4)
jmp 0xcd09
incl %ebx
cvtsi2sd %esi, %xmm1
movl %edx, %edx
cvtsi2sd %rdx, %xmm2
cvtsi2sdl 0x2c(%r14), %xmm3
divsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm4
incq %rcx
jmp 0xccdb
movsd %xmm4, 0x8(%rsp)
leaq 0x6722(%rip), %rdx      # 0x1345e
movl $0x384, %esi            # imm = 0x384
movl $0x162, %ecx            # imm = 0x162
callq 0x44e0
movq %rax, %r15
movl 0x28(%r14), %ecx
movl 0x2c(%r14), %edx
leaq 0x7cc9(%rip), %rsi      # 0x14a26
movq %rax, %rdi
xorl %eax, %eax
callq 0x45f0
movq %r15, %rdi
callq 0x41d0
movq %rax, %r14
addq %r15, %r14
leaq 0x7ccb(%rip), %r12      # 0x14a47
xorl %r13d, %r13d
cmpq $0xa, %r13
je 0xcdaa
movl 0x10(%rsp,%r13,4), %ecx
movq %r14, %rdi
movq %r12, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0x45f0
movq %r14, %rdi
callq 0x41d0
addq %rax, %r14
incq %r13
jmp 0xcd7f
leaq 0x7cbd(%rip), %rsi      # 0x14a6e
pushq $0xa
popq %rdx
movq %r14, %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x45f0
movq %r14, %rdi
callq 0x41d0
addq %rax, %r14
leaq 0x7cd0(%rip), %rsi      # 0x14aa2
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x1, %al
callq 0x45f0
movq %r15, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq