// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerWalFrames
static int pagerWalFrames(
  Pager *pPager,                  /* Pager object */
  PgHdr *pList,                   /* List of frames to log */
  Pgno nTruncate,                 /* Database size after this commit */
  int isCommit                    /* True if this is a commit */
){
  int rc;                         /* Return code */
  int nList;                      /* Number of pages in pList */
#if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
  PgHdr *p;                       /* For looping over pages */
#endif

  assert( pPager->pWal );
  assert( pList );
#ifdef SQLITE_DEBUG
  /* Verify that the page list is in accending order */
  for(p=pList; p && p->pDirty; p=p->pDirty){
    assert( p->pgno < p->pDirty->pgno );
  }
#endif

  assert( pList->pDirty==0 || isCommit );
  if( isCommit ){
    /* If a WAL transaction is being committed, there is no point in writing
    ** any pages with page numbers greater than nTruncate into the WAL file.
    ** They will never be read by any client. So remove them from the pDirty
    ** list here. */
    PgHdr *p;
    PgHdr **ppNext = &pList;
    nList = 0;
    for(p=pList; (*ppNext = p)!=0; p=p->pDirty){
      if( p->pgno<=nTruncate ){
        ppNext = &p->pDirty;
        nList++;
      }
    }
    assert( pList );
  }else{
    nList = 1;
  }
  pPager->aStat[PAGER_STAT_WRITE] += nList;

  if( pList->pgno==1 ) pager_write_changecounter(pList);
  rc = sqlite3WalFrames(pPager->pWal, 
      pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
  );
  if( rc==SQLITE_OK && pPager->pBackup ){
    PgHdr *p;
    for(p=pList; p; p=p->pDirty){
      sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);
    }
  }

#ifdef SQLITE_CHECK_PAGES
  pList = sqlite3PcacheDirtyList(pPager->pPCache);
  for(p=pList; p; p=p->pDirty){
    pager_set_pagehash(p);
  }
#endif

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, -0x68(%rbp)
testl %ecx, %ecx
je 0x185f9
leaq -0x68(%rbp), %r8
xorl %eax, %eax
movq %r15, (%r8)
testq %r15, %r15
je 0x185f3
xorl %edi, %edi
cmpl %edx, 0x28(%r15)
leaq 0x18(%r15), %rsi
cmovbeq %rsi, %r8
setbe %dil
addl %edi, %eax
movq 0x18(%r15), %r15
jmp 0x185d1
movq -0x68(%rbp), %r15
jmp 0x185fc
pushq $0x1
popq %rax
movl %ecx, -0x48(%rbp)
movl %edx, -0x44(%rbp)
addl %eax, 0xf8(%r14)
cmpl $0x1, 0x28(%r15)
jne 0x18618
movq %r15, %rdi
callq 0x19241
movq 0x118(%r14), %rdx
movl 0xbc(%r14), %ecx
movzbl 0xe(%r14), %eax
movl %eax, -0x40(%rbp)
cmpw $0x0, 0x3c(%rdx)
movq %rdx, -0x30(%rbp)
movl %ecx, -0x34(%rbp)
movq %r15, -0x58(%rbp)
je 0x186ec
movl 0x58(%rdx), %esi
testq %rsi, %rsi
je 0x18783
movq %r14, -0x60(%rbp)
movslq %ecx, %rdi
leaq -0xb8(%rbp), %r8
movq %rdx, (%r8)
movq 0x10(%rdx), %rax
movq %rax, -0x98(%rbp)
movq %rax, 0x8(%r8)
andq $0x0, 0x10(%r8)
movl -0x40(%rbp), %eax
movl %eax, 0x18(%r8)
movl %ecx, 0x1c(%r8)
addq $0x18, %rdi
movq %rsi, %rbx
movq %rdi, %r14
imulq %rdi, %rbx
addq $0x20, %rbx
xorl %r13d, %r13d
movq %r15, %rax
testq %rax, %rax
movl -0x48(%rbp), %edx
je 0x1885a
movq %rax, %r15
testl %edx, %edx
je 0x186bc
cmpq $0x0, 0x18(%r15)
movl -0x44(%rbp), %edx
je 0x186b7
xorl %edx, %edx
movq %rsi, %r13
jmp 0x186c1
movq %rsi, %r13
xorl %edx, %edx
leaq -0xb8(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rcx
callq 0x19342
testl %eax, %eax
jne 0x18852
addq %r14, %rbx
movq 0x18(%r15), %rax
movq %r13, %rsi
incl %esi
movq %r15, %r13
jmp 0x18698
movq 0x30(%rdx), %rax
movq (%rax), %r15
cmpl $0x0, 0x60(%r15)
je 0x18934
pushq $0x4
popq %rbx
leaq -0x90(%rbp), %rsi
movl %ebx, %edi
movq %rdx, %r12
callq 0xb09f
movq %r12, %rdi
movl %ebx, %esi
movl %ebx, %edx
callq 0x1961e
cmpl $0x5, %eax
je 0x18930
movl %eax, %r12d
testl %eax, %eax
jne 0x18976
movq -0x30(%rbp), %rbx
incl 0x80(%rbx)
leaq 0x68(%rbx), %rdi
andl $0x0, 0x58(%rbx)
callq 0x180a3
incl %eax
bswapl %eax
movl %eax, 0x68(%rbx)
movl -0x90(%rbp), %eax
movl %eax, 0x6c(%rbx)
movq %rbx, %rdi
callq 0x195ab
xorl %eax, %eax
movl %eax, 0x60(%r15)
movl %eax, 0x68(%r15)
cmpq $0x3, %rax
je 0x18922
movl $0xffffffff, 0x6c(%r15,%rax,4) # imm = 0xFFFFFFFF
incq %rax
jmp 0x1876b
movq %rsi, -0x50(%rbp)
movabsq $0x18e22d0082067f37, %rax # imm = 0x18E22D0082067F37
movq %rax, -0x90(%rbp)
movl %ecx, %eax
shrl $0x18, %eax
movb %al, -0x88(%rbp)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, -0x87(%rbp)
movb %ch, -0x86(%rbp)
movb %cl, -0x85(%rbp)
movl 0x80(%rdx), %eax
movl %ecx, %r12d
movl %eax, %ecx
bswapl %ecx
movl %ecx, -0x84(%rbp)
testl %eax, %eax
jne 0x187e1
leaq 0x68(%rdx), %rsi
pushq $0x8
popq %rdi
callq 0xb09f
movq -0x30(%rbp), %rdx
movq 0x68(%rdx), %rax
leaq -0x90(%rbp), %rbx
movq %rax, 0x10(%rbx)
pushq $0x1
popq %rdi
movq %rdx, %r13
pushq $0x18
popq %rdx
leaq -0xc0(%rbp), %r15
movq %rbx, %rsi
xorl %ecx, %ecx
movq %r15, %r8
callq 0x192e3
movl (%r15), %eax
movl 0x4(%r15), %ecx
movl %eax, %edx
bswapl %edx
movl %edx, 0x18(%rbx)
movl %ecx, %edx
bswapl %edx
movl %edx, 0x1c(%rbx)
movl %r12d, 0x38(%r13)
movb $0x0, 0x55(%r13)
movl %eax, 0x60(%r13)
movl %ecx, 0x64(%r13)
movb $0x1, 0x43(%r13)
movq 0x10(%r13), %rdi
movq (%rdi), %rax
pushq $0x20
popq %rdx
movq %rbx, %rsi
xorl %ecx, %ecx
callq *0x18(%rax)
testl %eax, %eax
je 0x188e7
movl %eax, %r12d
jmp 0x18a51
testl %edx, %edx
sete %al
testb $0x20, -0x40(%rbp)
sete %cl
xorl %r12d, %r12d
orb %al, %cl
movl $0x0, %r15d
jne 0x189b9
movq %rsi, -0x50(%rbp)
movq -0x30(%rbp), %rax
cmpb $0x0, 0x45(%rax)
je 0x1898f
movq 0x10(%rax), %rdi
callq 0x18445
movl %eax, %ecx
leaq (%rcx,%rbx), %rsi
decq %rsi
movq %rsi, %rax
cqto
idivq %rcx
subq %rdx, %rsi
leaq -0xb8(%rbp), %rax
movq %rsi, -0x40(%rbp)
movq %rsi, 0x10(%rax)
xorl %r15d, %r15d
cmpq -0x40(%rbp), %rbx
jge 0x189b2
leaq -0xb8(%rbp), %rdi
movq %r13, %rsi
movl -0x44(%rbp), %edx
movq %rbx, %rcx
callq 0x19342
testl %eax, %eax
jne 0x18852
addq %r14, %rbx
incl %r15d
jmp 0x188b8
cmpl $0x0, -0x40(%rbp)
movq -0x58(%rbp), %r15
movq %r13, %rdx
je 0x18916
cmpb $0x0, 0x44(%rdx)
je 0x18916
movq 0x10(%rdx), %rdi
movl -0x40(%rbp), %esi
andl $0x13, %esi
movq (%rdi), %rax
callq *0x28(%rax)
movq -0x30(%rbp), %rdx
testl %eax, %eax
jne 0x18852
movl -0x34(%rbp), %ecx
movq -0x50(%rbp), %rsi
jmp 0x18650
pushq $0x4
popq %rdx
movq -0x30(%rbp), %rdi
movl %edx, %esi
callq 0x1963f
movq -0x30(%rbp), %rdx
pushq $0x3
popq %rsi
movq %rdx, %rdi
callq 0x1965e
movq -0x30(%rbp), %rdx
orw $-0x1, 0x3c(%rdx)
pushq $0x1
popq %rbx
leaq -0x90(%rbp), %r15
movl %ebx, %r13d
movq %rdx, %rdi
movq %r15, %rsi
movl %ebx, %edx
movl %r13d, %ecx
callq 0x19682
movq -0x30(%rbp), %rdx
incl %r13d
cmpl $-0x1, %eax
je 0x18955
movl %eax, %r12d
jmp 0x1897a
movq -0x30(%rbp), %rdx
movl -0x34(%rbp), %ecx
testl %r12d, %r12d
movq -0x58(%rbp), %r15
jne 0x18a51
jmp 0x18644
movl -0x40(%rbp), %esi
andl $0x13, %esi
movq -0x98(%rbp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movq -0x30(%rbp), %rdi
movl %eax, %r12d
xorl %r15d, %r15d
movq -0x50(%rbp), %rsi
jmp 0x189c1
movl -0x48(%rbp), %edx
movq -0x50(%rbp), %rsi
testl %edx, %edx
movq -0x30(%rbp), %rdi
je 0x189ef
cmpb $0x0, 0x43(%rdi)
je 0x189ef
movq 0x20(%rdi), %rax
testq %rax, %rax
js 0x189ef
addl %r15d, %esi
imulq %r14, %rsi
addq $0x20, %rsi
cmpq %rax, %rsi
cmovleq %rax, %rsi
callq 0x19439
movq -0x30(%rbp), %rdi
movb $0x0, 0x43(%rdi)
movl 0x58(%rdi), %ebx
movq -0x58(%rbp), %r14
testq %r14, %r14
je 0x18a1a
testl %r12d, %r12d
jne 0x18a1a
incl %ebx
movl 0x28(%r14), %edx
movq -0x30(%rbp), %rdi
movl %ebx, %esi
callq 0x194b8
movl %eax, %r12d
movq 0x18(%r14), %r14
jmp 0x189f6
movq -0x60(%rbp), %r14
testl %r12d, %r12d
jne 0x18a41
testl %r15d, %r15d
jle 0x18a41
incl %ebx
decl %r15d
movl 0x28(%r13), %edx
movq -0x30(%rbp), %rdi
movl %ebx, %esi
callq 0x194b8
movl %eax, %r12d
jmp 0x18a1e
testl %r12d, %r12d
movq -0x58(%rbp), %r15
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %ecx
je 0x18a66
movl %r12d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ecx, %eax
andl $0xff00, %eax           # imm = 0xFF00
shrl $0x10, %ecx
orl %eax, %ecx
movw %cx, 0x56(%rdi)
movl %ebx, 0x58(%rdi)
cmpl $0x0, -0x48(%rbp)
je 0x18a95
incl 0x50(%rdi)
movl -0x44(%rbp), %eax
movl %eax, 0x5c(%rdi)
movq %rdi, %r12
callq 0x195ab
movl %ebx, 0x18(%r12)
xorl %r12d, %r12d
cmpq $0x0, 0x70(%r14)
je 0x18a51
testq %r15, %r15
je 0x18a51
movq 0x70(%r14), %rdi
movl 0x28(%r15), %esi
movq 0x8(%r15), %rdx
callq 0x1927c
movq 0x18(%r15), %r15
jmp 0x18a9f