LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walBusyLock
static int walBusyLock(
  Wal *pWal,                      /* WAL connection */
  int (*xBusy)(void*),            /* Function to call when busy */
  void *pBusyArg,                 /* Context argument for xBusyHandler */
  int lockIdx,                    /* Offset of first byte to lock */
  int n                           /* Number of bytes to lock */
){
  int rc;
  do {
    rc = walLockExclusive(pWal, lockIdx, n);
  }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %edx
callq 0x23020
movl %eax, -0x24(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x10(%rbp)
movb %al, -0x25(%rbp)
je 0x25a57
xorl %eax, %eax
cmpl $0x5, -0x24(%rbp)
movb %al, -0x25(%rbp)
jne 0x25a57
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
setne %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
testb $0x1, %al
jne 0x25a1b
movl -0x24(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3WalEndWriteTransaction
SQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal){
  if( pWal->writeLock ){
    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
    pWal->writeLock = 0;
    pWal->truncateOnCommit = 0;
  }
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpb $0x0, 0x40(%rax)
je 0x25f66
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x23070
movq -0x8(%rbp), %rax
movb $0x0, 0x40(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x43(%rax)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walIteratorNext
static int walIteratorNext(
  WalIterator *p,               /* Iterator */
  u32 *piPage,                  /* OUT: The page number of the next page */
  u32 *piFrame                  /* OUT: Wal frame index of next page */
){
  u32 iMin;                     /* Result pgno must be greater than iMin */
  u32 iRet = 0xFFFFFFFF;        /* 0xffffffff is never a valid page number */
  int i;                        /* For looping through segments */

  iMin = p->iPrior;
  assert( iMin<0xffffffff );
  for(i=p->nSegment-1; i>=0; i--){
    struct WalSegment *pSegment = &p->aSegment[i];
    while( pSegment->iNext<pSegment->nEntry ){
      u32 iPg = pSegment->aPgno[pSegment->aIndex[pSegment->iNext]];
      if( iPg>iMin ){
        if( iPg<iRet ){
          iRet = iPg;
          *piFrame = pSegment->iZero + pSegment->aIndex[pSegment->iNext];
        }
        break;
      }
      pSegment->iNext++;
    }
  }

  *piPage = p->iPrior = iRet;
  return (iRet==0xFFFFFFFF);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x262a5
movq -0x8(%rbp), %rax
addq $0x8, %rax
movslq -0x24(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x26295
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq -0x30(%rbp), %rdx
movslq (%rdx), %rdx
movzwl (%rcx,%rdx,2), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jbe 0x26288
movl -0x34(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x26286
movl -0x34(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rdx
movslq (%rdx), %rdx
movzwl (%rax,%rdx,2), %eax
addl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x26295
movq -0x30(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x2621e
jmp 0x26297
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x261fd
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
cmpl $-0x1, -0x20(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BitvecDestroy
SQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec *p){
  if( p==0 ) return;
  if( p->iDivisor ){
    unsigned int i;
    for(i=0; i<BITVEC_NPTR; i++){
      sqlite3BitvecDestroy(p->u.apSub[i]);
    }
  }
  sqlite3_free(p);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x26645
jmp 0x26686
movq -0x8(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x2667d
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpq $0x3e, %rax
jae 0x2667b
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movq 0x10(%rax,%rcx,8), %rdi
callq 0x26630
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x26656
jmp 0x2667d
movq -0x8(%rbp), %rdi
callq 0xa420
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: releaseAllSavepoints
static void releaseAllSavepoints(Pager *pPager){
  int ii;               /* Iterator for looping through Pager.aSavepoint */
  for(ii=0; ii<pPager->nSavepoint; ii++){
    sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);
  }
  if( !pPager->exclusiveMode || sqlite3IsMemJournal(pPager->sjfd) ){
    sqlite3OsClose(pPager->sjfd);
  }
  sqlite3_free(pPager->aSavepoint);
  pPager->aSavepoint = 0;
  pPager->nSavepoint = 0;
  pPager->nSubRec = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x80(%rcx), %eax
jge 0x266d9
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x26630
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x266a3
movq -0x8(%rbp), %rax
cmpb $0x0, 0x8(%rax)
je 0x266f5
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x267f0
cmpl $0x0, %eax
je 0x26702
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x20ea0
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0xa420
movq -0x8(%rbp), %rax
movq $0x0, 0x78(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x80(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x38(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3WalEndReadTransaction
SQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal){
  sqlite3WalEndWriteTransaction(pWal);
  if( pWal->readLock>=0 ){
    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));
    pWal->readLock = -1;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x25f30
movq -0x8(%rbp), %rax
movswl 0x3c(%rax), %eax
cmpl $0x0, %eax
jl 0x26780
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movswl 0x3c(%rax), %esi
addl $0x3, %esi
callq 0x230b0
movq -0x8(%rbp), %rax
movw $0xffff, 0x3c(%rax)     # imm = 0xFFFF
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerUnlockDb
static int pagerUnlockDb(Pager *pPager, int eLock){
  int rc = SQLITE_OK;

  assert( !pPager->exclusiveMode || pPager->eLock==eLock );
  assert( eLock==NO_LOCK || eLock==SHARED_LOCK );
  assert( eLock!=NO_LOCK || pagerUseWal(pPager)==0 );
  if( isOpen(pPager->fd) ){
    assert( pPager->eLock>=eLock );
    rc = sqlite3OsUnlock(pPager->fd, eLock);
    if( pPager->eLock!=UNKNOWN_LOCK ){
      pPager->eLock = (u8)eLock;
    }
    IOTRACE(("UNLOCK %p %d\n", pPager, eLock))
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, (%rax)
je 0x267e2
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movl -0xc(%rbp), %esi
callq 0x26810
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x5, %eax
je 0x267e0
movl -0xc(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x14(%rax)
jmp 0x267e2
movl -0x10(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerRollbackWal
static int pagerRollbackWal(Pager *pPager){
  int rc;                         /* Return Code */
  PgHdr *pList;                   /* List of dirty pages to revert */

  /* For all pages in the cache that are currently dirty or have already
  ** been written (but not committed) to the log file, do one of the 
  ** following:
  **
  **   + Discard the cached page (if refcount==0), or
  **   + Reload page content from the database (if refcount>0).
  */
  pPager->dbSize = pPager->dbOrigSize;
  rc = sqlite3WalUndo(pPager->pWal, pagerUndoCallback, (void *)pPager);
  pList = sqlite3PcacheDirtyList(pPager->pPCache);
  while( pList && rc==SQLITE_OK ){
    PgHdr *pNext = pList->pDirty;
    rc = pagerUndoCallback((void *)pPager, pList->pgno);
    pList = pNext;
  }

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x8(%rbp), %rax
movq 0x118(%rax), %rdi
movq -0x8(%rbp), %rdx
leaq 0x870(%rip), %rsi       # 0x27c90
callq 0x27bb0
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rdi
callq 0x27d50
movq %rax, -0x18(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x18(%rbp)
movb %al, -0x21(%rbp)
je 0x27452
cmpl $0x0, -0xc(%rbp)
sete %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0x2745b
jmp 0x27484
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x28(%rax), %esi
callq 0x27c90
movl %eax, -0xc(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x2743c
movl -0xc(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3WalSavepointUndo
SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
  int rc = SQLITE_OK;

  assert( pWal->writeLock );
  assert( aWalData[3]!=pWal->nCkpt || aWalData[0]<=pWal->hdr.mxFrame );

  if( aWalData[3]!=pWal->nCkpt ){
    /* This savepoint was opened immediately after the write-transaction
    ** was started. Right after that, the writer decided to wrap around
    ** to the start of the log. Update the savepoint values to match.
    */
    aWalData[0] = 0;
    aWalData[3] = pWal->nCkpt;
  }

  if( aWalData[0]<pWal->hdr.mxFrame ){
    pWal->hdr.mxFrame = aWalData[0];
    pWal->hdr.aFrameCksum[0] = aWalData[1];
    pWal->hdr.aFrameCksum[1] = aWalData[2];
    walCleanupHash(pWal);
  }

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x80(%rcx), %eax
je 0x27b65
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
movl 0x80(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x58(%rcx), %eax
jae 0x27ba6
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x58(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x8(%rbp), %rdi
callq 0x242f0
movl -0x14(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3WalUndo
SQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){
  int rc = SQLITE_OK;
  if( ALWAYS(pWal->writeLock) ){
    Pgno iMax = pWal->hdr.mxFrame;
    Pgno iFrame;
  
    /* Restore the clients cache of the wal-index header to the state it
    ** was in before the client began writing to the database. 
    */
    memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr));

    for(iFrame=pWal->hdr.mxFrame+1; 
        ALWAYS(rc==SQLITE_OK) && iFrame<=iMax; 
        iFrame++
    ){
      /* This call cannot fail. Unless the page for which the page number
      ** is passed as the second argument is (a) in the cache and 
      ** (b) has an outstanding reference, then xUndo is either a no-op
      ** (if (a) is false) or simply expels the page from the cache (if (b)
      ** is false).
      **
      ** If the upper layer is doing a rollback, it is guaranteed that there
      ** are no outstanding references to any page other than page 1. And
      ** page 1 is never written to the log until the transaction is
      ** committed. As a result, the call to xUndo may not fail.
      */
      assert( walFramePgno(pWal, iFrame)!=1 );
      rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));
    }
    if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);
  }
  assert( rc==SQLITE_OK );
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
cmpb $0x0, 0x40(%rax)
je 0x27c83
movq -0x8(%rbp), %rax
movl 0x58(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x23680
movq -0x30(%rbp), %rdi
movq %rax, %rsi
movl $0x30, %edx
callq 0x82f0
movq -0x8(%rbp), %rax
movl 0x58(%rax), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x31(%rbp)
jne 0x27c2d
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
setbe %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x27c36
jmp 0x27c6c
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x27da0
movq -0x48(%rbp), %rdi
movl %eax, %esi
movq -0x40(%rbp), %rax
callq *%rax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x27c16
movl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x58(%rcx), %eax
je 0x27c81
movq -0x8(%rbp), %rdi
callq 0x242f0
jmp 0x27c83
movl -0x1c(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerUndoCallback
static int pagerUndoCallback(void *pCtx, Pgno iPg){
  int rc = SQLITE_OK;
  Pager *pPager = (Pager *)pCtx;
  PgHdr *pPg;

  assert( pagerUseWal(pPager) );
  pPg = sqlite3PagerLookup(pPager, iPg);
  if( pPg ){
    if( sqlite3PcachePageRefcount(pPg)==1 ){
      sqlite3PcacheDrop(pPg);
    }else{
      u32 iFrame = 0;
      rc = sqlite3WalFindFrame(pPager->pWal, pPg->pgno, &iFrame);
      if( rc==SQLITE_OK ){
        rc = readDbPage(pPg, iFrame);
      }
      if( rc==SQLITE_OK ){
        pPager->xReiniter(pPg);
      }
      sqlite3PagerUnref(pPg);
    }
  }

  /* Normally, if a transaction is rolled back, any backup processes are
  ** updated as data is copied out of the rollback journal and into the
  ** database. This is not generally possible with a WAL database, as
  ** rollback involves simply truncating the log file. Therefore, if one
  ** or more frames have already been written to the log (and therefore 
  ** also copied into the backup databases) as part of this transaction,
  ** the backups must be restarted.
  */
  sqlite3BackupRestart(pPager->pBackup);

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x27e20
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x27d3a
movq -0x20(%rbp), %rdi
callq 0x24d60
cmpl $0x1, %eax
jne 0x27cde
movq -0x20(%rbp), %rdi
callq 0x27e60
jmp 0x27d38
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq 0x118(%rax), %rdi
movq -0x20(%rbp), %rax
movl 0x28(%rax), %esi
leaq -0x24(%rbp), %rdx
callq 0x27ee0
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x27d18
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x28040
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x27d2f
movq -0x18(%rbp), %rax
movq 0x100(%rax), %rax
movq -0x20(%rbp), %rdi
callq *%rax
movq -0x20(%rbp), %rdi
callq 0xec30
jmp 0x27d3a
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x25140
movl -0x10(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PcacheDirtyList
SQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache *pCache){
  PgHdr *p;
  for(p=pCache->pDirty; p; p=p->pDirtyNext){
    p->pDirty = p->pDirtyNext;
  }
  return pcacheSortDirtyList(pCache->pDirty);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x27d8c
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x27d67
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x28570
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walFramePgno
static u32 walFramePgno(Wal *pWal, u32 iFrame){
  int iHash = walFramePage(iFrame);
  if( iHash==0 ){
    return pWal->apWiData[0][WALINDEX_HDR_SIZE/sizeof(u32) + iFrame - 1];
  }
  return pWal->apWiData[iHash][(iFrame-1-HASHTABLE_NPAGE_ONE)%HASHTABLE_NPAGE];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl -0x14(%rbp), %edi
callq 0x242c0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x27dde
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
addq $0x22, %rcx
subq $0x1, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4(%rbp)
jmp 0x27e0a
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
subq $0xfde, %rcx            # imm = 0xFDE
andq $0xfff, %rcx            # imm = 0xFFF
movl (%rax,%rcx,4), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PagerLookup
SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){
  PgHdr *pPg = 0;
  assert( pPager!=0 );
  assert( pgno!=0 );
  assert( pPager->pPCache!=0 );
  assert( pPager->eState>=PAGER_READER && pPager->eState!=PAGER_ERROR );
  sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);
  return pPg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rdi
movl -0xc(%rbp), %esi
xorl %edx, %edx
leaq -0x18(%rbp), %rcx
callq 0x28150
movq -0x18(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PcacheDrop
SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr *p){
  PCache *pCache;
  assert( p->nRef==1 );
  if( p->flags&PGHDR_DIRTY ){
    pcacheRemoveFromDirtyList(p);
  }
  pCache = p->pCache;
  pCache->nRef--;
  if( p->pgno==1 ){
    pCache->pPage1 = 0;
  }
  sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, p->pPage, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x27e85
movq -0x8(%rbp), %rdi
callq 0x248d0
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
cmpl $0x1, 0x28(%rax)
jne 0x27eb4
movq -0x10(%rbp), %rax
movq $0x0, 0x48(%rax)
movq 0xa86bd(%rip), %rax     # 0xd0578
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x8(%rbp), %rcx
movq (%rcx), %rsi
movl $0x1, %edx
callq *%rax
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: numberOfCachePages
static int numberOfCachePages(PCache *p){
  if( p->szCache>=0 ){
    return p->szCache;
  }else{
    return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jl 0x2849e
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x284c6
movq -0x10(%rbp), %rax
movslq 0x1c(%rax), %rax
imulq $-0x400, %rax, %rax     # imm = 0xFC00
movq -0x10(%rbp), %rcx
movl 0x20(%rcx), %ecx
movq -0x10(%rbp), %rdx
addl 0x24(%rdx), %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3WalReadFrame
SQLITE_PRIVATE int sqlite3WalReadFrame(
  Wal *pWal,                      /* WAL handle */
  u32 iRead,                      /* Frame to read */
  int nOut,                       /* Size of buffer pOut in bytes */
  u8 *pOut                        /* Buffer to write page data to */
){
  int sz;
  i64 iOffset;
  sz = pWal->hdr.szPage;
  sz = (sz&0xfe00) + ((sz&0x0001)<<16);
  testcase( sz<=32768 );
  testcase( sz>=65536 );
  iOffset = walFrameOffset(iRead, sz) + WAL_FRAME_HDRSIZE;
  /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
  return sqlite3OsRead(pWal->pWalFd, pOut, (nOut>sz ? sz : nOut), iOffset);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x56(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl $0xfe00, %eax           # imm = 0xFE00
movl -0x1c(%rbp), %ecx
andl $0x1, %ecx
shll $0x10, %ecx
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl -0x1c(%rbp), %ecx
addl $0x18, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
addq $0x20, %rax
addq $0x18, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x2854c
movl -0x1c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x28552
movl -0x10(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movq -0x28(%rbp), %rcx
callq 0x23e30
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pcacheSortDirtyList
static PgHdr *pcacheSortDirtyList(PgHdr *pIn){
  PgHdr *a[N_SORT_BUCKET], *p;
  int i;
  memset(a, 0, sizeof(a));
  while( pIn ){
    p = pIn;
    pIn = p->pDirty;
    p->pDirty = 0;
    for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){
      if( a[i]==0 ){
        a[i] = p;
        break;
      }else{
        p = pcacheMergeDirtyList(a[i], p);
        a[i] = 0;
      }
    }
    if( NEVER(i==N_SORT_BUCKET-1) ){
      /* To get here, there need to be 2^(N_SORT_BUCKET) elements in
      ** the input list.  But that is impossible.
      */
      a[i] = pcacheMergeDirtyList(a[i], p);
    }
  }
  p = a[0];
  for(i=1; i<N_SORT_BUCKET; i++){
    p = pcacheMergeDirtyList(p, a[i]);
  }
  return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
leaq -0x110(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x8200
cmpq $0x0, -0x8(%rbp)
je 0x28686
movq -0x8(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x118(%rbp), %rax
movq $0x0, 0x18(%rax)
movl $0x0, -0x11c(%rbp)
cmpl $0x1f, -0x11c(%rbp)
jge 0x2864b
movslq -0x11c(%rbp), %rax
cmpq $0x0, -0x110(%rbp,%rax,8)
jne 0x28603
movq -0x118(%rbp), %rcx
movslq -0x11c(%rbp), %rax
movq %rcx, -0x110(%rbp,%rax,8)
jmp 0x2864b
movslq -0x11c(%rbp), %rax
movq -0x110(%rbp,%rax,8), %rdi
movq -0x118(%rbp), %rsi
callq 0x286f0
movq %rax, -0x118(%rbp)
movslq -0x11c(%rbp), %rax
movq $0x0, -0x110(%rbp,%rax,8)
jmp 0x2863a
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x285d0
cmpl $0x1f, -0x11c(%rbp)
jne 0x28681
movslq -0x11c(%rbp), %rax
movq -0x110(%rbp,%rax,8), %rdi
movq -0x118(%rbp), %rsi
callq 0x286f0
movq %rax, %rcx
movslq -0x11c(%rbp), %rax
movq %rcx, -0x110(%rbp,%rax,8)
jmp 0x28592
movq -0x110(%rbp), %rax
movq %rax, -0x118(%rbp)
movl $0x1, -0x11c(%rbp)
cmpl $0x20, -0x11c(%rbp)
jge 0x286da
movq -0x118(%rbp), %rdi
movslq -0x11c(%rbp), %rax
movq -0x110(%rbp,%rax,8), %rsi
callq 0x286f0
movq %rax, -0x118(%rbp)
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x2869e
movq -0x118(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pcacheMergeDirtyList
static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){
  PgHdr result, *pTail;
  pTail = &result;
  while( pA && pB ){
    if( pA->pgno<pB->pgno ){
      pTail->pDirty = pA;
      pTail = pA;
      pA = pA->pDirty;
    }else{
      pTail->pDirty = pB;
      pTail = pB;
      pB = pB->pDirty;
    }
  }
  if( pA ){
    pTail->pDirty = pA;
  }else if( pB ){
    pTail->pDirty = pB;
  }else{
    pTail->pDirty = 0;
  }
  return result.pDirty;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x8(%rbp)
movb %al, -0x61(%rbp)
je 0x2871b
cmpq $0x0, -0x10(%rbp)
setne %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x28724
jmp 0x28778
movq -0x8(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jae 0x28756
movq -0x8(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x28776
movq -0x10(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x28704
cmpq $0x0, -0x8(%rbp)
je 0x2878d
movq -0x8(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x287b0
cmpq $0x0, -0x10(%rbp)
je 0x287a2
movq -0x10(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x287ae
movq -0x60(%rbp), %rax
movq $0x0, 0x18(%rax)
jmp 0x287b0
movq -0x40(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: read32bits
static int read32bits(sqlite3_file *fd, i64 offset, u32 *pRes){
  unsigned char ac[4];
  int rc = sqlite3OsRead(fd, ac, sizeof(ac), offset);
  if( rc==SQLITE_OK ){
    *pRes = sqlite3Get4byte(ac);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
movq -0x10(%rbp), %rcx
movl $0x4, %edx
callq 0x23e30
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x28804
leaq -0x1c(%rbp), %rdi
callq 0x20a50
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pager_cksum
static u32 pager_cksum(Pager *pPager, const u8 *aData){
  u32 cksum = pPager->cksumInit;         /* Checksum value to return */
  int i = pPager->pageSize-200;          /* Loop counter */
  while( i>0 ){
    cksum += aData[i];
    i -= 200;
  }
  return cksum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl 0xbc(%rax), %eax
subl $0xc8, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jle 0x2885d
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movzbl (%rax,%rcx), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
subl $0xc8, %eax
movl %eax, -0x18(%rbp)
jmp 0x28838
movl -0x14(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PcacheMakeDirty
SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){
  p->flags &= ~PGHDR_DONT_WRITE;
  assert( p->nRef>0 );
  if( 0==(p->flags & PGHDR_DIRTY) ){
    p->flags |= PGHDR_DIRTY;
    pcacheAddToDirtyList( p);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %ecx
andl $-0x21, %ecx
movw %cx, 0x2c(%rax)
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %ecx
andl $0x2, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x288f4
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %ecx
orl $0x2, %ecx
movw %cx, 0x2c(%rax)
movq -0x8(%rbp), %rdi
callq 0x28980
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PcacheRelease
SQLITE_PRIVATE void sqlite3PcacheRelease(PgHdr *p){
  assert( p->nRef>0 );
  p->nRef--;
  if( p->nRef==0 ){
    PCache *pCache = p->pCache;
    pCache->nRef--;
    if( (p->flags&PGHDR_DIRTY)==0 ){
      pcacheUnpin(p);
    }else{
      /* Move the page to the head of the dirty list. */
      pcacheRemoveFromDirtyList(p);
      pcacheAddToDirtyList(p);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movw 0x2e(%rax), %cx
addw $-0x1, %cx
movw %cx, 0x2e(%rax)
movq -0x8(%rbp), %rax
movswl 0x2e(%rax), %eax
cmpl $0x0, %eax
jne 0x28971
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x2895d
movq -0x8(%rbp), %rdi
callq 0x249c0
jmp 0x2896f
movq -0x8(%rbp), %rdi
callq 0x248d0
movq -0x8(%rbp), %rdi
callq 0x28980
jmp 0x28971
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pcacheAddToDirtyList
static void pcacheAddToDirtyList(PgHdr *pPage){
  PCache *p = pPage->pCache;

  assert( pPage->pDirtyNext==0 && pPage->pDirtyPrev==0 && p->pDirty!=pPage );

  pPage->pDirtyNext = p->pDirty;
  if( pPage->pDirtyNext ){
    assert( pPage->pDirtyNext->pDirtyPrev==0 );
    pPage->pDirtyNext->pDirtyPrev = pPage;
  }
  p->pDirty = pPage;
  if( !p->pDirtyTail ){
    p->pDirtyTail = pPage;
  }
  if( !p->pSynced && 0==(pPage->flags&PGHDR_NEED_SYNC) ){
    p->pSynced = pPage;
  }
  expensive_assert( pcacheCheckSynced(p) );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x289be
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x289e0
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x28a08
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %ecx
andl $0x4, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x28a08
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pager_truncate
static int pager_truncate(Pager *pPager, Pgno nPage){
  int rc = SQLITE_OK;
  assert( pPager->eState!=PAGER_ERROR );
  assert( pPager->eState!=PAGER_READER );
  
  if( isOpen(pPager->fd) 
   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) 
  ){
    i64 currentSize, newSize;
    int szPage = pPager->pageSize;
    assert( pPager->eLock==EXCLUSIVE_LOCK );
    /* TODO: Is it safe to use Pager.dbFileSize here? */
    rc = sqlite3OsFileSize(pPager->fd, &currentSize);
    newSize = szPage*(i64)nPage;
    if( rc==SQLITE_OK && currentSize!=newSize ){
      if( currentSize>newSize ){
        rc = sqlite3OsTruncate(pPager->fd, newSize);
      }else if( (currentSize+szPage)<=newSize ){
        char *pTmp = pPager->pTmpSpace;
        memset(pTmp, 0, szPage);
        testcase( (newSize-szPage) == currentSize );
        testcase( (newSize-szPage) >  currentSize );
        rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, newSize-szPage);
      }
      if( rc==SQLITE_OK ){
        pPager->dbFileSize = nPage;
      }
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, (%rax)
je 0x28cc5
movq -0x8(%rbp), %rax
movzbl 0x13(%rax), %eax
cmpl $0x4, %eax
jge 0x28bf6
movq -0x8(%rbp), %rax
movzbl 0x13(%rax), %eax
cmpl $0x0, %eax
jne 0x28cc5
movq -0x8(%rbp), %rax
movl 0xbc(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x23e00
movl %eax, -0x10(%rbp)
movslq -0x24(%rbp), %rax
movl -0xc(%rbp), %ecx
imulq %rcx, %rax
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x28cc3
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x28cc3
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jle 0x28c5e
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x241d0
movl %eax, -0x10(%rbp)
jmp 0x28cb1
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
addq %rcx, %rax
cmpq -0x20(%rbp), %rax
jg 0x28caf
movq -0x8(%rbp), %rax
movq 0x108(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x24(%rbp), %rdx
xorl %esi, %esi
callq 0x8200
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rsi
movl -0x24(%rbp), %edx
movq -0x20(%rbp), %rcx
movslq -0x24(%rbp), %rax
subq %rax, %rcx
callq 0xf430
movl %eax, -0x10(%rbp)
jmp 0x28cb1
cmpl $0x0, -0x10(%rbp)
jne 0x28cc1
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x24(%rax)
jmp 0x28cc3
jmp 0x28cc5
movl -0x10(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: zeroJournalHdr
static int zeroJournalHdr(Pager *pPager, int doTruncate){
  int rc = SQLITE_OK;                               /* Return code */
  assert( isOpen(pPager->jfd) );
  if( pPager->journalOff ){
    const i64 iLimit = pPager->journalSizeLimit;    /* Local cache of jsl */

    IOTRACE(("JZEROHDR %p\n", pPager))
    if( doTruncate || iLimit==0 ){
      rc = sqlite3OsTruncate(pPager->jfd, 0);
    }else{
      static const char zeroHdr[28] = {0};
      rc = sqlite3OsWrite(pPager->jfd, zeroHdr, sizeof(zeroHdr), 0);
    }
    if( rc==SQLITE_OK && !pPager->noSync ){
      rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_DATAONLY|pPager->syncFlags);
    }

    /* At this point the transaction is committed but the write lock 
    ** is still held on the file. If there is a size limit configured for 
    ** the persistent journal and the journal file currently consumes more
    ** space than that limit allows for, truncate it now. There is no need
    ** to sync the file following this operation.
    */
    if( rc==SQLITE_OK && iLimit>0 ){
      i64 sz;
      rc = sqlite3OsFileSize(pPager->jfd, &sz);
      if( rc==SQLITE_OK && sz>iLimit ){
        rc = sqlite3OsTruncate(pPager->jfd, iLimit);
      }
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x2901b
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
movq %rax, -0x18(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x28f71
cmpq $0x0, -0x18(%rbp)
jne 0x28f87
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x241d0
movl %eax, -0x10(%rbp)
jmp 0x28fa7
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
leaq 0x81f3a(%rip), %rsi     # 0xaaed0
movl $0x1c, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0xf430
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x28fd2
movq -0x8(%rbp), %rax
cmpb $0x0, 0xb(%rax)
jne 0x28fd2
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x8(%rbp), %rax
movzbl 0xf(%rax), %esi
orl $0x10, %esi
callq 0x22ce0
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x29019
cmpq $0x0, -0x18(%rbp)
jle 0x29019
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x23e00
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x29017
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
jle 0x29017
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x241d0
movl %eax, -0x10(%rbp)
jmp 0x29019
jmp 0x2901b
movl -0x10(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3WalExclusiveMode
SQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op){
  int rc;
  assert( pWal->writeLock==0 );
  assert( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE || op==-1 );

  /* pWal->readLock is usually set, but might be -1 if there was a 
  ** prior error while attempting to acquire are read-lock. This cannot 
  ** happen if the connection is actually in exclusive mode (as no xShmLock
  ** locks are taken in this case). Nor should the pager attempt to
  ** upgrade to exclusive-mode following such an error.
  */
  assert( pWal->readLock>=0 || pWal->lockError );
  assert( pWal->readLock>=0 || (op<=0 && pWal->exclusiveMode==0) );

  if( op==0 ){
    if( pWal->exclusiveMode ){
      pWal->exclusiveMode = 0;
      if( walLockShared(pWal, WAL_READ_LOCK(pWal->readLock))!=SQLITE_OK ){
        pWal->exclusiveMode = 1;
      }
      rc = pWal->exclusiveMode==0;
    }else{
      /* Already in locking_mode=NORMAL */
      rc = 0;
    }
  }else if( op>0 ){
    assert( pWal->exclusiveMode==0 );
    assert( pWal->readLock>=0 );
    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));
    pWal->exclusiveMode = 1;
    rc = 1;
  }else{
    rc = pWal->exclusiveMode==0;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x290c9
movq -0x8(%rbp), %rax
cmpb $0x0, 0x3f(%rax)
je 0x290c0
movq -0x8(%rbp), %rax
movb $0x0, 0x3f(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movswl 0x3c(%rax), %esi
addl $0x3, %esi
callq 0x23600
cmpl $0x0, %eax
je 0x290a8
movq -0x8(%rbp), %rax
movb $0x1, 0x3f(%rax)
movq -0x8(%rbp), %rax
movzbl 0x3f(%rax), %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x10(%rbp)
jmp 0x290c7
movl $0x0, -0x10(%rbp)
jmp 0x2910c
cmpl $0x0, -0xc(%rbp)
jle 0x290f4
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movswl 0x3c(%rax), %esi
addl $0x3, %esi
callq 0x230b0
movq -0x8(%rbp), %rax
movb $0x1, 0x3f(%rax)
movl $0x1, -0x10(%rbp)
jmp 0x2910a
movq -0x8(%rbp), %rax
movzbl 0x3f(%rax), %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x10(%rbp)
jmp 0x2910c
movl -0x10(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PcacheSetCachesize
SQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){
  pCache->szCache = mxPage;
  if( pCache->pCache ){
    sqlite3GlobalConfig.pcache2.xCachesize(pCache->pCache,
                                           numberOfCachePages(pCache));
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x29170
movq 0xa7415(%rip), %rax     # 0xd0560
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x28480
movq -0x20(%rbp), %rdi
movl %eax, %esi
movq -0x18(%rbp), %rax
callq *%rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: newDatabase
static int newDatabase(BtShared *pBt){
  MemPage *pP1;
  unsigned char *data;
  int rc;

  assert( sqlite3_mutex_held(pBt->mutex) );
  if( pBt->nPage>0 ){
    return SQLITE_OK;
  }
  pP1 = pBt->pPage1;
  assert( pP1!=0 );
  data = pP1->aData;
  rc = sqlite3PagerWrite(pP1->pDbPage);
  if( rc ) return rc;
  memcpy(data, zMagicHeader, sizeof(zMagicHeader));
  assert( sizeof(zMagicHeader)==16 );
  data[16] = (u8)((pBt->pageSize>>8)&0xff);
  data[17] = (u8)((pBt->pageSize>>16)&0xff);
  data[18] = 1;
  data[19] = 1;
  assert( pBt->usableSize<=pBt->pageSize && pBt->usableSize+255>=pBt->pageSize);
  data[20] = (u8)(pBt->pageSize - pBt->usableSize);
  data[21] = 64;
  data[22] = 32;
  data[23] = 32;
  memset(&data[24], 0, 100-24);
  zeroPage(pP1, PTF_INTKEY|PTF_LEAF|PTF_LEAFDATA );
  pBt->btsFlags |= BTS_PAGESIZE_FIXED;
#ifndef SQLITE_OMIT_AUTOVACUUM
  assert( pBt->autoVacuum==1 || pBt->autoVacuum==0 );
  assert( pBt->incrVacuum==1 || pBt->incrVacuum==0 );
  put4byte(&data[36 + 4*4], pBt->autoVacuum);
  put4byte(&data[36 + 7*4], pBt->incrVacuum);
#endif
  pBt->nPage = 1;
  data[31] = 1;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
jbe 0x297d2
movl $0x0, -0x4(%rbp)
jmp 0x29908
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x2980b
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x29908
movq -0x20(%rbp), %rax
movq 0x816da(%rip), %rcx     # 0xaaef0
movq %rcx, (%rax)
movq 0x816d8(%rip), %rcx     # 0xaaef8
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x11(%rax)
movq -0x20(%rbp), %rax
movb $0x1, 0x12(%rax)
movq -0x20(%rbp), %rax
movb $0x1, 0x13(%rax)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x34(%rcx), %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x14(%rax)
movq -0x20(%rbp), %rax
movb $0x40, 0x15(%rax)
movq -0x20(%rbp), %rax
movb $0x20, 0x16(%rax)
movq -0x20(%rbp), %rax
movb $0x20, 0x17(%rax)
movq -0x20(%rbp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
movl $0x4c, %edx
callq 0x8200
movq -0x18(%rbp), %rdi
movl $0xd, %esi
callq 0x2a920
movq -0x10(%rbp), %rax
movzwl 0x26(%rax), %ecx
orl $0x2, %ecx
movw %cx, 0x26(%rax)
movq -0x20(%rbp), %rdi
addq $0x34, %rdi
movq -0x10(%rbp), %rax
movzbl 0x21(%rax), %esi
callq 0x22060
movq -0x20(%rbp), %rdi
addq $0x40, %rdi
movq -0x10(%rbp), %rax
movzbl 0x22(%rax), %esi
callq 0x22060
movq -0x10(%rbp), %rax
movl $0x1, 0x3c(%rax)
movq -0x20(%rbp), %rax
movb $0x1, 0x1f(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: unlockBtreeIfUnused
static void unlockBtreeIfUnused(BtShared *pBt){
  assert( sqlite3_mutex_held(pBt->mutex) );
  assert( countValidCursors(pBt,0)==0 || pBt->inTransaction>TRANS_NONE );
  if( pBt->inTransaction==TRANS_NONE && pBt->pPage1!=0 ){
    assert( pBt->pPage1->aData );
    assert( sqlite3PagerRefcount(pBt->pPager)==1 );
    assert( pBt->pPage1->aData );
    releasePage(pBt->pPage1);
    pBt->pPage1 = 0;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x24(%rax), %eax
cmpl $0x0, %eax
jne 0x2995d
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x2995d
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x29fd0
movq -0x8(%rbp), %rax
movq $0x0, 0x18(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: btreeGetPage
static int btreeGetPage(
  BtShared *pBt,       /* The btree */
  Pgno pgno,           /* Number of the page to fetch */
  MemPage **ppPage,    /* Return the page in this parameter */
  int flags            /* PAGER_GET_NOCONTENT or PAGER_GET_READONLY */
){
  int rc;
  DbPage *pDbPage;

  assert( flags==0 || flags==PAGER_GET_NOCONTENT || flags==PAGER_GET_READONLY );
  assert( sqlite3_mutex_held(pBt->mutex) );
  rc = sqlite3PagerAcquire(pBt->pPager, pgno, (DbPage**)&pDbPage, flags);
  if( rc ) return rc;
  *ppPage = btreePageFromDbPage(pDbPage, pgno, pBt);
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x14(%rbp), %esi
movl -0x24(%rbp), %ecx
leaq -0x30(%rbp), %rdx
callq 0xe5f0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x29f0d
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x29f2e
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x2a530
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PagerOpenWal
SQLITE_PRIVATE int sqlite3PagerOpenWal(
  Pager *pPager,                  /* Pager object */
  int *pbOpen                     /* OUT: Set to true if call is a no-op */
){
  int rc = SQLITE_OK;             /* Return code */

  assert( assert_pager_state(pPager) );
  assert( pPager->eState==PAGER_OPEN   || pbOpen );
  assert( pPager->eState==PAGER_READER || !pbOpen );
  assert( pbOpen==0 || *pbOpen==0 );
  assert( pbOpen!=0 || (!pPager->tempFile && !pPager->pWal) );

  if( !pPager->tempFile && !pPager->pWal ){
    if( !sqlite3PagerWalSupported(pPager) ) return SQLITE_CANTOPEN;

    /* Close any rollback journal previously open */
    sqlite3OsClose(pPager->jfd);

    rc = pagerOpenWal(pPager);
    if( rc==SQLITE_OK ){
      pPager->journalMode = PAGER_JOURNALMODE_WAL;
      pPager->eState = PAGER_OPEN;
    }
  }else{
    *pbOpen = 1;
  }

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x10(%rax)
jne 0x29fb7
movq -0x10(%rbp), %rax
cmpq $0x0, 0x118(%rax)
jne 0x29fb7
movq -0x10(%rbp), %rdi
callq 0x2a5b0
cmpl $0x0, %eax
jne 0x29f86
movl $0xe, -0x4(%rbp)
jmp 0x29fc7
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x20ea0
movq -0x10(%rbp), %rdi
callq 0x2a610
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x29fb5
movq -0x10(%rbp), %rax
movb $0x5, 0x9(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x13(%rax)
jmp 0x29fc1
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq