// File: /workspace/github_c_makefile_star2_O1/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 0x33523
movq %rdi, %r14
cmpl $0x0, 0x1fc(%rdi)
jne 0x33523
cmpl $0x0, 0x200(%r14)
je 0x33298
movq 0x8(%r14), %rdi
leaq 0x46aaa(%rip), %rsi     # 0x79d33
callq 0x31af5
movl $0xffffffb5, %ebx       # imm = 0xFFFFFFB5
jmp 0x33523
cmpl $0x2, %eax
jne 0x332d1
cmpl $0x0, 0x1f4(%r14)
je 0x332c1
movq 0x30(%r14), %rdi
movq (%rdi), %rax
movl $0x1, %esi
callq *0x40(%rax)
movl $0x1, 0x1f4(%r14)
movl $0x1, 0x1f0(%r14)
jmp 0x33523
movl %esi, %r12d
cmpl $0x0, 0x204(%r14)
je 0x334ba
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdi
movl $0x1, %edx
callq *0x20(%rdi)
movq 0x10(%r14), %r15
movq 0x48(%r14), %rax
movq 0x228(%r14), %rsi
andb $-0x4, 0x1f8(%r14)
movq $0x0, 0x170(%r14)
movl $0x0, 0x60(%r14)
movq %rax, 0x40(%r14)
testq %rsi, %rsi
je 0x3333d
movq 0x28(%rsi), %r13
andb $-0x6f, 0x20(%rsi)
movq %r14, %rdi
callq 0x3c77b
movq %r13, %rsi
testq %r13, %r13
jne 0x33325
movl $0x0, 0x254(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x218(%r14)
movups %xmm0, 0x228(%r14)
movups %xmm0, 0x234(%r14)
movq 0x248(%r14), %rax
testq %rax, %rax
je 0x333ac
movl 0x250(%r14), %ecx
shll $0x3, %ecx
testl %ecx, %ecx
je 0x333ac
addq %rax, %rcx
movb $0x0, (%rax)
incq %rax
cmpq %rcx, %rax
jae 0x333ac
movb $0x0, (%rax)
incq %rax
cmpq %rcx, %rax
jae 0x333ac
movb $0x0, (%rax)
incq %rax
cmpq %rcx, %rax
jae 0x333ac
movb $0x0, (%rax)
incq %rax
cmpq %rcx, %rax
jb 0x33380
movq 0x198(%r14), %rdi
testq %rdi, %rdi
je 0x333c8
callq 0x3c994
movq $0x0, 0x198(%r14)
cmpl $0x0, 0x1f4(%r14)
je 0x333ec
movq 0x30(%r14), %rdi
movq (%rdi), %rax
movl $0x1, %esi
callq *0x40(%rax)
movl $0x1, 0x1f4(%r14)
movl $0x1, 0x1f0(%r14)
testl %r12d, %r12d
je 0x33492
movq (%r15), %r13
movq 0x8(%r13), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x33415
movq %r15, %rdi
callq *%rax
movq 0x8(%r13), %rax
movl 0x8(%rax), %eax
testq %rax, %rax
je 0x33453
addq %r15, %rax
movq %r15, %rcx
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x33453
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x33453
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jae 0x33453
movb $0x0, (%rcx)
incq %rcx
cmpq %rax, %rcx
jb 0x33427
movq %r13, (%r15)
movq 0x8(%r13), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x33473
movl 0x208(%r14), %esi
movq %r15, %rdi
callq *%rax
testl %eax, %eax
jne 0x3348d
movq 0x8(%r13), %rax
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x33492
movq 0x40(%r14), %rsi
movq %r15, %rdi
callq *%rax
testl %eax, %eax
je 0x33492
movl %eax, %r12d
jmp 0x33495
xorl %r12d, %r12d
testl %r12d, %r12d
je 0x33523
movq 0x8(%r14), %rdi
orl $0x1, 0x10c(%rdi)
leaq 0x46908(%rip), %rsi     # 0x79db8
callq 0x31af5
movl %r12d, %ebx
jmp 0x33523
movq 0x38(%r14), %rdi
testq %rdi, %rdi
je 0x334ce
movq (%rdi), %rax
movl $0x2, %esi
callq *0x28(%rax)
movq 0x38(%r14), %r15
testq %r15, %r15
je 0x334ee
movq (%r14), %r13
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movq %r13, %rdi
movq %r15, %rsi
callq 0x3503f
movq $0x0, 0x38(%r14)
testb $0x3, 0x1f8(%r14)
je 0x332e2
movq %r14, %rdi
xorl %esi, %esi
callq 0x3be3c
testl %eax, %eax
je 0x332e2
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