// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqliteDropCollection
UNQLITE_PRIVATE int unqliteDropCollection(unqlite_col *pCol)
{
	unqlite_vm *pVm = pCol->pVm;
	jx9_int64 nId;
	int rc;
	/* Reset the cursor */
	unqlite_kv_cursor_reset(pCol->pCursor);
	/* Seek the cursor to the desired location */
	rc = unqlite_kv_cursor_seek(pCol->pCursor,
		SyStringData(&pCol->sName),SyStringLength(&pCol->sName),
		UNQLITE_CURSOR_MATCH_EXACT
		);
	if( rc == UNQLITE_OK ){
		/* Remove the record from the storage engine */
		rc = unqlite_kv_cursor_delete_entry(pCol->pCursor);
	}
	if( rc != UNQLITE_OK ){
		unqliteGenErrorFormat(pCol->pVm->pDb,
				"Cannot remove collection '%z' due to a read-only Key/Value storage engine",
				&pCol->sName
			);
		return rc;
	}
	/* Drop collection records */
	for( nId = 0 ; nId < pCol->nLastid ; ++nId ){
		unqliteCollectionDropRecord(pCol,nId,0,0);
	}
	/* Cleanup */
	CollectionCacheRelease(pCol);
	SyBlobRelease(&pCol->sHeader);
	SyBlobRelease(&pCol->sWorker);
	SyMemBackendFree(&pVm->sAlloc,(void *)SyStringData(&pCol->sName));
	unqliteReleaseCursor(pVm->pDb,pCol->pCursor);
	/* Unlink */
	if( pCol->pPrevCol ){
		pCol->pPrevCol->pNextCol = pCol->pNextCol;
	}else{
		sxu32 iBucket = pCol->nHash & (pVm->iColSize - 1);
		pVm->apCol[iBucket] = pCol->pNextCol;
	}
	if( pCol->pNextCol ){
		pCol->pNextCol->pPrevCol = pCol->pPrevCol;
	}
	MACRO_LD_REMOVE(pVm->pCol,pCol);
	pVm->iCol--;
	SyMemBackendPoolFree(&pVm->sAlloc,pCol);
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
callq 0x59b40
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
movl $0x1, %ecx
callq 0x59ba0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x79a57
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
callq 0x59ae0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x79a88
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
leaq 0x49140(%rip), %rsi     # 0xc2bb6
movb $0x0, %al
callq 0x68100
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x79c4f
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0xa8(%rcx), %rax
jge 0x79ac0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x79c60
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x79a90
movq -0x10(%rbp), %rdi
callq 0x79da0
movq -0x10(%rbp), %rdi
addq $0x88, %rdi
callq 0x58c00
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
callq 0x58c00
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x5d6b0
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rsi
callq 0x598f0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x138(%rax)
je 0x79b3f
movq -0x10(%rbp), %rax
movq 0x130(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x138(%rax), %rax
movq %rcx, 0x130(%rax)
jmp 0x79b75
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x18(%rbp), %rcx
movl 0xdc(%rcx), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x130(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0xc8(%rax), %rax
movl -0x28(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x130(%rax)
je 0x79ba0
movq -0x10(%rbp), %rax
movq 0x138(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x130(%rax), %rax
movq %rcx, 0x138(%rax)
movq -0x18(%rbp), %rax
movq 0xd0(%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0x79bce
movq -0x18(%rbp), %rax
movq 0xd0(%rax), %rax
movq 0x120(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xd0(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x128(%rax)
je 0x79bf9
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rax
movq %rcx, 0x120(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x120(%rax)
je 0x79c24
movq -0x10(%rbp), %rax
movq 0x128(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rax
movq %rcx, 0x128(%rax)
movq -0x18(%rbp), %rax
movl 0xd8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xd8(%rax)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
callq 0x54490
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)