// File: /workspace/github_c_makefile_star2_O2/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
pushq $-0x18
popq %r14
testq %rdi, %rdi
je 0x28b61
movq %rdi, %rbx
cmpl $0xdead2bad, 0xf8(%rdi) # imm = 0xDEAD2BAD
je 0x28b61
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x28a6e
movq 0x5ed2d(%rip), %rax     # 0x87798
callq *0x20(%rax)
cmpl $0x2, 0x5ed33(%rip)     # 0x877a8
pushq $-0xa
popq %r14
jb 0x28a8b
cmpl $0xdead2bad, 0xf8(%rbx) # imm = 0xDEAD2BAD
je 0x28b61
movq %rbx, %rdi
callq 0x28b6f
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x28ac7
movq 0x5ecf2(%rip), %rax     # 0x87798
callq *0x30(%rax)
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x28ac7
movq 0x5ecdc(%rip), %rax     # 0x87798
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x28ac7
callq *%rax
movq (%rbx), %r15
movq 0xf8(%r15), %rdi
testq %rdi, %rdi
je 0x28ae0
movq 0x5ecbb(%rip), %rax     # 0x87798
callq *0x20(%rax)
cmpl $0x2, 0x5ecc1(%rip)     # 0x877a8
jb 0x28af6
cmpl $0xdb7c2712, 0x120(%r15) # imm = 0xDB7C2712
jne 0x28b61
movq 0x100(%r15), %rax
cmpq %rbx, %rax
jne 0x28b10
movq 0xe8(%rax), %rax
movq %rax, 0x100(%r15)
movq 0xe8(%rbx), %rax
movq 0xf0(%rbx), %rcx
testq %rcx, %rcx
je 0x28b2a
movq %rax, 0xe8(%rcx)
testq %rax, %rax
je 0x28b36
movq %rcx, 0xf0(%rax)
decl 0x108(%r15)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x27bf8
movq 0xf8(%r15), %rdi
xorl %r14d, %r14d
testq %rdi, %rdi
je 0x28b61
movq 0x5ec3a(%rip), %rax     # 0x87798
callq *0x30(%rax)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq