// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rdx, %rbx
movq %rdi, %r12
movq $0x0, -0x38(%rbp)
cmpb $0x0, 0x21(%rdi)
je 0x21c95
movq %r13, -0x48(%rbp)
movl 0x72c26(%rip), %ecx     # 0x94840
movl $0xcccccccd, %edi       # imm = 0xCCCCCCCD
movl %esi, %r8d
movl %r8d, %r13d
leal 0x1(%r13), %r8d
movl $0x0, %eax
cmpl $0x2, %r8d
jb 0x21c70
movl 0x34(%r12), %r9d
imulq %rdi, %r9
shrq $0x22, %r9
incl %r9d
leal -0x1(%r13), %r10d
movl %r10d, %eax
xorl %edx, %edx
divl %r9d
subl %edx, %r10d
movl %ecx, %eax
xorl %edx, %edx
divl 0x30(%r12)
leal 0x1(%r10), %edx
xorl %r9d, %r9d
cmpl %eax, %edx
sete %r9b
leal (%r10,%r9), %eax
addl $0x2, %eax
cmpl %eax, %r8d
je 0x21c22
movl %ecx, %eax
xorl %edx, %edx
divl 0x30(%r12)
cmpl %eax, %r13d
je 0x21c22
incl %r13d
xorl %r15d, %r15d
cmpl 0x3c(%r12), %r13d
jbe 0x21c9d
xorl %r14d, %r14d
jmp 0x21cde
xorl %r15d, %r15d
xorl %r14d, %r14d
jmp 0x21ce2
movl %esi, -0x30(%rbp)
leaq -0x29(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
movq %r12, %rdi
movl %r13d, %esi
callq 0x21d4e
movl %eax, %r14d
testl %eax, %eax
jne 0x21cdb
cmpb $0x4, -0x29(%rbp)
movl -0x30(%rbp), %esi
jne 0x21cde
xorl %eax, %eax
cmpl %esi, -0x3c(%rbp)
cmovnel %eax, %r13d
movl $0x65, %r14d
cmovnel %eax, %r14d
movl %r13d, %r15d
jmp 0x21cde
movl -0x30(%rbp), %esi
movq -0x48(%rbp), %r13
testl %r14d, %r14d
jne 0x21d15
xorl %ecx, %ecx
testq %rbx, %rbx
sete %cl
addl %ecx, %ecx
leaq -0x38(%rbp), %rdx
movq %r12, %rdi
callq 0x2035c
movl %eax, %r14d
testl %eax, %eax
jne 0x21d15
movq -0x38(%rbp), %rax
movq 0x50(%rax), %rax
movl (%rax), %r15d
bswapl %r15d
xorl %r14d, %r14d
movl %r15d, (%r13)
movq -0x38(%rbp), %rax
testq %rbx, %rbx
je 0x21d27
movq %rax, (%rbx)
jmp 0x21d35
testq %rax, %rax
je 0x21d35
movq 0x68(%rax), %rdi
callq 0xdcd4
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