// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x8(%rbp), %rax
cmpb $0x0, 0x21(%rax)
je 0x2cd5c
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x2b950
movl %eax, %ecx
movb $0x1, %al
cmpl -0x3c(%rbp), %ecx
movb %al, -0x3e(%rbp)
je 0x2ccf1
movl -0x3c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl 0xa3bf8(%rip), %eax     # 0xd08d0
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divl 0x30(%rcx)
movl %eax, %ecx
movl -0x44(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x3e(%rbp)
movb -0x3e(%rbp), %al
testb $0x1, %al
jne 0x2ccfa
jmp 0x2cd05
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2ccb4
movl -0x3c(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2ab10
movl %eax, %ecx
movl -0x48(%rbp), %eax
cmpl %ecx, %eax
ja 0x2cd5a
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %esi
leaq -0x3d(%rbp), %rdx
leaq -0x38(%rbp), %rcx
callq 0x2cdf0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x2cd58
movzbl -0x3d(%rbp), %eax
cmpl $0x4, %eax
jne 0x2cd58
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x2cd58
movl -0x3c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x65, -0x34(%rbp)
jmp 0x2cd5a
jmp 0x2cd5c
cmpl $0x0, -0x34(%rbp)
jne 0x2cd9f
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
xorl %ecx, %ecx
movl $0x2, %eax
cmpq $0x0, %rdx
cmovel %eax, %ecx
leaq -0x30(%rbp), %rdx
callq 0x29ed0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x2cd9d
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x20a50
movl %eax, -0x24(%rbp)
jmp 0x2cd9f
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x2cdbc
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x2cdc5
movq -0x30(%rbp), %rdi
callq 0x29fd0
cmpl $0x65, -0x34(%rbp)
jne 0x2cdd2
xorl %eax, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2cdd8
movl -0x34(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)