// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqlite_close
int unqlite_close(unqlite *pDb)
{
	int rc;
	if( UNQLITE_DB_MISUSE(pDb) ){
		return UNQLITE_CORRUPT;
	}
#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
	/* Release the database handle */
	rc = unqliteDbRelease(pDb);
#if defined(UNQLITE_ENABLE_THREADS)
	 /* Leave DB mutex */
	 SyMutexLeave(sUnqlMPGlobal.pMutexMethods, pDb->pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel != UNQLITE_THREAD_LEVEL_MULTI */
	 /* Release DB mutex */
	 SyMutexRelease(sUnqlMPGlobal.pMutexMethods, pDb->pMutex) /* NO-OP if sUnqlMPGlobal.nThreadingLevel != UNQLITE_THREAD_LEVEL_MULTI */
#endif
#if defined(UNQLITE_ENABLE_THREADS)
	/* Enter the global mutex */
	 SyMutexEnter(sUnqlMPGlobal.pMutexMethods, sUnqlMPGlobal.pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel == UNQLITE_THREAD_LEVEL_SINGLE */
#endif
	/* Unlink from the list of active database handles */
	 MACRO_LD_REMOVE(sUnqlMPGlobal.pDB, pDb);
	sUnqlMPGlobal.nDB--;
#if defined(UNQLITE_ENABLE_THREADS)
	/* Leave the global mutex */
	 SyMutexLeave(sUnqlMPGlobal.pMutexMethods, sUnqlMPGlobal.pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel == UNQLITE_THREAD_LEVEL_SINGLE */
#endif
	/* Release the memory chunk allocated to this handle */
	SyMemBackendPoolFree(&sUnqlMPGlobal.sAllocator,pDb);
	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x54923
movq -0x10(%rbp), %rax
cmpl $0xdb7c2712, 0x120(%rax) # imm = 0xDB7C2712
je 0x5492f
movl $0xffffffe8, -0x4(%rbp) # imm = 0xFFFFFFE8
jmp 0x54ab9
movq -0x10(%rbp), %rax
cmpq $0x0, 0xf8(%rax)
je 0x54955
movq 0x99f34(%rip), %rax     # 0xee878
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0xf8(%rcx), %rdi
callq *%rax
cmpl $0x1, 0x99f2c(%rip)     # 0xee888
jbe 0x5497a
movq -0x10(%rbp), %rax
cmpl $0xdb7c2712, 0x120(%rax) # imm = 0xDB7C2712
je 0x5497a
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x54ab9
movq -0x10(%rbp), %rdi
callq 0x54ad0
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0xf8(%rax)
je 0x549ac
movq 0x99edd(%rip), %rax     # 0xee878
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0xf8(%rcx), %rdi
callq *%rax
movq -0x10(%rbp), %rax
cmpq $0x0, 0xf8(%rax)
je 0x549e0
movq 0x99eb7(%rip), %rax     # 0xee878
cmpq $0x0, 0x18(%rax)
je 0x549e0
movq 0x99ea9(%rip), %rax     # 0xee878
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0xf8(%rcx), %rdi
callq *%rax
cmpq $0x0, 0x99e98(%rip)     # 0xee880
je 0x549fe
movq 0x99e87(%rip), %rax     # 0xee878
movq 0x20(%rax), %rax
movq 0x99e84(%rip), %rdi     # 0xee880
callq *%rax
movq 0x99ecb(%rip), %rax     # 0xee8d0
cmpq -0x10(%rbp), %rax
jne 0x54a20
movq 0x99ebe(%rip), %rax     # 0xee8d0
movq 0x110(%rax), %rax
movq %rax, 0x99eb0(%rip)     # 0xee8d0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x118(%rax)
je 0x54a4b
movq -0x10(%rbp), %rax
movq 0x110(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rax
movq %rcx, 0x110(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x110(%rax)
je 0x54a76
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x110(%rax), %rax
movq %rcx, 0x118(%rax)
movl 0x99e4c(%rip), %eax     # 0xee8c8
addl $-0x1, %eax
movl %eax, 0x99e43(%rip)     # 0xee8c8
cmpq $0x0, 0x99df3(%rip)     # 0xee880
je 0x54aa3
movq 0x99de2(%rip), %rax     # 0xee878
movq 0x30(%rax), %rax
movq 0x99ddf(%rip), %rdi     # 0xee880
callq *%rax
movq -0x10(%rbp), %rsi
leaq 0x99d12(%rip), %rdi     # 0xee7c0
callq 0x54490
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)