// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rdi, %r14
movq (%rdi), %rax
movq (%rax), %rdi
leaq -0x78(%rbp), %rdx
callq *0x10(%rax)
movl %eax, %r13d
testl %eax, %eax
jne 0x385b8
movq -0x78(%rbp), %rsi
movq 0x8(%rsi), %r8
testq %r8, %r8
je 0x3838e
xorl %r13d, %r13d
testq %r15, %r15
je 0x385b8
movq %r8, (%r15)
jmp 0x385b8
movq %r14, %rdi
movq %r12, %rdx
callq 0x37e75
testq %rax, %rax
je 0x3841c
movq 0x8(%rax), %rcx
movq (%rcx), %rdi
movzwl (%rdi), %ecx
rolw $0x8, %cx
movw %cx, 0x10(%rax)
movzwl 0x2(%rdi), %ecx
rolw $0x8, %cx
movw %cx, 0x12(%rax)
addq $0x4, %rdi
leaq 0x18(%rax), %r13
movq %r13, %rsi
movq %rax, -0x38(%rbp)
callq 0x36f8d
movq -0x38(%rbp), %r8
movq 0x8(%r8), %rdi
movq (%rdi), %rbx
movzwl 0x12(%r8), %edx
testq %rdx, %rdx
je 0x38427
movq (%r8), %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 0x3843b
movzwl %si, %edx
cmpq %rcx, %rdx
jl 0x383f1
movl $0xffffffe8, %r13d      # imm = 0xFFFFFFE8
jmp 0x385b2
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x385b8
movq %r13, -0x60(%rbp)
movq %r12, -0x58(%rbp)
movq %r15, -0x40(%rbp)
movq %r14, -0x48(%rbp)
xorl %eax, %eax
jmp 0x3844b
movq %r13, -0x60(%rbp)
movq %r12, -0x58(%rbp)
movq %r15, -0x40(%rbp)
movq %r14, -0x48(%rbp)
movw %ax, 0x5c(%r8)
movzwl 0x10(%r8), %r12d
testq %r12, %r12
je 0x38574
addq %rbx, %r12
movq (%r8), %rax
movslq 0x110(%rax), %rax
addq %r12, %rax
movq %rax, -0x68(%rbp)
movl (%r12), %r15d
movl 0x4(%r12), %edx
movq 0x8(%r12), %rsi
movzwl 0x10(%r12), %edi
rolw $0x8, %di
movl $0xffffffe8, %r13d      # imm = 0xFFFFFFE8
testw %di, %di
je 0x384a5
movzwl %di, %eax
addq %rbx, %rax
cmpq -0x68(%rbp), %rax
jae 0x385aa
movw %di, -0x2a(%rbp)
movq %rsi, -0x70(%rbp)
movl %edx, -0x4c(%rbp)
movq (%r8), %rdi
movq %r8, %rsi
callq 0x38981
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x385a6
movq %rax, %r14
movl %r12d, %eax
subl %ebx, %eax
movl %eax, %ebx
bswapl %r15d
movl -0x4c(%rbp), %eax
bswapl %eax
movq -0x70(%rbp), %rcx
bswapq %rcx
addq $0x12, %r12
movzwl -0x2a(%rbp), %edx
movw %dx, 0x10(%r14)
movl %eax, 0x4(%r14)
movq %rcx, 0x8(%r14)
movl %r15d, (%r14)
leaq 0x18(%r14), %rsi
movq %r12, %rdi
callq 0x36f8d
movw %bx, 0x28(%r14)
movq %r14, %r12
addq $0x40, %r12
xorl %ecx, %ecx
cmpl $0x40001, 0x4(%r14)     # imm = 0x40001
setae %cl
movq %r14, %rdi
leaq -0x6803(%rip), %rsi     # 0x31d27
movq %r12, %rdx
callq 0x39132
testl %eax, %eax
je 0x3853e
movq %r12, %rdi
callq 0x317be
movq %r14, %rdi
callq 0x389d8
testl %eax, %eax
movq -0x38(%rbp), %r8
jne 0x385aa
movzwl 0x10(%r14), %r12d
testq %r12, %r12
je 0x38574
movq 0x8(%r8), %rax
movq (%rax), %rbx
addq %rbx, %r12
movl $0xffffffe8, %r13d      # imm = 0xFFFFFFE8
cmpq -0x68(%rbp), %r12
jb 0x38472
jmp 0x385aa
movq -0x60(%rbp), %rax
movq (%rax), %rsi
testq %rsi, %rsi
je 0x3859d
movq -0x58(%rbp), %rax
testq %rax, %rax
cmovneq %rax, %r8
movq -0x48(%rbp), %rdi
movq %r8, %rdx
xorl %ecx, %ecx
callq 0x3833b
movq -0x38(%rbp), %r8
movq -0x40(%rbp), %r15
jmp 0x3837a
movq -0x38(%rbp), %r8
movq 0x8(%r8), %rdi
movq -0x48(%rbp), %r14
movq (%r14), %rax
callq *0x50(%rax)
movl %r13d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq