// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: pager_link_page
static int pager_link_page(Pager *pPager,Page *pPage)
{
	sxu32 nBucket;
	/* Install in the corresponding bucket */
	nBucket = PAGE_HASH(pPage->iPage) & (pPager->nSize - 1);
	pPage->pNextCollide = pPager->apHash[nBucket];
	if( pPager->apHash[nBucket] ){
		pPager->apHash[nBucket]->pPrevCollide = pPage;
	}
	pPager->apHash[nBucket] = pPage;
	/* Link to the list of active pages */
	MACRO_LD_PUSH(pPager->pAll,pPage);
	pPager->nPage++;
	if( (pPager->nPage >= pPager->nSize * 4)  && pPager->nPage < 100000 ){
		/* Grow the hashtable */
		sxu32 nNewSize = pPager->nSize << 1;
		Page *pEntry,**apNew;
		sxu32 n;
		apNew = (Page **)SyMemBackendAlloc(pPager->pAllocator, nNewSize * sizeof(Page *));
		if( apNew ){
			sxu32 iBucket;
			/* Zero the new table */
			SyZero((void *)apNew, nNewSize * sizeof(Page *));
			/* Rehash all entries */
			n = 0;
			pEntry = pPager->pAll;
			for(;;){
				/* Loop one */
				if( n >= pPager->nPage ){
					break;
				}
				pEntry->pNextCollide = pEntry->pPrevCollide = 0;
				/* Install in the new bucket */
				iBucket = PAGE_HASH(pEntry->iPage) & (nNewSize - 1);
				pEntry->pNextCollide = apNew[iBucket];
				if( apNew[iBucket] ){
					apNew[iBucket]->pPrevCollide = pEntry;
				}
				apNew[iBucket] = pEntry;
				/* Point to the next entry */
				pEntry = pEntry->pNext;
				n++;
			}
			/* Release the old table and reflect the change */
			SyMemBackendFree(pPager->pAllocator,(void *)pPager->apHash);
			pPager->apHash = apNew;
			pPager->nSize  = nNewSize;
		}
	}
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x250(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
andq %rcx, %rax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x248(%rax), %rax
movl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x8(%rbp), %rax
movq 0x248(%rax), %rax
movl -0x14(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x68bd6
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x248(%rax), %rax
movl -0x14(%rbp), %edx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x248(%rax), %rax
movl -0x14(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x228(%rax)
jne 0x68c0b
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x228(%rax)
jmp 0x68c40
movq -0x8(%rbp), %rax
movq 0x228(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x228(%rax), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x228(%rax)
movq -0x8(%rbp), %rax
movl 0x254(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x254(%rax)
movq -0x8(%rbp), %rax
movl 0x254(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x250(%rcx), %ecx
shll $0x2, %ecx
cmpl %ecx, %eax
jb 0x68db5
movq -0x8(%rbp), %rax
cmpl $0x186a0, 0x254(%rax)   # imm = 0x186A0
jae 0x68db5
movq -0x8(%rbp), %rax
movl 0x250(%rax), %eax
shll %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0x18(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x5bf70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x68db3
movq -0x28(%rbp), %rdi
movl -0x18(%rbp), %eax
shlq $0x3, %rax
movl %eax, %esi
callq 0x54280
movl $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq 0x228(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x254(%rcx), %eax
jb 0x68cf5
jmp 0x68d80
movq -0x20(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
andq %rcx, %rax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x68d57
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %edx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x50(%rax)
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x68ce1
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x248(%rax), %rsi
callq 0x5d6b0
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x248(%rax)
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x250(%rax)
jmp 0x68db5
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)