// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x58(%rbp)
cmpl $0xa, -0x58(%rbp)
jge 0x12cbe
movslq -0x58(%rbp), %rax
movl $0x0, -0x50(%rbp,%rax,4)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x12ca1
movl $0x0, -0x54(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x12d8c
movl $0x0, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x12d1b
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x12cfe
cmpl $0xa, -0x5c(%rbp)
jge 0x12d32
movslq -0x5c(%rbp), %rax
movl -0x50(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x50(%rbp,%rax,4)
jmp 0x12d3b
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
cvtsi2sdl -0x5c(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd 0xbf5b(%rip), %xmm0     # 0x1eca8
addsd -0x70(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
movq -0x10(%rbp), %rax
cvtsi2sdl 0x2c(%rax), %xmm2
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd 0xbf30(%rip), %xmm1     # 0x1eca0
divsd %xmm1, %xmm0
addsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x12cd4
movq -0x20(%rbp), %rdi
movl $0x384, %esi            # imm = 0x384
leaq 0xa683(%rip), %rdx      # 0x1d41f
movl $0x162, %ecx            # imm = 0x162
callq 0x44c0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x28(%rax), %ecx
leaq 0xbf1b(%rip), %rsi      # 0x1ecde
movb $0x0, %al
callq 0x45d0
movq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x80(%rbp), %rdi
callq 0x41b0
movq %rax, %rcx
movq -0x90(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x58(%rbp)
cmpl $0xa, -0x58(%rbp)
jge 0x12e44
movq -0x88(%rbp), %rdi
movl -0x58(%rbp), %edx
movslq -0x58(%rbp), %rax
movl -0x50(%rbp,%rax,4), %ecx
leaq 0xbee7(%rip), %rsi      # 0x1ecff
movb $0x0, %al
callq 0x45d0
movq -0x88(%rbp), %rdi
callq 0x41b0
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x12df9
movq -0x88(%rbp), %rdi
movl -0x54(%rbp), %ecx
leaq 0xbed1(%rip), %rsi      # 0x1ed26
movl $0xa, %edx
movb $0x0, %al
callq 0x45d0
movq -0x88(%rbp), %rdi
callq 0x41b0
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
movsd -0x68(%rbp), %xmm0
leaq 0xbecc(%rip), %rsi      # 0x1ed5a
movb $0x1, %al
callq 0x45d0
movq -0x80(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)