// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqlite_kv_fetch_callback
int unqlite_kv_fetch_callback(unqlite *pDb,const void *pKey,int nKeyLen,int (*xConsumer)(const void *,unsigned int,void *),void *pUserData)
{
	unqlite_kv_methods *pMethods;
	unqlite_kv_engine *pEngine;
	unqlite_kv_cursor *pCur;
	int rc;
	if( UNQLITE_DB_MISUSE(pDb) ){
		return UNQLITE_CORRUPT;
	}
#if defined(UNQLITE_ENABLE_THREADS)
	 /* Acquire DB mutex */
	 SyMutexEnter(sUnqlMPGlobal.pMutexMethods, pDb->pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel != UNQLITE_THREAD_LEVEL_MULTI */
	 if( sUnqlMPGlobal.nThreadingLevel > UNQLITE_THREAD_LEVEL_SINGLE && 
		 UNQLITE_THRD_DB_RELEASE(pDb) ){
			 return UNQLITE_ABORT; /* Another thread have released this instance */
	 }
#endif
	 /* Point to the underlying storage engine */
	 pEngine = unqlitePagerGetKvEngine(pDb);
	 pMethods = pEngine->pIo->pMethods;
	 pCur = pDb->sDB.pCursor;
	 if( nKeyLen < 0 ){
		 /* Assume a null terminated string and compute it's length */
		 nKeyLen = SyStrlen((const char *)pKey);
	 }
	 if( !nKeyLen ){
		 unqliteGenError(pDb,"Empty key");
		 rc = UNQLITE_EMPTY;
	 }else{
		 /* Seek to the record position */
		 rc = pMethods->xSeek(pCur,pKey,nKeyLen,UNQLITE_CURSOR_MATCH_EXACT);
	 }
	 if( rc == UNQLITE_OK && xConsumer ){
		 /* Consume the data directly */
		 rc = pMethods->xData(pCur,xConsumer,pUserData);	 
	 }
#if defined(UNQLITE_ENABLE_THREADS)
	 /* Leave DB mutex */
	 SyMutexLeave(sUnqlMPGlobal.pMutexMethods,pDb->pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel != UNQLITE_THREAD_LEVEL_MULTI */
#endif
	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0xffffffe8, %r14d      # imm = 0xFFFFFFE8
testq %rdi, %rdi
je 0x32473
movq %rdi, %rbx
cmpl $0xdb7c2712, 0x120(%rdi) # imm = 0xDB7C2712
jne 0x32473
movq %rcx, %r15
movl %edx, %r13d
movq %rsi, %r12
movq 0xf8(%rbx), %rdi
testq %rdi, %rdi
je 0x3237f
movq 0x64402(%rip), %rax     # 0x96778
movq %r8, %r14
callq *0x20(%rax)
movq %r14, %r8
cmpl $0x2, 0x64402(%rip)     # 0x96788
jb 0x3239e
movl $0xfffffff6, %r14d      # imm = 0xFFFFFFF6
cmpl $0xdb7c2712, 0x120(%rbx) # imm = 0xDB7C2712
jne 0x32473
movq 0xd8(%rbx), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
testl %r13d, %r13d
jns 0x323f7
cmpb $0x0, (%r12)
movq %r12, %r13
je 0x323f4
leaq 0x2(%r12), %r13
cmpb $0x0, -0x1(%r13)
je 0x323ec
cmpb $0x0, (%r13)
je 0x323f4
cmpb $0x0, 0x1(%r13)
je 0x323f1
leaq 0x4(%r13), %rcx
cmpb $0x0, 0x2(%r13)
movq %rcx, %r13
jne 0x323c0
addq $-0x2, %rcx
movq %rcx, %r13
jmp 0x323f4
decq %r13
jmp 0x323f4
incq %r13
subl %r12d, %r13d
movq %r8, -0x38(%rbp)
movq 0xe8(%rbx), %rdi
movq 0x8(%rax), %rax
testl %r13d, %r13d
movq %rdi, -0x30(%rbp)
je 0x32425
movq %r12, %rsi
movl %r13d, %edx
movl $0x1, %ecx
movq %rax, %r12
callq *0x50(%rax)
movl %eax, %r14d
jmp 0x3243d
movq %rax, %r12
leaq 0x43327(%rip), %rsi     # 0x75756
movq %rbx, %rdi
callq 0x31af5
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
testq %r15, %r15
movq -0x38(%rbp), %rdx
je 0x3245d
testl %r14d, %r14d
jne 0x3245d
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq *0xa0(%r12)
movl %eax, %r14d
movq 0xf8(%rbx), %rdi
testq %rdi, %rdi
je 0x32473
movq 0x64308(%rip), %rax     # 0x96778
callq *0x30(%rax)
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq