// File: /workspace/github_c_makefile_star2_O0/skeeto[P]flappy/sqlite3.c
// Function: sqlite3BtreeEnter
SQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){
  Btree *pLater;

  /* Some basic sanity checking on the Btree.  The list of Btrees
  ** connected by pNext and pPrev should be in sorted order by
  ** Btree.pBt value. All elements of the list should belong to
  ** the same connection. Only shared Btrees are on the list. */
  assert( p->pNext==0 || p->pNext->pBt>p->pBt );
  assert( p->pPrev==0 || p->pPrev->pBt<p->pBt );
  assert( p->pNext==0 || p->pNext->db==p->db );
  assert( p->pPrev==0 || p->pPrev->db==p->db );
  assert( p->sharable || (p->pNext==0 && p->pPrev==0) );

  /* Check for locking consistency */
  assert( !p->locked || p->wantToLock>0 );
  assert( p->sharable || p->wantToLock==0 );

  /* We should already hold a lock on the database connection */
  assert( sqlite3_mutex_held(p->db->mutex) );

  /* Unless the database is sharable and unlocked, then BtShared.db
  ** should already be set correctly. */
  assert( (p->locked==0 && p->sharable) || p->pBt->db==p->db );

  if( !p->sharable ) return;
  p->wantToLock++;
  if( p->locked ) return;

  /* In most cases, we should be able to acquire the lock we
  ** want without having to go throught the ascending lock
  ** procedure that follows.  Just be sure not to block.
  */
  if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){
    p->pBt->db = p->db;
    p->locked = 1;
    return;
  }

  /* To avoid deadlock, first release all locks with a larger
  ** BtShared address.  Then acquire our lock.  Then reacquire
  ** the other BtShared locks that we used to hold in ascending
  ** order.
  */
  for(pLater=p->pNext; pLater; pLater=pLater->pNext){
    assert( pLater->sharable );
    assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );
    assert( !pLater->locked || pLater->wantToLock>0 );
    if( pLater->locked ){
      unlockBtreeMutex(pLater);
    }
  }
  lockBtreeMutex(p);
  for(pLater=p->pNext; pLater; pLater=pLater->pNext){
    if( pLater->wantToLock ){
      lockBtreeMutex(pLater);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpb $0x0, 0x11(%rax)
jne 0x10f6b
jmp 0x1102f
movq -0x8(%rbp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rax
cmpb $0x0, 0x12(%rax)
je 0x10f87
jmp 0x1102f
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rax), %rdi
callq 0xcd90
cmpl $0x0, %eax
jne 0x10fba
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movb $0x1, 0x12(%rax)
jmp 0x1102f
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x10ff0
movq -0x10(%rbp), %rax
cmpb $0x0, 0x12(%rax)
je 0x10fe0
movq -0x10(%rbp), %rdi
callq 0x2d310
jmp 0x10fe2
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x10fc6
movq -0x8(%rbp), %rdi
callq 0x2d350
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1102f
movq -0x10(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x1101f
movq -0x10(%rbp), %rdi
callq 0x2d350
jmp 0x11021
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x11005
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)