// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: lhInstallCell
static int lhInstallCell(lhcell *pCell)
{
	lhpage *pPage = pCell->pPage->pMaster;
	sxu32 iBucket;
	if( pPage->nCell < 1 ){
		sxu32 nTableSize = 32; /* Must be a power of two */
		lhcell **apTable;
		/* Allocate a new cell table */
		apTable = (lhcell **)SyMemBackendAlloc(&pPage->pHash->sAllocator, nTableSize * sizeof(lhcell *));
		if( apTable == 0 ){
			return UNQLITE_NOMEM;
		}
		/* Zero the new table */
		SyZero((void *)apTable, nTableSize * sizeof(lhcell *));
		/* Install it */
		pPage->apCell = apTable;
		pPage->nCellSize = nTableSize;
	}
	iBucket = pCell->nHash & (pPage->nCellSize - 1);
	pCell->pNextCol = pPage->apCell[iBucket];
	if( pPage->apCell[iBucket] ){
		pPage->apCell[iBucket]->pPrevCol = pCell;
	}
	pPage->apCell[iBucket] = pCell;
	if( pPage->pFirst == 0 ){
		pPage->pFirst = pPage->pList = pCell;
	}else{
		MACRO_LD_PUSH(pPage->pList,pCell);
	}
	pPage->nCell++;
	if( (pPage->nCell >= pPage->nCellSize * 3) && pPage->nCell < 100000 ){
		/* Allocate a new larger table */
		sxu32 nNewSize = pPage->nCellSize << 1;
		lhcell *pEntry;
		lhcell **apNew;
		sxu32 n;
		
		apNew = (lhcell **)SyMemBackendAlloc(&pPage->pHash->sAllocator, nNewSize * sizeof(lhcell *));
		if( apNew ){
			/* Zero the new table */
			SyZero((void *)apNew, nNewSize * sizeof(lhcell *));
			/* Rehash all entries */
			n = 0;
			pEntry = pPage->pList;
			for(;;){
				/* Loop one */
				if( n >= pPage->nCell ){
					break;
				}
				pEntry->pNextCol = pEntry->pPrevCol = 0;
				/* Install in the new bucket */
				iBucket = pEntry->nHash & (nNewSize - 1);
				pEntry->pNextCol = apNew[iBucket];
				if( apNew[iBucket]  ){
					apNew[iBucket]->pPrevCol = pEntry;
				}
				apNew[iBucket] = pEntry;
				/* Point to the next entry */
				pEntry = pEntry->pNext;
				n++;
			}
			/* Release the old table and reflect the change */
			SyMemBackendFree(&pPage->pHash->sAllocator,(void *)pPage->apCell);
			pPage->apCell = apNew;
			pPage->nCellSize  = nNewSize;
		}
	}
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x40(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x38(%rax)
jae 0x64185
movl $0x20, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
movl -0x20(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x5bf70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x6415d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x643b1
movq -0x28(%rbp), %rdi
movl -0x20(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x54280
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
movl 0x3c(%rcx), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x641da
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %edx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x6420e
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x64255
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x64227
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0x64253
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rcx, 0x68(%rax)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0x64255
movq -0x18(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
movq -0x18(%rbp), %rax
movl 0x38(%rax), %eax
movq -0x18(%rbp), %rcx
imull $0x3, 0x3c(%rcx), %ecx
cmpl %ecx, %eax
jb 0x643aa
movq -0x18(%rbp), %rax
cmpl $0x186a0, 0x38(%rax)    # imm = 0x186A0
jae 0x643aa
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %eax
shll %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
movl -0x2c(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x5bf70
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x643a8
movq -0x40(%rbp), %rdi
movl -0x2c(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x54280
movl $0x0, -0x44(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x44(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x38(%rcx), %eax
jb 0x642f4
jmp 0x6437a
movq -0x38(%rbp), %rax
movq $0x0, 0x78(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x70(%rax)
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x64351
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %edx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x78(%rax)
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x38(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x642e3
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x5d6b0
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x2c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x3c(%rax)
jmp 0x643aa
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)