// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: unqlitePagerRollback
UNQLITE_PRIVATE int unqlitePagerRollback(Pager *pPager,int bResetKvEngine)
{
	int rc = UNQLITE_OK;
	if( pPager->iState < PAGER_WRITER_LOCKED ){
		/* A write transaction must be opened */
		return UNQLITE_OK;
	}
	if( pPager->is_mem ){
		/* As of this release 1.1.6: Transactions are not supported for in-memory databases */
		return UNQLITE_OK;
	}
	if( pPager->is_rdonly ){
		/* Read-Only DB */
		unqliteGenError(pPager->pDb,"Read-Only database");
		return UNQLITE_READ_ONLY;
	}
	if( pPager->iState >= PAGER_WRITER_CACHEMOD ){
		if( !pPager->no_jrnl ){
			/* Close any outstanding joural file */
			if( pPager->pjfd ){
				/* Sync the journal file */
				unqliteOsSync(pPager->pjfd,UNQLITE_SYNC_NORMAL);
			}
			unqliteOsCloseFree(pPager->pAllocator,pPager->pjfd);
			pPager->pjfd = 0;
			if( pPager->iFlags & (PAGER_CTRL_COMMIT_ERR|PAGER_CTRL_DIRTY_COMMIT) ){
				/* Perform the rollback */
				rc = pager_journal_rollback(pPager,0);
				if( rc != UNQLITE_OK ){
					/* Set the auto-commit flag */
					pPager->pDb->iFlags |= UNQLITE_FL_DISABLE_AUTO_COMMIT;
					return rc;
				}
			}
		}
		/* Unlink the journal file */
		unqliteOsDelete(pPager->pVfs,pPager->zJournal,1);
		/* Reset the pager state */
		rc = pager_reset_state(pPager,bResetKvEngine);
		if( rc != UNQLITE_OK ){
			/* Mostly an unlikely scenario */
			pPager->pDb->iFlags |= UNQLITE_FL_DISABLE_AUTO_COMMIT; /* Set the auto-commit flag */
			unqliteGenError(pPager->pDb,"Error while reseting pager to its initial state");
			return rc;
		}
	}else{
		/* Downgrade to shared lock */
		pager_unlock_db(pPager,SHARED_LOCK);
		pPager->iState = PAGER_READER;
	}
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x1f0(%rdi), %eax
xorl %ebx, %ebx
cmpl $0x2, %eax
jl 0x2bc48
movq %rdi, %r14
cmpl $0x0, 0x1fc(%rdi)
jne 0x2bc48
cmpl $0x0, 0x200(%r14)
je 0x2ba82
movq 0x8(%r14), %rdi
leaq 0x3c2a9(%rip), %rsi     # 0x67d1e
callq 0x2a542
pushq $-0x4b
popq %rbx
jmp 0x2bc48
cmpl $0x2, %eax
jne 0x2baa2
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x33bcd
movl $0x1, 0x1f0(%r14)
jmp 0x2bc48
movl %esi, %r15d
cmpl $0x0, 0x204(%r14)
je 0x2bbf4
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdi
pushq $0x1
popq %rdx
callq *0x20(%rdi)
movq 0x10(%r14), %r12
movq 0x48(%r14), %rax
movq 0x228(%r14), %rsi
andb $-0x4, 0x1f8(%r14)
andq $0x0, 0x170(%r14)
andl $0x0, 0x60(%r14)
movq %rax, 0x40(%r14)
testq %rsi, %rsi
je 0x2bb03
movq 0x28(%rsi), %r13
andb $-0x6f, 0x20(%rsi)
movq %r14, %rdi
callq 0x33f42
movq %r13, %rsi
jmp 0x2bae9
andl $0x0, 0x254(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x218(%r14)
movups %xmm0, 0x228(%r14)
movups %xmm0, 0x234(%r14)
movq 0x248(%r14), %rdi
testq %rdi, %rdi
je 0x2bb41
movl 0x250(%r14), %esi
shll $0x3, %esi
callq 0x27aea
movq 0x198(%r14), %rdi
testq %rdi, %rdi
je 0x2bb5a
callq 0x3415d
andq $0x0, 0x198(%r14)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x33bcd
movl $0x1, 0x1f0(%r14)
testl %r15d, %r15d
je 0x2bc48
movq (%r12), %r15
movq 0x8(%r15), %rax
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0x2bb93
movq %r12, %rdi
callq *%rcx
movq 0x8(%r15), %rax
movl 0x8(%rax), %esi
movq %r12, %rdi
callq 0x27aea
movq %r15, (%r12)
movq 0x8(%r15), %rcx
movq 0x18(%rcx), %rax
testq %rax, %rax
je 0x2bbc3
movl 0x208(%r14), %esi
movq %r12, %rdi
callq *%rax
testl %eax, %eax
jne 0x2bbd9
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %rax
testq %rax, %rax
je 0x2bc48
movq 0x40(%r14), %rsi
movq %r12, %rdi
callq *%rax
testl %eax, %eax
je 0x2bc48
movl %eax, %ebx
movq 0x8(%r14), %rdi
orl $0x1, 0x10c(%rdi)
leaq 0x3c1b6(%rip), %rsi     # 0x67da3
callq 0x2a542
jmp 0x2bc48
movq 0x38(%r14), %rdi
testq %rdi, %rdi
je 0x2bc0c
movq (%rdi), %rax
pushq $0x2
popq %rsi
callq *0x28(%rax)
movq 0x38(%r14), %rsi
jmp 0x2bc0e
xorl %esi, %esi
movq (%r14), %rdi
callq 0x33c59
andq $0x0, 0x38(%r14)
testb $0x3, 0x1f8(%r14)
je 0x2bab3
movq %r14, %rdi
xorl %esi, %esi
callq 0x3371a
testl %eax, %eax
je 0x2bab3
movq 0x8(%r14), %rcx
orl $0x1, 0x10c(%rcx)
movl %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq