// File: /workspace/github_c_makefile_star2_O1/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 $0x78, %rsp
movq %rdi, %r15
movq %rsi, -0x90(%rbp)
movl %ecx, -0x30(%rbp)
testl %ecx, %ecx
je 0x1a9b4
movq %rsi, -0x90(%rbp)
xorl %eax, %eax
testq %rsi, %rsi
je 0x1a9b9
leaq -0x90(%rbp), %rcx
xorl %r8d, %r8d
cmpl %edx, 0x28(%rsi)
setbe %r8b
leaq 0x18(%rsi), %rdi
cmovbeq %rdi, %rcx
addl %r8d, %eax
movq 0x18(%rsi), %rsi
movq %rsi, (%rcx)
testq %rsi, %rsi
jne 0x1a991
jmp 0x1a9b9
movl $0x1, %eax
movl %edx, -0x2c(%rbp)
addl %eax, 0xf8(%r15)
movq -0x90(%rbp), %rbx
cmpl $0x1, 0x28(%rbx)
jne 0x1a9d8
movq %rbx, %rdi
callq 0x1b7f7
movq %rbx, -0x98(%rbp)
movq 0x118(%r15), %r13
movl 0xbc(%r15), %eax
movq %rax, -0x80(%rbp)
movzbl 0xe(%r15), %eax
movl %eax, -0x38(%rbp)
xorl %ebx, %ebx
cmpw $0x0, 0x3c(%r13)
jne 0x1ab10
movq 0x30(%r13), %rax
movq (%rax), %r14
cmpl $0x0, 0x60(%r14)
je 0x1aabc
leaq -0x60(%rbp), %rsi
movl $0x4, %edi
callq 0xb9d9
xorl %ebx, %ebx
cmpb $0x0, 0x3f(%r13)
jne 0x1aa4b
movq 0x8(%r13), %rdi
movq (%rdi), %rax
movl $0x4, %esi
movl $0x4, %edx
movl $0xa, %ecx
callq *0x70(%rax)
movl %eax, %ebx
cmpl $0x5, %ebx
je 0x1aabc
testl %ebx, %ebx
jne 0x1ab10
incl 0x80(%r13)
xorl %ebx, %ebx
movl %ebx, 0x58(%r13)
movl 0x68(%r13), %eax
bswapl %eax
incl %eax
bswapl %eax
movl %eax, 0x68(%r13)
movl -0x60(%rbp), %eax
movl %eax, 0x6c(%r13)
movq %r13, %rdi
callq 0x1bbb8
movl %ebx, 0x60(%r14)
movl %ebx, 0x68(%r14)
movl $0xffffffff, 0x6c(%r14,%rbx,4) # imm = 0xFFFFFFFF
incq %rbx
cmpq $0x3, %rbx
jne 0x1aa8a
cmpb $0x0, 0x3f(%r13)
jne 0x1aabc
movq 0x8(%r13), %rdi
movq (%rdi), %rax
movl $0x4, %esi
movl $0x4, %edx
movl $0x9, %ecx
callq *0x70(%rax)
movq %r15, %r12
cmpb $0x0, 0x3f(%r13)
jne 0x1aadf
movq 0x8(%r13), %rdi
movq (%rdi), %rax
movl $0x3, %esi
movl $0x1, %edx
movl $0x5, %ecx
callq *0x70(%rax)
movw $0xffff, 0x3c(%r13)     # imm = 0xFFFF
movl $0x1, %r14d
leaq -0x60(%rbp), %r15
movq %r13, %rdi
movq %r15, %rsi
movl $0x1, %edx
movl %r14d, %ecx
callq 0x1bc42
incl %r14d
cmpl $-0x1, %eax
je 0x1aaf0
movl %eax, %ebx
movq %r12, %r15
movq %r13, -0x40(%rbp)
testl %ebx, %ebx
jne 0x1aef5
movq -0x40(%rbp), %rbx
movl 0x58(%rbx), %r13d
testq %r13, %r13
je 0x1ab31
xorl %r12d, %r12d
jmp 0x1ac48
movabsq $0x18e22d0082067f37, %rax # imm = 0x18E22D0082067F37
movq %rax, -0x60(%rbp)
movq -0x80(%rbp), %rcx
movl %ecx, %eax
shrl $0x18, %eax
movb %al, -0x58(%rbp)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, -0x57(%rbp)
movb %ch, -0x56(%rbp)
movb %cl, -0x55(%rbp)
movl 0x80(%rbx), %eax
movl %eax, %ecx
bswapl %ecx
movl %ecx, -0x54(%rbp)
testl %eax, %eax
jne 0x1ab78
leaq 0x68(%rbx), %rsi
movl $0x8, %edi
callq 0xb9d9
movq 0x68(%rbx), %rax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
movq $-0x8, %rdx
xorl %ecx, %ecx
addl %eax, %ecx
addl -0x58(%rbp,%rdx), %ecx
addl -0x54(%rbp,%rdx), %eax
addl %ecx, %eax
addq $0x8, %rdx
cmpq $0x10, %rdx
jb 0x1ab8b
movl %ecx, %edx
shrl $0x18, %edx
leaq -0x60(%rbp), %rsi
movb %dl, 0x18(%rsi)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, 0x19(%rsi)
movb %ch, -0x46(%rbp)
movb %cl, 0x1b(%rsi)
movl %eax, %edx
shrl $0x18, %edx
movb %dl, 0x1c(%rsi)
movl %eax, %edx
shrl $0x10, %edx
movb %dl, 0x1d(%rsi)
movb %ah, -0x42(%rbp)
movb %al, 0x1f(%rsi)
movq -0x40(%rbp), %rdx
movq -0x80(%rbp), %rdi
movl %edi, 0x38(%rdx)
movb $0x0, 0x55(%rdx)
movl %ecx, 0x60(%rdx)
movl %eax, 0x64(%rdx)
movb $0x1, 0x43(%rdx)
movq 0x10(%rdx), %rdi
movq (%rdi), %rax
xorl %r14d, %r14d
movl $0x20, %edx
xorl %ecx, %ecx
callq *0x18(%rax)
testl %eax, %eax
je 0x1ac09
movl %eax, %r12d
movl %eax, %ebx
jmp 0x1ac3f
cmpl $0x0, -0x38(%rbp)
je 0x1ac39
movq -0x40(%rbp), %rax
cmpb $0x0, 0x44(%rax)
je 0x1ac39
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x38(%rbp), %esi
andl $0x13, %esi
movq (%rdi), %rax
callq *0x28(%rax)
testl %eax, %eax
je 0x1ac39
movl %eax, %r12d
xorl %r14d, %r14d
jmp 0x1ac05
xorl %r12d, %r12d
movb $0x1, %r14b
testb %r14b, %r14b
je 0x1aef5
movq %r15, -0x70(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0x10(%rax), %rdi
movq %rdi, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x80(%rbp), %rax
movl %eax, -0x44(%rbp)
addl $0x18, %eax
cltq
movq %r13, %r15
movq %rax, -0x88(%rbp)
imulq %rax, %r15
addq $0x20, %r15
xorl %r14d, %r14d
movq -0x98(%rbp), %rax
testq %rax, %rax
je 0x1acee
movq %rdi, -0x68(%rbp)
movq %rax, %r12
cmpl $0x0, -0x30(%rbp)
je 0x1acaf
cmpq $0x0, 0x18(%r12)
movl -0x2c(%rbp), %edx
je 0x1acb1
xorl %edx, %edx
leaq -0x60(%rbp), %rdi
movq %r12, %rsi
movq %r15, %rcx
callq 0x1b8e6
testl %eax, %eax
cmovnel %eax, %ebx
jne 0x1aef1
movq %r12, %rcx
movl %eax, %r12d
addq -0x88(%rbp), %r15
movq 0x18(%rcx), %rax
incl %r13d
testq %rax, %rax
jne 0x1ac9b
movq %rcx, -0x78(%rbp)
movq -0x68(%rbp), %rdi
jmp 0x1acf6
movq $0x0, -0x78(%rbp)
cmpl $0x0, -0x30(%rbp)
sete %al
testb $0x20, -0x38(%rbp)
sete %cl
orb %al, %cl
jne 0x1adf5
movq -0x40(%rbp), %rax
cmpb $0x0, 0x45(%rax)
je 0x1ad2a
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq 0x58(%rax), %rax
testq %rax, %rax
je 0x1ad3e
callq *%rax
jmp 0x1ad43
movl -0x38(%rbp), %esi
andl $0x13, %esi
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, %r12d
jmp 0x1adf5
movl $0x1000, %eax           # imm = 0x1000
movl $0x10000, %ecx          # imm = 0x10000
cmpl %ecx, %eax
cmovll %eax, %ecx
cmpl $0x20, %eax
movl $0x200, %eax            # imm = 0x200
cmovgel %ecx, %eax
movl %eax, %ecx
leaq (%r15,%rcx), %rsi
decq %rsi
movq %rsi, %rax
cqto
idivq %rcx
subq %rdx, %rsi
movq %rsi, -0x50(%rbp)
xorl %r14d, %r14d
movq %rsi, -0x38(%rbp)
cmpq %rsi, %r15
setl %al
jge 0x1ade9
movb %al, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
movq -0x78(%rbp), %rsi
movl -0x2c(%rbp), %edx
movq %r15, %rcx
callq 0x1b8e6
testl %eax, %eax
je 0x1ad9e
movl %eax, %r12d
jmp 0x1ade3
addq -0x88(%rbp), %r15
movl $0x1, %eax
movl %eax, %r14d
cmpq -0x38(%rbp), %r15
setl %al
jge 0x1af3d
movb %al, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
movq -0x78(%rbp), %rsi
movl -0x2c(%rbp), %edx
movq %r15, %rcx
callq 0x1b8e6
movl %eax, %r12d
leal 0x1(%r14), %eax
addq -0x88(%rbp), %r15
testl %r12d, %r12d
je 0x1adaa
movl %r12d, %ebx
movb -0x68(%rbp), %al
testb %al, %al
movq -0x70(%rbp), %r15
jne 0x1aef5
cmpl $0x0, -0x30(%rbp)
movq -0x40(%rbp), %rbx
je 0x1ae33
cmpb $0x0, 0x43(%rbx)
je 0x1ae33
movq 0x20(%rbx), %rax
testq %rax, %rax
js 0x1ae33
addl %r14d, %r13d
imulq -0x88(%rbp), %r13
addq $0x20, %r13
cmpq %rax, %r13
cmovleq %rax, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1b9e1
movb $0x0, 0x43(%rbx)
movl 0x58(%rbx), %r15d
cmpq $0x0, -0x98(%rbp)
movq %rbx, %r13
je 0x1ae72
testl %r12d, %r12d
jne 0x1ae72
movq -0x98(%rbp), %rbx
incl %r15d
movl 0x28(%rbx), %edx
movq %r13, %rdi
movl %r15d, %esi
callq 0x1ba60
movl %eax, %r12d
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
je 0x1ae72
testl %r12d, %r12d
je 0x1ae50
testl %r12d, %r12d
sete %al
testl %r14d, %r14d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1aeb4
movq -0x78(%rbp), %r12
incl %r15d
movl 0x28(%r12), %edx
movq %r13, %rdi
movl %r15d, %esi
callq 0x1ba60
movl %eax, %ebx
testl %eax, %eax
sete %al
jne 0x1aeb7
leal -0x1(%r14), %ecx
cmpl $0x1, %r14d
movl %ecx, %r14d
jg 0x1ae89
jmp 0x1aeb7
movl %r12d, %ebx
testb %al, %al
je 0x1aef1
movq -0x80(%rbp), %rcx
movl %ecx, %eax
andl $0xff00, %eax           # imm = 0xFF00
shrl $0x10, %ecx
orl %eax, %ecx
movw %cx, 0x56(%r13)
movl %r15d, 0x58(%r13)
cmpl $0x0, -0x30(%rbp)
je 0x1aef1
incl 0x50(%r13)
movl -0x2c(%rbp), %eax
movl %eax, 0x5c(%r13)
movq %r13, %rdi
callq 0x1bbb8
movl %r15d, 0x18(%r13)
movq -0x70(%rbp), %r15
testl %ebx, %ebx
jne 0x1af2c
cmpq $0x0, 0x70(%r15)
sete %al
movq -0x90(%rbp), %r14
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x1af2c
movq 0x70(%r15), %rdi
movl 0x28(%r14), %esi
movq 0x8(%r14), %rdx
callq 0x1b826
movq 0x18(%r14), %r14
testq %r14, %r14
jne 0x1af12
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
jmp 0x1ade9