// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqlite_vm_release
int unqlite_vm_release(unqlite_vm *pVm)
{
	int rc;
	if( UNQLITE_VM_MISUSE(pVm) ){
		return UNQLITE_CORRUPT;
	}
#if defined(UNQLITE_ENABLE_THREADS)
	 /* Acquire VM mutex */
	 SyMutexEnter(sUnqlMPGlobal.pMutexMethods, pVm->pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel != UNQLITE_THREAD_LEVEL_MULTI */
	 if( sUnqlMPGlobal.nThreadingLevel > UNQLITE_THREAD_LEVEL_SINGLE && 
		 UNQLITE_THRD_VM_RELEASE(pVm) ){
			 return UNQLITE_ABORT; /* Another thread have released this instance */
	 }
#endif
	/* Release the VM */
	 rc = unqliteVmRelease(pVm);
#if defined(UNQLITE_ENABLE_THREADS)
	 /* Leave VM mutex */
	 SyMutexLeave(sUnqlMPGlobal.pMutexMethods,pVm->pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel != UNQLITE_THREAD_LEVEL_MULTI */
	 /* Release VM mutex */
	 SyMutexRelease(sUnqlMPGlobal.pMutexMethods,pVm->pMutex) /* NO-OP if sUnqlMPGlobal.nThreadingLevel != UNQLITE_THREAD_LEVEL_MULTI */
#endif
	 if( rc == UNQLITE_OK ){
		 unqlite *pDb = pVm->pDb;
		 /* Unlink from the list of active VM's */
#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
		MACRO_LD_REMOVE(pDb->pVms, pVm);
		pDb->iVm--;
		/* Release the memory chunk allocated to this instance */
		SyMemBackendPoolFree(&pDb->sMem,pVm);
#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 %rbx
pushq %rax
movl $0xffffffe8, %r15d      # imm = 0xFFFFFFE8
testq %rdi, %rdi
je 0x2f726
movq %rdi, %rbx
cmpl $0xdead2bad, 0xf8(%rdi) # imm = 0xDEAD2BAD
je 0x2f726
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x2f61e
movq 0x6515d(%rip), %rax     # 0x94778
callq *0x20(%rax)
cmpl $0x2, 0x65163(%rip)     # 0x94788
jb 0x2f63d
movl $0xfffffff6, %r15d      # imm = 0xFFFFFFF6
cmpl $0xdead2bad, 0xf8(%rbx) # imm = 0xDEAD2BAD
je 0x2f726
movq 0xe0(%rbx), %rdi
callq 0x2f0f4
leaq 0x8(%rbx), %rdi
callq 0x2e588
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x2f686
movq 0x65113(%rip), %rax     # 0x94778
callq *0x30(%rax)
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x2f686
movq 0x650fd(%rip), %rax     # 0x94778
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2f686
callq *%rax
movq (%rbx), %r14
movq 0xf8(%r14), %rdi
testq %rdi, %rdi
je 0x2f69f
movq 0x650dc(%rip), %rax     # 0x94778
callq *0x20(%rax)
cmpl $0x2, 0x650e2(%rip)     # 0x94788
jb 0x2f6bb
movl $0xfffffff6, %r15d      # imm = 0xFFFFFFF6
cmpl $0xdb7c2712, 0x120(%r14) # imm = 0xDB7C2712
jne 0x2f726
movq 0x100(%r14), %rax
cmpq %rbx, %rax
jne 0x2f6d5
movq 0xe8(%rax), %rax
movq %rax, 0x100(%r14)
movq 0xe8(%rbx), %rax
movq 0xf0(%rbx), %rcx
testq %rcx, %rcx
je 0x2f6ef
movq %rax, 0xe8(%rcx)
testq %rax, %rax
je 0x2f6fb
movq %rcx, 0xf0(%rax)
decl 0x108(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e659
movq 0xf8(%r14), %rdi
xorl %r15d, %r15d
testq %rdi, %rdi
je 0x2f726
movq 0x65055(%rip), %rax     # 0x94778
callq *0x30(%rax)
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq