// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: lhRecordLookup
static int lhRecordLookup(
	lhash_kv_engine *pEngine, /* KV storage engine */
	const void *pKey,         /* Lookup key */
	sxu32 nByte,              /* Key length */
	lhcell **ppCell           /* OUT: Target cell on success */
	)
{
	lhash_bmap_rec *pRec;
	lhpage *pPage;
	lhcell *pCell;
	pgno iBucket;
	sxu32 nHash;
	int rc;
	/* Acquire the first page (hash Header) so that everything gets loaded autmatically */
	rc = pEngine->pIo->xGet(pEngine->pIo->pHandle,1,0);
	if( rc != UNQLITE_OK ){
		return rc;
	}
	/* Compute the hash of the key first */
	nHash = pEngine->xHash(pKey,nByte);
	/* Extract the logical (i.e. not real) page number */
	iBucket = nHash & (pEngine->nmax_split_nucket - 1);
	if( iBucket >= (pEngine->split_bucket + pEngine->max_split_bucket) ){
		/* Low mask */
		iBucket = nHash & (pEngine->max_split_bucket - 1);
	}
	/* Map the logical bucket number to real page number */
	pRec = lhMapFindBucket(pEngine,iBucket);
	if( pRec == 0 ){
		/* No such entry */
		return UNQLITE_NOTFOUND;
	}
	/* Load the master page and it's slave page in-memory  */
	rc = lhLoadPage(pEngine,pRec->iReal,0,&pPage,0);
	if( rc != UNQLITE_OK ){
		/* IO error, unlikely scenario */
		return rc;
	}
	/* Lookup for the cell */
	pCell = lhFindCell(pPage,pKey,nByte,nHash);
	if( pCell == 0 ){
		/* No such entry */
		return UNQLITE_NOTFOUND;
	}
	if( ppCell ){
		*ppCell = pCell;
	}
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rdi
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x6656b
movl -0x50(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x66661
movq -0x10(%rbp), %rax
movq 0xc0(%rax), %rax
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq *%rax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x130(%rcx), %rcx
subq $0x1, %rcx
andq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x120(%rcx), %rcx
movq -0x10(%rbp), %rdx
addq 0x128(%rdx), %rcx
cmpq %rcx, %rax
jb 0x665d3
movl -0x4c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x128(%rcx), %rcx
subq $0x1, %rcx
andq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x62520
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x665f4
movl $0xfffffffa, -0x4(%rbp) # imm = 0xFFFFFFFA
jmp 0x66661
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x38(%rbp), %rcx
xorl %r8d, %r8d
callq 0x62dc0
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x66621
movl -0x50(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x66661
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x4c(%rbp), %ecx
callq 0x62f10
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x66648
movl $0xfffffffa, -0x4(%rbp) # imm = 0xFFFFFFFA
jmp 0x66661
cmpq $0x0, -0x28(%rbp)
je 0x6665a
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)