// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqlite_kv_append
int unqlite_kv_append(unqlite *pDb,const void *pKey,int nKeyLen,const void *pData,unqlite_int64 nDataLen)
{
	unqlite_kv_engine *pEngine;
	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);
	 if( pEngine->pIo->pMethods->xAppend == 0 ){
		 /* Storage engine does not implement such method */
		 unqliteGenError(pDb,"xAppend() method not implemented in the underlying storage engine");
		 rc = UNQLITE_NOTIMPLEMENTED;
	 }else{
		 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{
			 /* Perform the requested operation */
			 rc = pEngine->pIo->pMethods->xAppend(pEngine,pKey,nKeyLen,pData,nDataLen);
		 }
	 }
#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
pushq %rax
movl $0xffffffe8, %r14d      # imm = 0xFFFFFFE8
testq %rdi, %rdi
je 0x31ef6
movq %rdi, %rbx
cmpl $0xdb7c2712, 0x120(%rdi) # imm = 0xDB7C2712
jne 0x31ef6
movq %rcx, %r15
movl %edx, %r13d
movq %rsi, %r12
movq 0xf8(%rbx), %rdi
testq %rdi, %rdi
je 0x31e1a
movq 0x64967(%rip), %rax     # 0x96778
movq %r8, %r14
callq *0x20(%rax)
movq %r14, %r8
cmpl $0x2, 0x64967(%rip)     # 0x96788
jb 0x31e39
movl $0xfffffff6, %r14d      # imm = 0xFFFFFFF6
cmpl $0xdb7c2712, 0x120(%rbx) # imm = 0xDB7C2712
jne 0x31ef6
movq 0xd8(%rbx), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
movq 0x40(%rax), %rax
testq %rax, %rax
je 0x31e94
testl %r13d, %r13d
jns 0x31eb6
cmpb $0x0, (%r12)
movq %r12, %r13
je 0x31eb3
leaq 0x2(%r12), %r13
cmpb $0x0, -0x1(%r13)
je 0x31eab
cmpb $0x0, (%r13)
je 0x31eb3
cmpb $0x0, 0x1(%r13)
je 0x31eb0
leaq 0x4(%r13), %rcx
cmpb $0x0, 0x2(%r13)
movq %rcx, %r13
jne 0x31e68
addq $-0x2, %rcx
movq %rcx, %r13
jmp 0x31eb3
leaq 0x438c5(%rip), %rsi     # 0x75760
movq %rbx, %rdi
callq 0x31af5
movl $0xffffffef, %r14d      # imm = 0xFFFFFFEF
jmp 0x31ee0
decq %r13
jmp 0x31eb3
incq %r13
subl %r12d, %r13d
testl %r13d, %r13d
je 0x31ecb
movq %r12, %rsi
movl %r13d, %edx
movq %r15, %rcx
callq *%rax
movl %eax, %r14d
jmp 0x31ee0
leaq 0x43884(%rip), %rsi     # 0x75756
movq %rbx, %rdi
callq 0x31af5
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
movq 0xf8(%rbx), %rdi
testq %rdi, %rdi
je 0x31ef6
movq 0x64885(%rip), %rax     # 0x96778
callq *0x30(%rax)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq