// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: page_write
static int page_write(Pager *pPager,Page *pPage)
{
	int rc;
	if( !pPager->is_mem && !pPager->no_jrnl ){
		/* Write the page to the transaction journal */
		if( pPage->iPage < pPager->dbOrigSize && !unqliteBitvecTest(pPager->pVec,pPage->iPage) ){
			sxu32 cksum;
			if( pPager->nRec == SXU32_HIGH ){
				/* Journal Limit reached */
				unqliteGenError(pPager->pDb,"Journal record limit reached, commit your changes");
				return UNQLITE_LIMIT;
			}
			/* Write the page number */
			rc = WriteInt64(pPager->pjfd,pPage->iPage,pPager->iJournalOfft);
			if( rc != UNQLITE_OK ){ return rc; }
			/* Write the raw page */
			/** CODEC */
			rc = unqliteOsWrite(pPager->pjfd,pPage->zData,pPager->iPageSize,pPager->iJournalOfft + 8);
			if( rc != UNQLITE_OK ){ return rc; }
			/* Compute the checksum */
			cksum = pager_cksum(pPager,pPage->zData);
			rc = WriteInt32(pPager->pjfd,cksum,pPager->iJournalOfft + 8 + pPager->iPageSize);
			if( rc != UNQLITE_OK ){ return rc; }
			/* Update the journal offset */
			pPager->iJournalOfft += 8 /* page num */ + pPager->iPageSize + 4 /* cksum */;
			pPager->nRec++;
			/* Mark as journalled  */
			unqliteBitvecSet(pPager->pVec,pPage->iPage);
		}
	}
	/* Add the page to the dirty list */
	pager_page_to_dirty_list(pPager,pPage);
	/* Update the database size and return. */
	if( (1 + pPage->iPage) > pPager->dbSize ){
		pPager->dbSize = 1 + pPage->iPage;
		if( pPager->dbSize == SXU64_HIGH ){
			unqliteGenError(pPager->pDb,"Database maximum page limit (64-bit) reached");
			return UNQLITE_LIMIT;
		}
	}	
	return UNQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1fc(%rax)
jne 0x6a789
movq -0x10(%rbp), %rax
cmpl $0x0, 0x204(%rax)
jne 0x6a789
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x6a787
movq -0x10(%rbp), %rax
movq 0x198(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x6b010
cmpl $0x0, %eax
jne 0x6a787
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x60(%rax)
jne 0x6a673
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x57be5(%rip), %rsi     # 0xc2247
callq 0x58950
movl $0xfffffff9, -0x4(%rbp) # imm = 0xFFFFFFF9
jmp 0x6a7f1
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x170(%rax), %rdx
callq 0x6b110
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x6a6a7
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6a7f1
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0x208(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x170(%rax), %rcx
addq $0x8, %rcx
callq 0x69e30
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x6a6e9
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6a7f1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x69dd0
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movl -0x20(%rbp), %esi
movq -0x10(%rbp), %rax
movq 0x170(%rax), %rdx
addq $0x8, %rdx
movq -0x10(%rbp), %rax
movslq 0x208(%rax), %rax
addq %rax, %rdx
callq 0x6acf0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x6a73d
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6a7f1
movq -0x10(%rbp), %rax
movl 0x208(%rax), %eax
addl $0x8, %eax
addl $0x4, %eax
movslq %eax, %rcx
movq -0x10(%rbp), %rax
addq 0x170(%rax), %rcx
movq %rcx, 0x170(%rax)
movq -0x10(%rbp), %rax
movl 0x60(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x60(%rax)
movq -0x10(%rbp), %rax
movq 0x198(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x6b160
jmp 0x6a789
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6b340
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x1, %rax
movq -0x10(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jbe 0x6a7ea
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
cmpq $-0x1, 0x40(%rax)
jne 0x6a7e8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x57a9f(%rip), %rsi     # 0xc2279
callq 0x58950
movl $0xfffffff9, -0x4(%rbp) # imm = 0xFFFFFFF9
jmp 0x6a7f1
jmp 0x6a7ea
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)