// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9_vm_release
JX9_PRIVATE int jx9_vm_release(jx9_vm *pVm)
{
	jx9 *pEngine;
	int rc;
	/* Ticket 1433-002: NULL VM is harmless operation */
	if ( JX9_VM_MISUSE(pVm) ){
		return JX9_CORRUPT;
	}
#if defined(JX9_ENABLE_THREADS)
	 /* Acquire VM mutex */
	 SyMutexEnter(sJx9MPGlobal.pMutexMethods, pVm->pMutex); /* NO-OP if sJx9MPGlobal.nThreadingLevel != JX9_THREAD_LEVEL_MULTI */
	 if( sJx9MPGlobal.nThreadingLevel > JX9_THREAD_LEVEL_SINGLE && 
		 JX9_THRD_VM_RELEASE(pVm) ){
			 return JX9_ABORT; /* Another thread have released this instance */
	 }
#endif
	pEngine = pVm->pEngine;
	rc = jx9VmRelease(&(*pVm));
#if defined(JX9_ENABLE_THREADS)
	 /* Leave VM mutex */
	 SyMutexLeave(sJx9MPGlobal.pMutexMethods, pVm->pMutex); /* NO-OP if sJx9MPGlobal.nThreadingLevel != JX9_THREAD_LEVEL_MULTI */
	 /* Release VM mutex */
	 SyMutexRelease(sJx9MPGlobal.pMutexMethods, pVm->pMutex) /* NO-OP if sJx9MPGlobal.nThreadingLevel != JX9_THREAD_LEVEL_MULTI */
#endif
	if( rc == JX9_OK ){
		/* Unlink from the list of active VM */
#if defined(JX9_ENABLE_THREADS)
			/* Acquire engine mutex */
			SyMutexEnter(sJx9MPGlobal.pMutexMethods, pEngine->pMutex); /* NO-OP if sJx9MPGlobal.nThreadingLevel != JX9_THREAD_LEVEL_MULTI */
			if( sJx9MPGlobal.nThreadingLevel > JX9_THREAD_LEVEL_SINGLE && 
				JX9_THRD_ENGINE_RELEASE(pEngine) ){
					return JX9_ABORT; /* Another thread have released this instance */
			}
#endif
		MACRO_LD_REMOVE(pEngine->pVms, pVm);
		pEngine->iVm--;
		/* Release the memory chunk allocated to this VM */
		SyMemBackendPoolFree(&pEngine->sAllocator, pVm);
#if defined(JX9_ENABLE_THREADS)
			/* Leave engine mutex */
			SyMutexLeave(sJx9MPGlobal.pMutexMethods, pEngine->pMutex); /* NO-OP if sJx9MPGlobal.nThreadingLevel != JX9_THREAD_LEVEL_MULTI */
#endif	
	}
	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x28585
movq %rdi, %rbx
cmpl $0xdead2bad, 0x6e8(%rdi) # imm = 0xDEAD2BAD
jne 0x2858a
popq %rbx
popq %r14
popq %rbp
retq
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x285a0
movq 0x5fb23(%rip), %rax     # 0x880c0
callq *0x20(%rax)
cmpl $0x2, 0x5fb29(%rip)     # 0x880d0
jb 0x285b5
cmpl $0xdead2bad, 0x6e8(%rbx) # imm = 0xDEAD2BAD
je 0x28585
movq 0xc0(%rbx), %r14
movq %rbx, %rdi
callq 0x3206e
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x285f8
movq 0x5fae9(%rip), %rax     # 0x880c0
callq *0x30(%rax)
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x285f8
movq 0x5fad3(%rip), %rax     # 0x880c0
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x285f8
callq *%rax
movq 0xf0(%r14), %rdi
testq %rdi, %rdi
je 0x2860e
movq 0x5fab5(%rip), %rax     # 0x880c0
callq *0x20(%rax)
cmpl $0x2, 0x5fabb(%rip)     # 0x880d0
jb 0x28628
cmpl $0xf874bcd7, 0x118(%r14) # imm = 0xF874BCD7
jne 0x28585
movq 0xf8(%r14), %rax
cmpq %rbx, %rax
jne 0x28642
movq 0x6d8(%rax), %rax
movq %rax, 0xf8(%r14)
movq 0x6d8(%rbx), %rax
movq 0x6e0(%rbx), %rcx
testq %rcx, %rcx
je 0x2865c
movq %rax, 0x6d8(%rcx)
testq %rax, %rax
je 0x28668
movq %rcx, 0x6e0(%rax)
decl 0x100(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27bf8
movq 0xf0(%r14), %rdi
testq %rdi, %rdi
je 0x28585
movq 0x5fa2f(%rip), %rax     # 0x880c0
popq %rbx
popq %r14
popq %rbp
jmpq *0x30(%rax)