// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/haxHash.c
// Function: RebuildTable
static void
RebuildTable(
    Hax_Interp *interp,
    Hax_HashTable *tablePtr	/* Table to enlarge. */)
{
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
    int oldSize, count, index;
    Hax_HashEntry **oldBuckets;
    Hax_HashEntry **oldChainPtr, **newChainPtr;
    Hax_HashEntry *hPtr;

    oldSize = tablePtr->numBuckets;
    oldBuckets = tablePtr->buckets;

    /*
     * Allocate and initialize the new bucket array, and set up
     * hashing constants for new array size.
     */

    tablePtr->numBuckets *= 4;
    tablePtr->buckets = (Hax_HashEntry **) ckalloc(memoryp, (unsigned)
	    (tablePtr->numBuckets * sizeof(Hax_HashEntry *)));
    for (count = tablePtr->numBuckets, newChainPtr = tablePtr->buckets;
	    count > 0; count--, newChainPtr++) {
	*newChainPtr = NULL;
    }
    tablePtr->rebuildSize *= 4;
    tablePtr->downShift -= 2;
    tablePtr->mask = (tablePtr->mask << 2) + 3;

    /*
     * Rehash all of the existing entries into the new bucket array.
     */

    for (oldChainPtr = oldBuckets; oldSize > 0; oldSize--, oldChainPtr++) {
	for (hPtr = *oldChainPtr; hPtr != NULL; hPtr = *oldChainPtr) {
	    *oldChainPtr = hPtr->nextPtr;
	    if (tablePtr->keyType == HAX_STRING_KEYS) {
		index = HashString(hPtr->key.string) & tablePtr->mask;
	    } else if (tablePtr->keyType == HAX_ONE_WORD_KEYS) {
		index = RANDOM_INDEX(tablePtr, hPtr->key.oneWordValue);
	    } else {
		int *iPtr;
		int count;

		for (index = 0, count = tablePtr->keyType,
			iPtr = hPtr->key.words; count > 0; count--, iPtr++) {
		    index += *iPtr;
		}
		index = RANDOM_INDEX(tablePtr, index);
	    }
	    hPtr->bucketPtr = &(tablePtr->buckets[index]);
	    hPtr->nextPtr = *hPtr->bucketPtr;
	    *hPtr->bucketPtr = hPtr;
	}
    }

    /*
     * Free up the old bucket array, if it was dynamically allocated.
     */

    if (oldBuckets != tablePtr->staticBuckets) {
	ckfree(memoryp, (char *) oldBuckets);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
movl 0x28(%rsi), %r12d
movq (%rsi), %r14
leal (,%r12,4), %eax
movl %eax, 0x28(%rsi)
movl %r12d, %esi
shll $0x5, %esi
leaq 0x6a92(%rip), %rdx      # 0x1445e
movl $0x38f, %ecx            # imm = 0x38F
callq 0x44d0
movq %rax, (%r15)
movslq 0x28(%r15), %rdx
testq %rdx, %rdx
jle 0xd9f0
shlq $0x3, %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x42b0
shll $0x2, 0x30(%r15)
movl 0x34(%r15), %ecx
movl 0x38(%r15), %eax
addl $-0x2, %ecx
movl %ecx, 0x34(%r15)
leal 0x3(,%rax,4), %eax
movl %eax, 0x38(%r15)
testl %r12d, %r12d
jle 0xdae4
movl %ecx, %ecx
movq %r14, %rdx
movq (%rdx), %rsi
testq %rsi, %rsi
je 0xdace
movl 0x3c(%r15), %edi
leal 0x1(%rdi), %r8d
movq (%rsi), %r9
movq %r9, (%rdx)
cmpl $0x1, %edi
je 0xda68
testl %edi, %edi
jne 0xda72
movb 0x20(%rsi), %r11b
testb %r11b, %r11b
je 0xda9d
leaq 0x21(%rsi), %r10
xorl %r9d, %r9d
movsbl %r11b, %r11d
leal (%r9,%r9,8), %r9d
addl %r11d, %r9d
movb (%r10), %r11b
incq %r10
testb %r11b, %r11b
jne 0xda50
jmp 0xdaa8
imulq $0x41c64e6d, 0x20(%rsi), %r9 # imm = 0x41C64E6D
jmp 0xdaa5
jle 0xdaa2
leaq 0x20(%rsi), %r10
xorl %r9d, %r9d
movl %r8d, %r11d
movslq (%r10), %r13
movslq %r9d, %r9
addq %r13, %r9
addq $0x4, %r10
decl %r11d
cmpl $0x1, %r11d
ja 0xda7e
imulq $0x41c64e6d, %r9, %r9   # imm = 0x41C64E6D
jmp 0xdaa5
xorl %r9d, %r9d
jmp 0xdaa8
xorl %r9d, %r9d
sarq %cl, %r9
andl %eax, %r9d
movq (%r15), %r10
movslq %r9d, %r9
leaq (%r10,%r9,8), %r9
movq %r9, 0x10(%rsi)
movq (%r9), %r10
movq %r10, (%rsi)
movq %rsi, (%r9)
movq (%rdx), %rsi
testq %rsi, %rsi
jne 0xda31
leal -0x1(%r12), %esi
addq $0x8, %rdx
cmpl $0x1, %r12d
movl %esi, %r12d
jg 0xda1d
addq $0x8, %r15
cmpq %r15, %r14
je 0xdb0d
leaq 0x696a(%rip), %rdx      # 0x1445e
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3b8, %ecx            # imm = 0x3B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x4280
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop