// File: /workspace/github_c_makefile_star2_O3/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 0x2f10f
movq %rdi, %rbx
cmpl $0xdead2bad, 0x6e8(%rdi) # imm = 0xDEAD2BAD
jne 0x2f114
popq %rbx
popq %r14
popq %rbp
retq
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x2f12a
movq 0x65f79(%rip), %rax     # 0x950a0
callq *0x20(%rax)
cmpl $0x2, 0x65f7f(%rip)     # 0x950b0
jb 0x2f13f
cmpl $0xdead2bad, 0x6e8(%rbx) # imm = 0xDEAD2BAD
je 0x2f10f
movq 0xc0(%rbx), %r14
movl $0xdead2bad, 0x6e8(%rbx) # imm = 0xDEAD2BAD
movq %rbx, %rdi
callq 0x2e588
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x2f18c
movq 0x65f35(%rip), %rax     # 0x950a0
callq *0x30(%rax)
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x2f18c
movq 0x65f1f(%rip), %rax     # 0x950a0
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2f18c
callq *%rax
movq 0xf0(%r14), %rdi
testq %rdi, %rdi
je 0x2f1a2
movq 0x65f01(%rip), %rax     # 0x950a0
callq *0x20(%rax)
cmpl $0x2, 0x65f07(%rip)     # 0x950b0
jb 0x2f1bc
cmpl $0xf874bcd7, 0x118(%r14) # imm = 0xF874BCD7
jne 0x2f10f
movq 0xf8(%r14), %rax
cmpq %rbx, %rax
jne 0x2f1d6
movq 0x6d8(%rax), %rax
movq %rax, 0xf8(%r14)
movq 0x6d8(%rbx), %rax
movq 0x6e0(%rbx), %rcx
testq %rcx, %rcx
je 0x2f1f0
movq %rax, 0x6d8(%rcx)
testq %rax, %rax
je 0x2f1fc
movq %rcx, 0x6e0(%rax)
decl 0x100(%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e659
movq 0xf0(%r14), %rdi
testq %rdi, %rdi
je 0x2f10f
movq 0x65e7b(%rip), %rax     # 0x950a0
popq %rbx
popq %r14
popq %rbp
jmpq *0x30(%rax)