// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: MemHashGrowTable
static int MemHashGrowTable(mem_hash_kv_engine *pEngine)
{
	sxu32 nNewSize = pEngine->nBucket << 1;
	mem_hash_record *pEntry;
	mem_hash_record **apNew;
	sxu32 n,iBucket;
	/* Allocate a new larger table */
	apNew = (mem_hash_record **)SyMemBackendAlloc(&pEngine->sAlloc, nNewSize * sizeof(mem_hash_record *));
	if( apNew == 0 ){
		/* Not so fatal, simply a performance hit */
		return UNQLITE_OK;
	}
	/* Zero the new table */
	SyZero((void *)apNew, nNewSize * sizeof(mem_hash_record *));
	/* Rehash all entries */
	n = 0;
	pEntry = pEngine->pLast;
	for(;;){
		
		/* Loop one */
		if( n >= pEngine->nRecord ){
			break;
		}
		pEntry->pNextHash = pEntry->pPrevHash = 0;
		/* Install in the new bucket */
		iBucket = pEntry->nHash & (nNewSize - 1);
		pEntry->pNextHash = apNew[iBucket];
		if( apNew[iBucket] ){
			apNew[iBucket]->pPrevHash = pEntry;
		}
		apNew[iBucket] = pEntry;
		/* Point to the next entry */
		pEntry = pEntry->pNext;
		n++;

		/* Loop two */
		if( n >= pEngine->nRecord ){
			break;
		}
		pEntry->pNextHash = pEntry->pPrevHash = 0;
		/* Install in the new bucket */
		iBucket = pEntry->nHash & (nNewSize - 1);
		pEntry->pNextHash = apNew[iBucket];
		if( apNew[iBucket] ){
			apNew[iBucket]->pPrevHash = pEntry;
		}
		apNew[iBucket] = pEntry;
		/* Point to the next entry */
		pEntry = pEntry->pNext;
		n++;

		/* Loop three */
		if( n >= pEngine->nRecord ){
			break;
		}
		pEntry->pNextHash = pEntry->pPrevHash = 0;
		/* Install in the new bucket */
		iBucket = pEntry->nHash & (nNewSize - 1);
		pEntry->pNextHash = apNew[iBucket];
		if( apNew[iBucket] ){
			apNew[iBucket]->pPrevHash = pEntry;
		}
		apNew[iBucket] = pEntry;
		/* Point to the next entry */
		pEntry = pEntry->pNext;
		n++;

		/* Loop four */
		if( n >= pEngine->nRecord ){
			break;
		}
		pEntry->pNextHash = pEntry->pPrevHash = 0;
		/* Install in the new bucket */
		iBucket = pEntry->nHash & (nNewSize - 1);
		pEntry->pNextHash = apNew[iBucket];
		if( apNew[iBucket] ){
			apNew[iBucket]->pPrevHash = pEntry;
		}
		apNew[iBucket] = pEntry;
		/* Point to the next entry */
		pEntry = pEntry->pNext;
		n++;
	}
	/* Release the old table and reflect the change */
	SyMemBackendFree(&pEngine->sAlloc,(void *)pEngine->apBucket);
	pEngine->apBucket = apNew;
	pEngine->nBucket  = nNewSize;
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0xd4(%rax), %eax
shll %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl -0x14(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x5bf70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x607b8
movl $0x0, -0x4(%rbp)
jmp 0x60a78
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x54280
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xd0(%rcx), %eax
jb 0x607f4
jmp 0x60a3d
movq -0x20(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x60852
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %edx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x48(%rax)
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xd0(%rcx), %eax
jb 0x6088a
jmp 0x60a3d
movq -0x20(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x608e8
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %edx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x48(%rax)
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xd0(%rcx), %eax
jb 0x60920
jmp 0x60a3d
movq -0x20(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x6097e
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %edx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x48(%rax)
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xd0(%rcx), %eax
jb 0x609b6
jmp 0x60a3d
movq -0x20(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x60a14
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %edx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x48(%rax)
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x607e0
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rsi
callq 0x5d6b0
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xd8(%rax)
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xd4(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)