// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: btreeDropTable
static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){
  int rc;
  MemPage *pPage = 0;
  BtShared *pBt = p->pBt;

  assert( sqlite3BtreeHoldsMutex(p) );
  assert( p->inTrans==TRANS_WRITE );
  assert( iTable>=2 );
  if( iTable>btreePagecount(pBt) ){
    return SQLITE_CORRUPT_BKPT;
  }

  rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0);
  if( rc ) return rc;
  rc = sqlite3BtreeClearTable(p, iTable, 0);
  if( rc ){
    releasePage(pPage);
    return rc;
  }

  *piMoved = 0;

#ifdef SQLITE_OMIT_AUTOVACUUM
  freePage(pPage, &rc);
  releasePage(pPage);
#else
  if( pBt->autoVacuum ){
    Pgno maxRootPgno;
    sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &maxRootPgno);

    if( iTable==maxRootPgno ){
      /* If the table being dropped is the table with the largest root-page
      ** number in the database, put the root page on the free list.
      */
      freePage(pPage, &rc);
      releasePage(pPage);
      if( rc!=SQLITE_OK ){
        return rc;
      }
    }else{
      /* The table being dropped does not have the largest root-page
      ** number in the database. So move the page that does into the
      ** gap left by the deleted root-page.
      */
      MemPage *pMove;
      releasePage(pPage);
      rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);
      if( rc!=SQLITE_OK ){
        return rc;
      }
      rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0);
      releasePage(pMove);
      if( rc!=SQLITE_OK ){
        return rc;
      }
      pMove = 0;
      rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);
      freePage(pMove, &rc);
      releasePage(pMove);
      if( rc!=SQLITE_OK ){
        return rc;
      }
      *piMoved = maxRootPgno;
    }

    /* Set the new 'max-root-page' value in the database header. This
    ** is the old value less one, less one more if that happens to
    ** be a root-page number, less one again if that is the
    ** PENDING_BYTE_PAGE.
    */
    maxRootPgno--;
    while( maxRootPgno==PENDING_BYTE_PAGE(pBt)
           || PTRMAP_ISPAGE(pBt, maxRootPgno) ){
      maxRootPgno--;
    }
    assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) );

    rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno);
  }else{
    freePage(pPage, &rc);
    releasePage(pPage);
  }
#endif
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3e7da0
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jbe 0x40a7e1
movl $0x12089, %edi          # imm = 0x12089
callq 0x3dff80
movl %eax, -0x4(%rbp)
jmp 0x40a9cb
movq -0x38(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3e6f40
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x40a807
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40a9cb
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x3fb250
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x40a834
movq -0x30(%rbp), %rdi
callq 0x3e9b70
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40a9cb
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x38(%rbp), %rax
cmpb $0x0, 0x21(%rax)
je 0x40a9af
movq -0x10(%rbp), %rdi
movl $0x4, %esi
leaq -0x3c(%rbp), %rdx
callq 0x3faf70
movl -0x14(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x40a892
movq -0x30(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x401990
movq -0x30(%rbp), %rdi
callq 0x3e9b70
cmpl $0x0, -0x24(%rbp)
je 0x40a88d
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40a9cb
jmp 0x40a947
movq -0x30(%rbp), %rdi
callq 0x3e9b70
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %esi
leaq -0x48(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3e6f40
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x40a8c1
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40a9cb
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x14(%rbp), %r8d
movl $0x1, %edx
xorl %r9d, %r9d
movl %r9d, %ecx
callq 0x3ea490
movl %eax, -0x24(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3e9b70
cmpl $0x0, -0x24(%rbp)
je 0x40a8fa
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40a9cb
movq $0x0, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %esi
leaq -0x48(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3e6f40
movl %eax, -0x24(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x401990
movq -0x48(%rbp), %rdi
callq 0x3e9b70
cmpl $0x0, -0x24(%rbp)
je 0x40a93e
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x40a9cb
movl -0x3c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %ecx
movl 0x235357(%rip), %eax    # 0x63fcb0
movq -0x38(%rbp), %rsi
xorl %edx, %edx
divl 0x34(%rsi)
movl %eax, %edx
addl $0x1, %edx
movb $0x1, %al
cmpl %edx, %ecx
movb %al, -0x4d(%rbp)
je 0x40a985
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x3e8c00
cmpl -0x3c(%rbp), %eax
sete %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x40a98e
jmp 0x40a999
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x40a950
movq -0x10(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl $0x4, %esi
callq 0x3c6370
movl %eax, -0x24(%rbp)
jmp 0x40a9c5
movq -0x30(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x401990
movq -0x30(%rbp), %rdi
callq 0x3e9b70
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)