// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq 0x280(%rdi), %rdi
movl 0x28(%rsi), %r13d
movq (%rsi), %r14
leal (,%r13,4), %eax
movl %eax, 0x28(%rsi)
movl %r13d, %esi
shll $0x5, %esi
leaq 0x6620(%rip), %rdx      # 0x1345e
movq %rdi, 0x8(%rsp)
movl $0x38f, %ecx            # imm = 0x38F
callq 0x44e0
movq %rax, (%r15)
movl 0x28(%r15), %ecx
testl %ecx, %ecx
jle 0xce64
andq $0x0, (%rax)
decl %ecx
addq $0x8, %rax
jmp 0xce54
shll $0x2, 0x30(%r15)
movl 0x34(%r15), %r12d
movl 0x38(%r15), %eax
addl $-0x2, %r12d
movl %r12d, 0x34(%r15)
leal 0x3(,%rax,4), %ebp
movl %ebp, 0x38(%r15)
movq %r14, 0x10(%rsp)
testl %r13d, %r13d
jle 0xcf00
movq (%r14), %rbx
testq %rbx, %rbx
je 0xcef7
movq (%rbx), %rax
movq %rax, (%r14)
movl 0x3c(%r15), %eax
leaq 0x20(%rbx), %rdi
testl %eax, %eax
je 0xceb6
cmpl $0x1, %eax
jne 0xcebd
imulq $0x41c64e6d, (%rdi), %rax # imm = 0x41C64E6D
jmp 0xced7
callq 0xcdf3
jmp 0xcedd
xorl %ecx, %ecx
testl %eax, %eax
jle 0xcecd
addl (%rdi), %ecx
decl %eax
addq $0x4, %rdi
jmp 0xcebf
movslq %ecx, %rax
imulq $0x41c64e6d, %rax, %rax # imm = 0x41C64E6D
movl %r12d, %ecx
sarq %cl, %rax
andl %ebp, %eax
movq (%r15), %rcx
cltq
leaq (%rcx,%rax,8), %rax
movq %rax, 0x10(%rbx)
movq (%rax), %rcx
movq %rcx, (%rbx)
movq %rbx, (%rax)
jmp 0xce8e
decl %r13d
addq $0x8, %r14
jmp 0xce89
addq $0x8, %r15
movq 0x10(%rsp), %rsi
cmpq %r15, %rsi
je 0xcf32
leaq 0x6549(%rip), %rdx      # 0x1345e
movq 0x8(%rsp), %rdi
movl $0x3b8, %ecx            # imm = 0x3B8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4280
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)