// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: balance_deeper
static int balance_deeper(MemPage *pRoot, MemPage **ppChild){
  int rc;                        /* Return value from subprocedures */
  MemPage *pChild = 0;           /* Pointer to a new child page */
  Pgno pgnoChild = 0;            /* Page number of the new child page */
  BtShared *pBt = pRoot->pBt;    /* The BTree */

  assert( pRoot->nOverflow>0 );
  assert( sqlite3_mutex_held(pBt->mutex) );

  /* Make pRoot, the root page of the b-tree, writable. Allocate a new 
  ** page that will become the new right-child of pPage. Copy the contents
  ** of the node stored on pRoot into the new child page.
  */
  rc = sqlite3PagerWrite(pRoot->pDbPage);
  if( rc==SQLITE_OK ){
    rc = allocateBtreePage(pBt,&pChild,&pgnoChild,pRoot->pgno,0);
    copyNodeContent(pRoot, pChild, &rc);
    if( ISAUTOVACUUM ){
      ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot->pgno, &rc);
    }
  }
  if( rc ){
    *ppChild = 0;
    releasePage(pChild);
    return rc;
  }
  assert( sqlite3PagerIswriteable(pChild->pDbPage) );
  assert( sqlite3PagerIswriteable(pRoot->pDbPage) );
  assert( pChild->nCell==pRoot->nCell );

  TRACE(("BALANCE: copy root %d into %d\n", pRoot->pgno, pChild->pgno));

  /* Copy the overflow cells from pRoot to pChild */
  memcpy(pChild->aiOvfl, pRoot->aiOvfl,
         pRoot->nOverflow*sizeof(pRoot->aiOvfl[0]));
  memcpy(pChild->apOvfl, pRoot->apOvfl,
         pRoot->nOverflow*sizeof(pRoot->apOvfl[0]));
  pChild->nOverflow = pRoot->nOverflow;

  /* Zero the contents of pRoot. Then install pChild as the right-child. */
  zeroPage(pRoot, pChild->aData[0] & ~PTF_LEAF);
  put4byte(&pRoot->aData[pRoot->hdrOffset+8], pgnoChild);

  *ppChild = pChild;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x434e8
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x70(%rax), %ecx
leaq -0x28(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
xorl %r8d, %r8d
callq 0x2cef0
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x1c(%rbp), %rdx
callq 0x44c30
movq -0x38(%rbp), %rax
cmpb $0x0, 0x21(%rax)
je 0x434e6
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x10(%rbp), %rax
movl 0x70(%rax), %ecx
movl $0x5, %edx
leaq -0x1c(%rbp), %r8
callq 0x2dd40
jmp 0x434e8
cmpl $0x0, -0x1c(%rbp)
je 0x4350d
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rdi
callq 0x29fd0
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x435a9
movq -0x28(%rbp), %rdi
addq $0x14, %rdi
movq -0x10(%rbp), %rsi
addq $0x14, %rsi
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, %edx
shlq %rdx
callq 0x82f0
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, %edx
shlq $0x3, %rdx
callq 0x82f0
movq -0x10(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rax
movzbl (%rax), %esi
andl $-0x9, %esi
callq 0x2a920
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
addl $0x8, %eax
cltq
addq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0x22060
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)