// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movq %rdx, %r12
movq %rdi, %r14
movq (%rdi), %rax
movq (%rax), %rdi
leaq -0x78(%rbp), %rdx
callq *0x10(%rax)
movl %eax, %r15d
testl %eax, %eax
jne 0x38df8
movq -0x78(%rbp), %rsi
movq 0x8(%rsi), %r8
testq %r8, %r8
je 0x38bd9
xorl %r15d, %r15d
testq %rbx, %rbx
je 0x38df8
movq %r8, (%rbx)
jmp 0x38df8
movq %r14, %rdi
movq %r12, %rdx
callq 0x386a2
testq %rax, %rax
je 0x38dda
movq %r12, -0x60(%rbp)
movq %r14, -0x48(%rbp)
movq %rbx, -0x40(%rbp)
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), %rsi
movq %rsi, -0x68(%rbp)
movq %rax, -0x30(%rbp)
callq 0x376e7
movq -0x30(%rbp), %r8
movq 0x8(%r8), %rax
movq (%rax), %r13
movzwl 0x12(%r8), %edx
xorl %eax, %eax
testq %rdx, %rdx
je 0x38c7f
movq (%r8), %rcx
movslq 0x110(%rcx), %rcx
movzwl (%r13,%rdx), %esi
movzwl 0x2(%r13,%rdx), %edx
rolw $0x8, %si
rolw $0x8, %dx
movl %eax, %edi
movzwl %dx, %eax
addl %edi, %eax
testw %si, %si
je 0x38c7f
movzwl %si, %edx
cmpq %rcx, %rdx
jl 0x38c4d
movl $0xffffffe8, %r15d      # imm = 0xFFFFFFE8
xorl %eax, %eax
jmp 0x38c89
movw %ax, 0x5c(%r8)
xorl %r15d, %r15d
movb $0x1, %al
testb %al, %al
je 0x38de5
movzwl 0x10(%r8), %eax
testq %rax, %rax
je 0x38de2
addq %rax, %r13
movq (%r8), %rax
movslq 0x110(%rax), %rcx
addq %r13, %rcx
xorl %edx, %edx
movq %rcx, -0x50(%rbp)
movq 0x8(%r8), %rax
movq (%rax), %r12
movl (%r13), %esi
movl 0x4(%r13), %edi
movq 0x8(%r13), %r9
movzwl 0x10(%r13), %r14d
rolw $0x8, %r14w
testw %r14w, %r14w
je 0x38cee
movzwl %r14w, %eax
addq %r12, %rax
movl $0xffffffe8, %r15d      # imm = 0xFFFFFFE8
cmpq %rcx, %rax
jae 0x38db3
movq %r9, -0x70(%rbp)
movl %edi, -0x34(%rbp)
movl %esi, -0x38(%rbp)
movq %rdx, -0x58(%rbp)
movq (%r8), %rdi
movq %r8, %rsi
callq 0x3921c
testq %rax, %rax
je 0x38da1
movq %rax, %rbx
movl %r13d, %r15d
subl %r12d, %r15d
movl -0x38(%rbp), %eax
bswapl %eax
movl -0x34(%rbp), %ecx
bswapl %ecx
movq -0x70(%rbp), %rdx
bswapq %rdx
addq $0x12, %r13
movw %r14w, 0x10(%rbx)
movl %ecx, 0x4(%rbx)
movq %rdx, 0x8(%rbx)
movl %eax, (%rbx)
leaq 0x18(%rbx), %rsi
movq %r13, %rdi
callq 0x376e7
movw %r15w, 0x28(%rbx)
leaq 0x40(%rbx), %r15
xorl %ecx, %ecx
cmpl $0x40001, 0x4(%rbx)     # imm = 0x40001
setae %cl
movq %rbx, %rdi
leaq -0x6a55(%rip), %rsi     # 0x32312
movq %r15, %rdx
callq 0x39a56
testl %eax, %eax
je 0x38d7b
movq %r15, %rdi
callq 0x31d8f
movq %rbx, %rdi
callq 0x39277
xorl %r15d, %r15d
testl %eax, %eax
setne %r15b
movq -0x58(%rbp), %rdx
cmoveq %rbx, %rdx
negl %r15d
movq -0x30(%rbp), %r8
movq -0x50(%rbp), %rcx
jmp 0x38db3
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq -0x30(%rbp), %r8
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rdx
testl %r15d, %r15d
jne 0x38de5
movzwl 0x10(%rdx), %r13d
testq %r13, %r13
je 0x38de2
movq 0x8(%r8), %rax
addq (%rax), %r13
cmpq %rcx, %r13
jb 0x38cb5
movl $0xffffffe8, %r15d      # imm = 0xFFFFFFE8
jmp 0x38de5
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x38df8
xorl %r15d, %r15d
testl %r15d, %r15d
je 0x38e0a
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq 0x8(%r8), %rdi
callq *0x50(%rax)
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x68(%rbp), %rax
movq (%rax), %rsi
testq %rsi, %rsi
movq -0x48(%rbp), %rdi
je 0x38e33
movq -0x60(%rbp), %rax
testq %rax, %rax
cmovneq %rax, %r8
movq %r8, %rdx
xorl %ecx, %ecx
callq 0x38b86
movq -0x30(%rbp), %r8
movq -0x40(%rbp), %rbx
jmp 0x38bc5