// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqlitePagerAcquire
static int unqlitePagerAcquire(
  Pager *pPager,      /* The pager open on the database file */
  pgno pgno,          /* Page number to fetch */
  unqlite_page **ppPage,    /* OUT: Acquired page */
  int fetchOnly,      /* Cache lookup only */
  int noContent       /* Do not bother reading content from disk if true */
)
{
	Page *pPage;
	int rc;
	/* Acquire a shared lock (if not yet done) on the database and rollback any hot-journal if present */
	rc = pager_shared_lock(pPager);
	if( rc != UNQLITE_OK ){
		return rc;
	}
	/* Fetch the page from the cache */
	pPage = pager_fetch_page(pPager,pgno);
	if( fetchOnly ){
		if( ppPage ){
			*ppPage = (unqlite_page *)pPage;
		}
		return pPage ? UNQLITE_OK : UNQLITE_NOTFOUND;
	}
	if( pPage == 0 ){
		/* Allocate a new page */
		pPage = pager_alloc_page(pPager,pgno);
		if( pPage == 0 ){
			unqliteGenOutofMem(pPager->pDb);
			return UNQLITE_NOMEM;
		}
		/* Read page contents */
		rc = pager_get_page_contents(pPager,pPage,noContent);
		if( rc != UNQLITE_OK ){
			SyMemBackendPoolFree(pPager->pAllocator,pPage);
			return rc;
		}
		/* Link the page */
		pager_link_page(pPager,pPage);
	}else{
		if( ppPage ){
			page_ref(pPage);
		}
	}
	/* All done, page is loaded in memeory */
	if( ppPage ){
		*ppPage = (unqlite_page *)pPage;
	}
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r14
callq 0x3b5ca
movl %eax, %r12d
testl %eax, %eax
jne 0x3b5a4
movq %r15, -0x30(%rbp)
cmpl $0x0, 0x254(%r14)
je 0x3b47d
movq 0x248(%r14), %rax
movl 0x250(%r14), %ecx
decl %ecx
movl %r13d, %edx
andl %ecx, %edx
movq (%rax,%rdx,8), %r15
testq %r15, %r15
je 0x3b47d
cmpq %r13, 0x10(%r15)
je 0x3b480
movq 0x48(%r15), %r15
jmp 0x3b46c
xorl %r15d, %r15d
testl %ebx, %ebx
je 0x3b4a4
movq -0x30(%rbp), %rax
testq %rax, %rax
je 0x3b490
movq %r15, (%rax)
xorl %eax, %eax
testq %r15, %r15
movl $0xfffffffa, %r12d      # imm = 0xFFFFFFFA
cmovnel %eax, %r12d
jmp 0x3b5a4
testq %r15, %r15
je 0x3b4ca
movq -0x30(%rbp), %rax
testq %rax, %rax
je 0x3b4b6
incl 0x24(%r15)
xorl %r12d, %r12d
testq %rax, %rax
je 0x3b5a4
movq %r15, (%rax)
jmp 0x3b5a4
movq %r14, %rdi
movq %r13, %rsi
callq 0x3bb57
testq %rax, %rax
je 0x3b561
movq %rax, %r15
cmpl $0x0, 0x1fc(%r14)
jne 0x3b51e
movq 0x10(%r15), %rcx
cmpq 0x40(%r14), %rcx
jae 0x3b51e
testb $0x1, 0x16d(%r14)
je 0x3b579
movq 0x58(%r14), %rax
testq %rax, %rax
je 0x3b579
movslq 0x208(%r14), %rdx
imulq %rdx, %rcx
addq %rcx, %rax
movq %rax, (%r15)
xorl %r12d, %r12d
jmp 0x3b594
movl 0x208(%r14), %eax
xorl %r12d, %r12d
testq %rax, %rax
je 0x3b594
movq (%r15), %rcx
addq %rcx, %rax
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x3b594
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x3b594
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x3b594
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jb 0x3b533
jmp 0x3b594
movq 0x8(%r14), %rdi
leaq 0x3a462(%rip), %rsi     # 0x759ce
callq 0x31af5
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x3b5a4
movq 0x30(%r14), %rdi
movq (%r15), %rsi
movslq 0x208(%r14), %rdx
imulq %rdx, %rcx
movq (%rdi), %rax
callq *0x10(%rax)
movl %eax, %r12d
testl %r12d, %r12d
je 0x3b5b6
movq (%r14), %rdi
movq %r15, %rsi
callq 0x2eb38
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r15, %rsi
callq 0x3bbdb
movq -0x30(%rbp), %rax
jmp 0x3b4b6