// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: lhLoadPage
static int lhLoadPage(lhash_kv_engine *pEngine,pgno pnum,lhpage *pMaster,lhpage **ppOut,int iNest)
{
	unqlite_page *pRaw;
	lhpage *pPage = 0; /* cc warning */
	int rc;
	/* Aquire the page from the pager first */
	rc = pEngine->pIo->xGet(pEngine->pIo->pHandle,pnum,&pRaw);
	if( rc != UNQLITE_OK ){
		return rc;
	}
	if( pRaw->pUserData ){
		/* The page is already parsed and loaded in memory. Point to it */
		pPage = (lhpage *)pRaw->pUserData;
	}else{
		/* Allocate a new page */
		pPage = lhNewPage(pEngine,pRaw,pMaster);
		if( pPage == 0 ){
			return UNQLITE_NOMEM;
		}
		/* Process the page */
		rc = lhParsePageHeader(pPage);
		if( rc == UNQLITE_OK ){
			/* Load cells */
			rc = lhLoadCells(pPage);
		}
		if( rc != UNQLITE_OK ){
			pEngine->pIo->xPageUnref(pPage->pRaw); /* pPage will be released inside this call */
			return rc;
		}
		if( pPage->sHdr.iSlave > 0 && iNest < 128 ){
			if( pMaster == 0 ){
				pMaster = pPage;
			}
			/* Slave page. Not a fatal error if something goes wrong here */
			lhLoadPage(pEngine,pPage->sHdr.iSlave,pMaster,0,iNest++);
		}
	}
	if( ppOut ){
		*ppOut = pPage;
	}
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rdi, %r14
movq (%rdi), %rax
movq (%rax), %rdi
leaq -0x68(%rbp), %rdx
callq *0x10(%rax)
movl %eax, %ebx
testl %eax, %eax
jne 0x30dcb
movq -0x68(%rbp), %rsi
movq 0x8(%rsi), %r13
testq %r13, %r13
je 0x30ba1
xorl %ebx, %ebx
testq %r15, %r15
je 0x30dcb
movq %r13, (%r15)
jmp 0x30dcb
movq %r14, %rdi
movq %r12, %rdx
callq 0x306e9
testq %rax, %rax
je 0x30c2f
movq %rax, %r13
movq 0x8(%rax), %rax
movq (%rax), %rdi
movzwl (%rdi), %eax
rolw $0x8, %ax
movw %ax, 0x10(%r13)
movzwl 0x2(%rdi), %eax
rolw $0x8, %ax
movw %ax, 0x12(%r13)
addq $0x4, %rdi
leaq 0x18(%r13), %rsi
movq %rsi, -0x60(%rbp)
callq 0x2f685
movq 0x8(%r13), %rdi
movq (%rdi), %rbx
movzwl 0x12(%r13), %edx
testq %rdx, %rdx
je 0x30c37
pushq $-0x18
popq %r8
movq (%r13), %rax
movslq 0x110(%rax), %rcx
xorl %eax, %eax
movzwl (%rbx,%rdx), %esi
movzwl 0x2(%rbx,%rdx), %edx
rolw $0x8, %si
rolw $0x8, %dx
addl %edx, %eax
testw %si, %si
je 0x30c47
movzwl %si, %edx
cmpq %rcx, %rdx
jl 0x30c07
movl %r8d, %ebx
jmp 0x30dc5
pushq $-0x1
popq %rbx
jmp 0x30dcb
movq %r12, -0x48(%rbp)
movq %r15, -0x38(%rbp)
movq %r14, -0x30(%rbp)
xorl %eax, %eax
jmp 0x30c53
movq %r12, -0x48(%rbp)
movq %r15, -0x38(%rbp)
movq %r14, -0x30(%rbp)
movw %ax, 0x5c(%r13)
movzwl 0x10(%r13), %r12d
testq %r12, %r12
je 0x30d7f
addq %rbx, %r12
movq (%r13), %rax
movslq 0x110(%rax), %rax
addq %r12, %rax
movq %rax, -0x58(%rbp)
movq %r13, -0x50(%rbp)
movq %r12, %rdi
leaq -0x40(%rbp), %rsi
callq 0x2f679
leaq 0x4(%r12), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x2f679
leaq 0x8(%r12), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2f685
movzwl 0x10(%r12), %r15d
rolw $0x8, %r15w
testw %r15w, %r15w
je 0x30cc9
movzwl %r15w, %eax
addq %rbx, %rax
cmpq -0x58(%rbp), %rax
jae 0x30dad
movq (%r13), %rdi
movq %r13, %rsi
callq 0x31189
testq %rax, %rax
je 0x30db1
movq %rax, %r14
movl %r12d, %r13d
subl %ebx, %r13d
addq $0x12, %r12
movw %r15w, 0x10(%rax)
movl -0x3c(%rbp), %eax
movl %eax, 0x4(%r14)
movq -0x70(%rbp), %rax
movq %rax, 0x8(%r14)
movl -0x40(%rbp), %eax
movl %eax, (%r14)
leaq 0x18(%r14), %rsi
movq %r12, %rdi
callq 0x2f685
movw %r13w, 0x28(%r14)
movq %r14, %r12
addq $0x40, %r12
xorl %ecx, %ecx
cmpl $0x40001, 0x4(%r14)     # imm = 0x40001
setae %cl
movq %r14, %rdi
leaq -0x61ab(%rip), %rsi     # 0x2ab89
movq %r12, %rdx
callq 0x31968
testl %eax, %eax
je 0x30d48
movq %r12, %rdi
callq 0x2a72f
movq %r14, %rdi
callq 0x311e2
testl %eax, %eax
jne 0x30db6
movzwl 0x10(%r14), %r12d
testq %r12, %r12
movq -0x50(%rbp), %r13
je 0x30d7f
movq 0x8(%r13), %rdi
movq (%rdi), %rbx
addq %rbx, %r12
cmpq -0x58(%rbp), %r12
jb 0x30c7f
movq -0x30(%rbp), %r14
pushq $-0x18
popq %rbx
jmp 0x30dc5
movq -0x60(%rbp), %rax
movq (%rax), %rsi
testq %rsi, %rsi
je 0x30da4
movq -0x48(%rbp), %rax
testq %rax, %rax
movq %r13, %rdx
cmovneq %rax, %rdx
movq -0x30(%rbp), %rdi
xorl %ecx, %ecx
callq 0x30b50
movq -0x38(%rbp), %r15
jmp 0x30b8e
pushq $-0x18
jmp 0x30db3
pushq $-0x1
popq %rbx
jmp 0x30dbd
pushq $-0x1
popq %rbx
movq -0x50(%rbp), %r13
movq 0x8(%r13), %rdi
movq -0x30(%rbp), %r14
movq (%r14), %rax
callq *0x50(%rax)
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq