// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: HashmapGrowBucket
static sxi32 HashmapGrowBucket(jx9_hashmap *pMap)
{
	if( pMap->nEntry >= pMap->nSize * HASHMAP_FILL_FACTOR ){
		jx9_hashmap_node **apOld = pMap->apBucket;
		jx9_hashmap_node *pEntry, **apNew;
		sxu32 nNew = pMap->nSize << 1;
		sxu32 nBucket;
		sxu32 n;
		if( nNew < 1 ){
			nNew = 16;
		}
		/* Allocate a new bucket */
		apNew = (jx9_hashmap_node **)SyMemBackendAlloc(&pMap->pVm->sAllocator, nNew * sizeof(jx9_hashmap_node *));
		if( apNew == 0 ){
			if( pMap->nSize < 1 ){
				return SXERR_MEM; /* Fatal */
			}
			/* Not so fatal here, simply a performance hit */
			return SXRET_OK;
		}
		/* Zero the table */
		SyZero((void *)apNew, nNew * sizeof(jx9_hashmap_node *));
		/* Reflect the change */
		pMap->apBucket = apNew;
		pMap->nSize = nNew;
		if( apOld == 0 ){
			/* First allocated table [i.e: no entry], return immediately */
			return SXRET_OK;
		}
		/* Rehash old entries */
		pEntry = pMap->pFirst;
		n = 0;
		for( ;; ){
			if( n >= pMap->nEntry ){
				break;
			}
			/* Clear the old collision link */
			pEntry->pNextCollide = pEntry->pPrevCollide = 0;
			/* Link to the new bucket */
			nBucket = pEntry->nHash & (nNew - 1);
			if( pMap->apBucket[nBucket] != 0 ){
				pEntry->pNextCollide = pMap->apBucket[nBucket];
				pMap->apBucket[nBucket]->pPrevCollide = pEntry;
			}
			pMap->apBucket[nBucket] = pEntry;
			/* Point to the next entry */
			pEntry = pEntry->pPrev; /* Reverse link */
			n++;
		}
		/* Free the old table */
		SyMemBackendFree(&pMap->pVm->sAllocator, (void *)apOld);
	}
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x10(%rbp), %rcx
imull $0x3, 0x28(%rcx), %ecx
cmpl %ecx, %eax
jb 0x70d40
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x28(%rax), %eax
shll %eax
movl %eax, -0x2c(%rbp)
cmpl $0x1, -0x2c(%rbp)
jae 0x70bf8
movl $0x10, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x2c(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x5bf70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x70c3a
movq -0x10(%rbp), %rax
cmpl $0x1, 0x28(%rax)
jae 0x70c2e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x70d47
movl $0x0, -0x4(%rbp)
jmp 0x70d47
movq -0x28(%rbp), %rdi
movl -0x2c(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x54280
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
cmpq $0x0, -0x18(%rbp)
jne 0x70c75
movl $0x0, -0x4(%rbp)
jmp 0x70d47
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
jb 0x70c99
jmp 0x70d30
movq -0x20(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x20(%rbp), %rax
movl 0x34(%rax), %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x70d03
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %edx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x58(%rax)
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x70c88
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x5d6b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq