// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: relocatePage
static int relocatePage(
  BtShared *pBt,           /* Btree */
  MemPage *pDbPage,        /* Open page to move */
  u8 eType,                /* Pointer map 'type' entry for pDbPage */
  Pgno iPtrPage,           /* Pointer map 'page-no' entry for pDbPage */
  Pgno iFreePage,          /* The location to move pDbPage to */
  int isCommit             /* isCommit flag passed to sqlite3PagerMovepage */
){
  MemPage *pPtrPage;   /* The page that contains a pointer to pDbPage */
  Pgno iDbPage = pDbPage->pgno;
  Pager *pPager = pBt->pPager;
  int rc;

  assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 || 
      eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE );
  assert( sqlite3_mutex_held(pBt->mutex) );
  assert( pDbPage->pBt==pBt );

  /* Move page iDbPage from its current location to page number iFreePage */
  TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n", 
      iDbPage, iFreePage, iPtrPage, eType));
  rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);
  if( rc!=SQLITE_OK ){
    return rc;
  }
  pDbPage->pgno = iFreePage;

  /* If pDbPage was a btree-page, then it may have child pages and/or cells
  ** that point to overflow pages. The pointer map entries for all these
  ** pages need to be changed.
  **
  ** If pDbPage is an overflow page, then the first 4 bytes may store a
  ** pointer to a subsequent overflow page. If this is the case, then
  ** the pointer map needs to be updated for the subsequent overflow page.
  */
  if( eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE ){
    rc = setChildPtrmaps(pDbPage);
    if( rc!=SQLITE_OK ){
      return rc;
    }
  }else{
    Pgno nextOvfl = get4byte(pDbPage->aData);
    if( nextOvfl!=0 ){
      ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, &rc);
      if( rc!=SQLITE_OK ){
        return rc;
      }
    }
  }

  /* Fix the database pointer on page iPtrPage that pointed at iDbPage so
  ** that it points at iFreePage. Also fix the pointer map entry for
  ** iPtrPage.
  */
  if( eType!=PTRMAP_ROOTPAGE ){
    rc = btreeGetPage(pBt, iPtrPage, &pPtrPage, 0);
    if( rc!=SQLITE_OK ){
      return rc;
    }
    rc = sqlite3PagerWrite(pPtrPage->pDbPage);
    if( rc!=SQLITE_OK ){
      releasePage(pPtrPage);
      return rc;
    }
    rc = modifyPagePointer(pPtrPage, iDbPage, iFreePage, eType);
    releasePage(pPtrPage);
    if( rc==SQLITE_OK ){
      ptrmapPut(pBt, iFreePage, eType, iPtrPage, &rc);
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %al, -0x19(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rsi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
callq 0x2da20
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x2d830
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d94b
movl -0x24(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x70(%rax)
movzbl -0x19(%rbp), %eax
cmpl $0x5, %eax
je 0x2d84c
movzbl -0x19(%rbp), %eax
cmpl $0x1, %eax
jne 0x2d86b
movq -0x18(%rbp), %rdi
callq 0x2dbf0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x2d869
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d94b
jmp 0x2d8ae
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x20a50
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x2d8ac
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %esi
movl -0x24(%rbp), %ecx
movl $0x4, %edx
leaq -0x44(%rbp), %r8
callq 0x2dd40
cmpl $0x0, -0x44(%rbp)
je 0x2d8aa
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d94b
jmp 0x2d8ac
jmp 0x2d8ae
movzbl -0x19(%rbp), %eax
cmpl $0x1, %eax
je 0x2d945
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
leaq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x29ed0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x2d8de
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d94b
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x2d905
movq -0x30(%rbp), %rdi
callq 0x29fd0
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2d94b
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x24(%rbp), %edx
movzbl -0x19(%rbp), %ecx
callq 0x2de80
movl %eax, -0x44(%rbp)
movq -0x30(%rbp), %rdi
callq 0x29fd0
cmpl $0x0, -0x44(%rbp)
jne 0x2d943
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
movb -0x19(%rbp), %al
movl -0x20(%rbp), %ecx
leaq -0x44(%rbp), %r8
movzbl %al, %edx
callq 0x2dd40
jmp 0x2d945
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)