// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: getOverflowPage
static int getOverflowPage(
  BtShared *pBt,               /* The database file */
  Pgno ovfl,                   /* Current overflow page number */
  MemPage **ppPage,            /* OUT: MemPage handle (may be NULL) */
  Pgno *pPgnoNext              /* OUT: Next overflow page number */
){
  Pgno next = 0;
  MemPage *pPage = 0;
  int rc = SQLITE_OK;

  assert( sqlite3_mutex_held(pBt->mutex) );
  assert(pPgnoNext);

#ifndef SQLITE_OMIT_AUTOVACUUM
  /* Try to find the next page in the overflow list using the
  ** autovacuum pointer-map pages. Guess that the next page in 
  ** the overflow list is page number (ovfl+1). If that guess turns 
  ** out to be wrong, fall back to loading the data of page 
  ** number ovfl to determine the next page number.
  */
  if( pBt->autoVacuum ){
    Pgno pgno;
    Pgno iGuess = ovfl+1;
    u8 eType;

    while( PTRMAP_ISPAGE(pBt, iGuess) || iGuess==PENDING_BYTE_PAGE(pBt) ){
      iGuess++;
    }

    if( iGuess<=btreePagecount(pBt) ){
      rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
      if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){
        next = iGuess;
        rc = SQLITE_DONE;
      }
    }
  }
#endif

  assert( next==0 || rc==SQLITE_DONE );
  if( rc==SQLITE_OK ){
    rc = btreeGetPage(pBt, ovfl, &pPage, (ppPage==0) ? PAGER_GET_READONLY : 0);
    assert( rc==SQLITE_OK || pPage==0 );
    if( rc==SQLITE_OK ){
      next = get4byte(pPage->aData);
    }
  }

  *pPgnoNext = next;
  if( ppPage ){
    *ppPage = pPage;
  }else{
    releasePage(pPage);
  }
  return (rc==SQLITE_DONE ? SQLITE_OK : rc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, -0x48(%rbp)
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %r12
movq $0x0, -0x38(%rbp)
cmpb $0x0, 0x21(%rdi)
je 0x2195a
movl 0x72f56(%rip), %ecx     # 0x94840
movl $0xcccccccd, %edi       # imm = 0xCCCCCCCD
movl %r15d, %r8d
movl %r8d, %r13d
leal 0x1(%r13), %r8d
movl $0x0, %eax
cmpl $0x2, %r8d
jb 0x2193d
movl 0x34(%r12), %r9d
imulq %rdi, %r9
shrq $0x22, %r9
incl %r9d
leal -0x1(%r13), %esi
movl %esi, %eax
xorl %edx, %edx
divl %r9d
subl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl 0x30(%r12)
leal 0x1(%rsi), %edx
xorl %r9d, %r9d
cmpl %eax, %edx
sete %r9b
leal (%rsi,%r9), %eax
addl $0x2, %eax
cmpl %eax, %r8d
je 0x218f2
movl %ecx, %eax
xorl %edx, %edx
divl 0x30(%r12)
cmpl %eax, %r13d
je 0x218f2
incl %r13d
cmpl 0x3c(%r12), %r13d
jbe 0x2197f
xorl %ecx, %ecx
testq %rbx, %rbx
sete %cl
addl %ecx, %ecx
leaq -0x38(%rbp), %rdx
movq %r12, %rdi
movl %r15d, %esi
callq 0x20068
testl %eax, %eax
je 0x219ad
movl %eax, %r14d
xorl %r13d, %r13d
jmp 0x219be
leaq -0x29(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
movq %r12, %rdi
movl %r13d, %esi
callq 0x21a08
movl %eax, %r14d
testl %eax, %eax
jne 0x219fa
cmpb $0x4, -0x29(%rbp)
jne 0x219fa
cmpl %r15d, -0x3c(%rbp)
jne 0x2195a
movl $0x65, %r14d
jmp 0x219be
movq -0x38(%rbp), %rax
movq 0x50(%rax), %rax
movl (%rax), %r13d
bswapl %r13d
xorl %r14d, %r14d
movq -0x48(%rbp), %rax
movl %r13d, (%rax)
movq -0x38(%rbp), %rax
testq %rbx, %rbx
je 0x219d3
movq %rax, (%rbx)
jmp 0x219e1
testq %rax, %rax
je 0x219e1
movq 0x68(%rax), %rdi
callq 0xddd3
xorl %eax, %eax
cmpl $0x65, %r14d
cmovnel %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r14d, %r14d
jne 0x2197a
jmp 0x2195a