// File: /workspace/github_c_makefile_star2_O1/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 0x2fc0f
movq %rdi, %rbx
cmpl $0xdead2bad, 0xf8(%rdi) # imm = 0xDEAD2BAD
je 0x2fc0f
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x2fb00
movq 0x66c7b(%rip), %rax     # 0x96778
callq *0x20(%rax)
cmpl $0x2, 0x66c81(%rip)     # 0x96788
jb 0x2fb1f
movl $0xfffffff6, %r15d      # imm = 0xFFFFFFF6
cmpl $0xdead2bad, 0xf8(%rbx) # imm = 0xDEAD2BAD
je 0x2fc0f
movq 0xe0(%rbx), %rdi
callq 0x2f5cf
leaq 0x8(%rbx), %rdi
callq 0x2ea67
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x2fb4a
movq 0x66c31(%rip), %rax     # 0x96778
callq *0x30(%rax)
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x2fb68
movq 0x66c1b(%rip), %rax     # 0x96778
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2fb68
callq *%rax
movq (%rbx), %r14
movq 0xf8(%r14), %rdi
testq %rdi, %rdi
je 0x2fb81
movq 0x66bfa(%rip), %rax     # 0x96778
callq *0x20(%rax)
cmpl $0x2, 0x66c00(%rip)     # 0x96788
jb 0x2fb9d
movl $0xfffffff6, %r15d      # imm = 0xFFFFFFF6
cmpl $0xdb7c2712, 0x120(%r14) # imm = 0xDB7C2712
jne 0x2fc0f
movq 0x100(%r14), %rax
cmpq %rbx, %rax
jne 0x2fbb7
movq 0xe8(%rax), %rax
movq %rax, 0x100(%r14)
movq 0xf0(%rbx), %rax
testq %rax, %rax
je 0x2fbd1
movq 0xe8(%rbx), %rcx
movq %rcx, 0xe8(%rax)
movq 0xe8(%rbx), %rcx
testq %rcx, %rcx
je 0x2fbe4
movq %rax, 0xf0(%rcx)
decl 0x108(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2eb38
movq 0xf8(%r14), %rdi
xorl %r15d, %r15d
testq %rdi, %rdi
je 0x2fc0f
movq 0x66b6c(%rip), %rax     # 0x96778
callq *0x30(%rax)
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq