LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pcache1Alloc
static void *pcache1Alloc(int nByte){
  void *p = 0;
  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );
  sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
  if( nByte<=pcache1.szSlot ){
    sqlite3_mutex_enter(pcache1.mutex);
    p = (PgHdr1 *)pcache1.pFree;
    if( p ){
      pcache1.pFree = pcache1.pFree->pNext;
      pcache1.nFreeSlot--;
      pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
      assert( pcache1.nFreeSlot>=0 );
      sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1);
    }
    sqlite3_mutex_leave(pcache1.mutex);
  }
  if( p==0 ){
    /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool.  Get
    ** it from sqlite3Malloc instead.
    */
    p = sqlite3Malloc(nByte);
#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
    if( p ){
      int sz = sqlite3MallocSize(p);
      sqlite3_mutex_enter(pcache1.mutex);
      sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);
      sqlite3_mutex_leave(pcache1.mutex);
    }
#endif
    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);
  }
  return p;
}

// Assembly:
movl %edi, 0x78ea4(%rip)     # 0x95cfc
cmpl %edi, 0x78ec6(%rip)     # 0x95d24
jge 0x1ce66
movl %edi, 0x78ebe(%rip)     # 0x95d24
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpl %edi, 0x7912a(%rip)     # 0x95f9c
jl 0x1cec9
movq 0x79145(%rip), %rbx     # 0x95fc0
testq %rbx, %rbx
je 0x1cec9
movq (%rbx), %rax
movq %rax, 0x79136(%rip)     # 0x95fc0
movl 0x79138(%rip), %eax     # 0x95fc8
leal -0x1(%rax), %ecx
movl %ecx, 0x7912f(%rip)     # 0x95fc8
xorl %ecx, %ecx
cmpl 0x79103(%rip), %eax     # 0x95fa4
setle %cl
movl %ecx, 0x79122(%rip)     # 0x95fcc
movl 0x78e34(%rip), %ecx     # 0x95ce4
leal 0x1(%rcx), %eax
movl %eax, 0x78e2b(%rip)     # 0x95ce4
cmpl 0x78e4d(%rip), %ecx     # 0x95d0c
jl 0x1cecb
movl %eax, 0x78e45(%rip)     # 0x95d0c
jmp 0x1cecb
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x1ceda
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0xa2a2
testq %rax, %rax
je 0x1cf0c
movq %rax, %rbx
movq %rax, %rdi
callq *0x77548(%rip)          # 0x94438
addl 0x78df2(%rip), %eax     # 0x95ce8
movl %eax, 0x78dec(%rip)     # 0x95ce8
cmpl 0x78e0e(%rip), %eax     # 0x95d10
jle 0x1ced0
movl %eax, 0x78e06(%rip)     # 0x95d10
jmp 0x1ced0
xorl %ebx, %ebx
jmp 0x1ced0
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PcacheTruncate
SQLITE_PRIVATE void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){
  if( pCache->pCache ){
    PgHdr *p;
    PgHdr *pNext;
    for(p=pCache->pDirty; p; p=pNext){
      pNext = p->pDirtyNext;
      /* This routine never gets call with a positive pgno except right
      ** after sqlite3PcacheCleanAll().  So if there are dirty pages,
      ** it must be that pgno==0.
      */
      assert( p->pgno>0 );
      if( ALWAYS(p->pgno>pgno) ){
        assert( p->flags&PGHDR_DIRTY );
        sqlite3PcacheMakeClean(p);
      }
    }
    if( pgno==0 && pCache->pPage1 ){
      memset(pCache->pPage1->pData, 0, pCache->szPage);
      pgno = 1;
    }
    sqlite3GlobalConfig.pcache2.xTruncate(pCache->pCache, pgno+1);
  }
}

// Assembly:
cmpq $0x0, 0x40(%rdi)
je 0x1cf6b
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x1cf46
movq 0x38(%rdi), %r15
cmpl %r14d, 0x28(%rdi)
jbe 0x1cf3e
callq 0x1b26c
movq %r15, %rdi
testq %r15, %r15
jne 0x1cf2f
testl %r14d, %r14d
jne 0x1cf6f
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x1cf6c
movq 0x8(%rax), %rdi
movslq 0x20(%rbx), %rdx
xorl %esi, %esi
callq 0x8200
movl $0x1, %r14d
jmp 0x1cf6f
retq
xorl %r14d, %r14d
movq 0x77582(%rip), %rax     # 0x944f8
movq 0x40(%rbx), %rdi
incl %r14d
movl %r14d, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pcache1Free
static int pcache1Free(void *p){
  int nFreed = 0;
  if( p==0 ) return 0;
  if( p>=pcache1.pStart && p<pcache1.pEnd ){
    PgFreeslot *pSlot;
    sqlite3_mutex_enter(pcache1.mutex);
    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1);
    pSlot = (PgFreeslot*)p;
    pSlot->pNext = pcache1.pFree;
    pcache1.pFree = pSlot;
    pcache1.nFreeSlot++;
    pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
    assert( pcache1.nFreeSlot<=pcache1.nSlot );
    sqlite3_mutex_leave(pcache1.mutex);
  }else{
    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );
    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
    nFreed = sqlite3MallocSize(p);
#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
    sqlite3_mutex_enter(pcache1.mutex);
    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -nFreed);
    sqlite3_mutex_leave(pcache1.mutex);
#endif
    sqlite3_free(p);
  }
  return nFreed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x1cff8
movq %rdi, %rbx
cmpq %rdi, 0x79007(%rip)     # 0x95fa8
ja 0x1cfff
cmpq %rbx, 0x79006(%rip)     # 0x95fb0
jbe 0x1cfff
movl 0x78d32(%rip), %eax     # 0x95ce4
decl %eax
movl %eax, 0x78d2a(%rip)     # 0x95ce4
cmpl 0x78d4c(%rip), %eax     # 0x95d0c
jle 0x1cfc8
movl %eax, 0x78d44(%rip)     # 0x95d0c
movq 0x78ff1(%rip), %rax     # 0x95fc0
movq %rax, (%rbx)
movq %rbx, 0x78fe7(%rip)     # 0x95fc0
movl 0x78fe9(%rip), %eax     # 0x95fc8
incl %eax
movl %eax, 0x78fe1(%rip)     # 0x95fc8
xorl %ecx, %ecx
cmpl 0x78fb5(%rip), %eax     # 0x95fa4
setl %cl
movl %ecx, 0x78fd4(%rip)     # 0x95fcc
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq *0x77430(%rip)          # 0x94438
movl 0x78cda(%rip), %ecx     # 0x95ce8
subl %eax, %ecx
movl %ecx, 0x78cd2(%rip)     # 0x95ce8
cmpl 0x78cf4(%rip), %ecx     # 0x95d10
jle 0x1d024
movl %ecx, 0x78cec(%rip)     # 0x95d10
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xa2e8
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerSyncHotJournal
static int pagerSyncHotJournal(Pager *pPager){
  int rc = SQLITE_OK;
  if( !pPager->noSync ){
    rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_NORMAL);
  }
  if( rc==SQLITE_OK ){
    rc = sqlite3OsFileSize(pPager->jfd, &pPager->journalHdr);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %eax, %eax
cmpb $0x0, 0xb(%rdi)
jne 0x1d29b
movq 0x50(%rbx), %rdi
movq (%rdi), %rax
movl $0x2, %esi
callq *0x28(%rax)
testl %eax, %eax
je 0x1d2a6
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq 0x50(%rbx), %rdi
addq $0x68, %rbx
movq (%rdi), %rax
movq 0x30(%rax), %rax
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmpq *%rax
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerUnlockAndRollback
static void pagerUnlockAndRollback(Pager *pPager){
  if( pPager->eState!=PAGER_ERROR && pPager->eState!=PAGER_OPEN ){
    assert( assert_pager_state(pPager) );
    if( pPager->eState>=PAGER_WRITER_LOCKED ){
      sqlite3BeginBenignMalloc();
      sqlite3PagerRollback(pPager);
      sqlite3EndBenignMalloc();
    }else if( !pPager->exclusiveMode ){
      assert( pPager->eState==PAGER_READER );
      pager_end_transaction(pPager, 0, 0);
    }
  }
  pager_unlock(pPager);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzbl 0x13(%rdi), %eax
testl %eax, %eax
je 0x1d313
cmpl $0x1, %eax
je 0x1d301
cmpl $0x6, %eax
je 0x1d313
movq 0x78c7e(%rip), %rax     # 0x95f60
testq %rax, %rax
je 0x1d2e9
callq *%rax
movq %rbx, %rdi
callq 0x1e053
movq 0x78c70(%rip), %rax     # 0x95f68
testq %rax, %rax
je 0x1d313
callq *%rax
jmp 0x1d313
cmpb $0x0, 0x8(%rbx)
jne 0x1d313
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1e0fd
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1d169
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walIndexClose
static void walIndexClose(Wal *pWal, int isDelete){
  if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){
    int i;
    for(i=0; i<pWal->nWiData; i++){
      sqlite3_free((void *)pWal->apWiData[i]);
      pWal->apWiData[i] = 0;
    }
  }else{
    sqlite3OsShmUnmap(pWal->pDbFd, isDelete);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpb $0x2, 0x3f(%rdi)
jne 0x1de31
cmpl $0x0, 0x28(%rbx)
jle 0x1de2c
xorl %r14d, %r14d
movq 0x30(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0xa2e8
movq 0x30(%rbx), %rax
movq $0x0, (%rax,%r14,8)
incq %r14
movslq 0x28(%rbx), %rax
cmpq %rax, %r14
jl 0x1de07
popq %rbx
popq %r14
popq %rbp
retq
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movq 0x80(%rax), %rax
popq %rbx
popq %r14
popq %rbp
jmpq *%rax
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walMerge
static void walMerge(
  const u32 *aContent,            /* Pages in wal - keys for the sort */
  ht_slot *aLeft,                 /* IN: Left hand input list */
  int nLeft,                      /* IN: Elements in array *paLeft */
  ht_slot **paRight,              /* IN/OUT: Right hand input list */
  int *pnRight,                   /* IN/OUT: Elements in *paRight */
  ht_slot *aTmp                   /* Temporary buffer */
){
  int iLeft = 0;                  /* Current index in aLeft */
  int iRight = 0;                 /* Current index in aRight */
  int iOut = 0;                   /* Current index in output buffer */
  int nRight = *pnRight;
  ht_slot *aRight = *paRight;

  assert( nLeft>0 && nRight>0 );
  while( iRight<nRight || iLeft<nLeft ){
    ht_slot logpage;
    Pgno dbpage;

    if( (iLeft<nLeft) 
     && (iRight>=nRight || aContent[aLeft[iLeft]]<aContent[aRight[iRight]])
    ){
      logpage = aLeft[iLeft++];
    }else{
      logpage = aRight[iRight++];
    }
    dbpage = aContent[logpage];

    aTmp[iOut++] = logpage;
    if( iLeft<nLeft && aContent[aLeft[iLeft]]==dbpage ) iLeft++;

    assert( iLeft>=nLeft || aContent[aLeft[iLeft]]>dbpage );
    assert( iRight>=nRight || aContent[aRight[iRight]]>dbpage );
  }

  *paRight = aLeft;
  *pnRight = iOut;
  memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl (%r8), %r10d
testl %r10d, %r10d
setg %r15b
testl %edx, %edx
setg %r12b
movl %r15d, %r11d
orb %r12b, %r11b
xorl %eax, %eax
cmpb $0x1, %r11b
jne 0x1defe
movq (%rcx), %r11
xorl %eax, %eax
xorl %r14d, %r14d
xorl %ebx, %ebx
testb $0x1, %r12b
je 0x1deaf
testb $0x1, %r15b
je 0x1dea4
movslq %r14d, %r15
movzwl (%rsi,%r15,2), %r15d
movl (%rdi,%r15,4), %r15d
movslq %ebx, %r12
movzwl (%r11,%r12,2), %r12d
cmpl (%rdi,%r12,4), %r15d
jae 0x1deaf
movl %r14d, %r15d
incl %r14d
movq %rsi, %r12
jmp 0x1deb7
movl %ebx, %r15d
incl %ebx
movq %r11, %r12
movslq %r15d, %r15
movzwl (%r12,%r15,2), %r12d
movl (%rdi,%r12,4), %r15d
movw %r12w, (%r9,%rax,2)
cmpl %edx, %r14d
jge 0x1dee6
movslq %r14d, %r12
movzwl (%rsi,%r12,2), %r12d
xorl %r13d, %r13d
cmpl %r15d, (%rdi,%r12,4)
sete %r13b
addl %r14d, %r13d
movl %r13d, %r14d
cmpl %edx, %r14d
setl %r12b
incq %rax
cmpl %r10d, %ebx
setl %r15b
jl 0x1de7e
cmpl %edx, %r14d
jl 0x1de7e
movq %rsi, (%rcx)
movl %eax, (%r8)
addl %eax, %eax
movq %rsi, %rdi
movq %r9, %rsi
movq %rax, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x82f0
// File: /workspace/github_c_makefile_star2_O1/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:
testq %rdi, %rdi
je 0x1df57
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x8(%rdi)
je 0x1df4b
movl $0x2, %r14d
movq (%rbx,%r14,8), %rdi
callq 0x1df1e
incq %r14
cmpq $0x40, %r14
jne 0x1df39
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0xa2e8
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x80(%rdi)
jle 0x1df97
movl $0x10, %r14d
xorl %r15d, %r15d
movq 0x78(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x1df1e
incq %r15
movslq 0x80(%rbx), %rax
addq $0x30, %r14
cmpq %rax, %r15
jl 0x1df77
cmpb $0x0, 0x8(%rbx)
je 0x1dfad
movq 0x58(%rbx), %rax
leaq 0x74ea8(%rip), %rcx     # 0x92e50
cmpq %rcx, (%rax)
jne 0x1dfc6
movq 0x58(%rbx), %r14
movq (%r14), %rax
testq %rax, %rax
je 0x1dfc6
movq %r14, %rdi
callq *0x8(%rax)
movq $0x0, (%r14)
movq 0x78(%rbx), %rdi
callq 0xa2e8
movq $0x0, 0x78(%rbx)
xorl %eax, %eax
movl %eax, 0x80(%rbx)
movl %eax, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x0, 0x40(%rdi)
je 0x1e020
cmpb $0x0, 0x3f(%rbx)
jne 0x1e018
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
xorl %esi, %esi
movl $0x1, %edx
movl $0x9, %ecx
callq *0x70(%rax)
xorl %eax, %eax
movb %al, 0x40(%rbx)
movb %al, 0x43(%rbx)
movzwl 0x3c(%rbx), %esi
testw %si, %si
js 0x1e04c
cmpb $0x0, 0x3f(%rbx)
jne 0x1e046
addl $0x3, %esi
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movl $0x1, %edx
movl $0x5, %ecx
callq *0x70(%rax)
movw $0xffff, 0x3c(%rbx)     # imm = 0xFFFF
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PagerRollback
SQLITE_PRIVATE int sqlite3PagerRollback(Pager *pPager){
  int rc = SQLITE_OK;                  /* Return code */
  PAGERTRACE(("ROLLBACK %d\n", PAGERID(pPager)));

  /* PagerRollback() is a no-op if called in READER or OPEN state. If
  ** the pager is already in the ERROR state, the rollback is not 
  ** attempted here. Instead, the error code is returned to the caller.
  */
  assert( assert_pager_state(pPager) );
  if( pPager->eState==PAGER_ERROR ) return pPager->errCode;
  if( pPager->eState<=PAGER_READER ) return SQLITE_OK;

  if( pagerUseWal(pPager) ){
    int rc2;
    rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1);
    rc2 = pager_end_transaction(pPager, pPager->setMaster, 0);
    if( rc==SQLITE_OK ) rc = rc2;
  }else if( !isOpen(pPager->jfd) || pPager->eState==PAGER_WRITER_LOCKED ){
    int eState = pPager->eState;
    rc = pager_end_transaction(pPager, 0, 0);
    if( !MEMDB && eState>PAGER_WRITER_LOCKED ){
      /* This can happen using journal_mode=off. Move the pager to the error 
      ** state to indicate that the contents of the cache may not be trusted.
      ** Any active readers will get SQLITE_ABORT.
      */
      pPager->errCode = SQLITE_ABORT;
      pPager->eState = PAGER_ERROR;
      return rc;
    }
  }else{
    rc = pager_playback(pPager, 0);
  }

  assert( pPager->eState==PAGER_READER || rc!=SQLITE_OK );
  assert( rc==SQLITE_OK || rc==SQLITE_FULL || rc==SQLITE_CORRUPT
          || rc==SQLITE_NOMEM || (rc&0xFF)==SQLITE_IOERR );

  /* If an error occurs during a ROLLBACK, we can no longer trust the pager
  ** cache. So call pager_error() on the way out to make any error persistent.
  */
  return pager_error(pPager, rc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movb 0x13(%rdi), %r14b
cmpb $0x6, %r14b
jne 0x1e06c
movl 0x2c(%rbx), %eax
jmp 0x1e0d7
xorl %eax, %eax
cmpb $0x2, %r14b
jb 0x1e0d7
cmpq $0x0, 0x118(%rbx)
je 0x1e0aa
movq %rbx, %rdi
movl $0x2, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x1e387
movl %eax, %r14d
movzbl 0x16(%rbx), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1e0fd
testl %r14d, %r14d
cmovnel %r14d, %eax
jmp 0x1e0c4
cmpb $0x2, %r14b
je 0x1e0dc
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x1e0dc
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1e706
cmpb $0xd, %al
je 0x1e0d0
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x1e0d7
movl %eax, 0x2c(%rbx)
movb $0x6, 0x13(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1e0fd
cmpb $0x2, %r14b
je 0x1e0c4
cmpb $0x0, 0x12(%rbx)
jne 0x1e0c4
movl $0x4, 0x2c(%rbx)
jmp 0x1e0d3
// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x20(%rdi), %eax
movl %eax, 0x1c(%rdi)
movq 0x118(%rdi), %r14
cmpb $0x0, 0x40(%r14)
je 0x1ed71
movl 0x58(%r14), %ecx
movq 0x30(%r14), %rax
movq (%rax), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm1, 0x58(%r14)
movups %xmm0, 0x48(%r14)
movups %xmm2, 0x68(%r14)
movl 0x58(%r14), %r13d
leal 0x1(%r13), %eax
xorl %r15d, %r15d
movl %ecx, -0x2c(%rbp)
cmpl %ecx, %eax
ja 0x1ed5e
movabsq $0xffffffff000, %r12    # imm = 0xFFFFFFFF000
addl $0x1001, %r13d          # imm = 0x1001
movl %r13d, %eax
leaq (%r12,%rax), %rcx
addq $0x21, %rcx
movq 0x30(%r14), %rax
testq %r12, %rcx
je 0x1ed27
shrq $0xc, %rcx
movslq %ecx, %rdx
leal -0xfdf(%r13), %ecx
andl $0xfff, %ecx            # imm = 0xFFF
shll $0x2, %ecx
addq (%rax,%rdx,8), %rcx
jmp 0x1ed3e
leal -0x1000(%r13), %ecx
movq (%rax), %rax
movl %ecx, %ecx
leaq (%rax,%rcx,4), %rcx
addq $0x84, %rcx
movl (%rcx), %esi
movq %rbx, %rdi
callq 0x1f2c9
movl %eax, %r15d
testl %eax, %eax
jne 0x1ed5e
leal -0xfff(%r13), %eax
incl %r13d
cmpl -0x2c(%rbp), %eax
jbe 0x1ecf6
movl -0x2c(%rbp), %eax
cmpl 0x58(%r14), %eax
je 0x1ed74
movq %r14, %rdi
callq 0x1c86e
jmp 0x1ed74
xorl %r15d, %r15d
movq 0x110(%rbx), %rdi
callq 0x1f37b
testq %rax, %rax
je 0x1edaa
testl %r15d, %r15d
jne 0x1edaa
movq %rax, %r14
movl 0x28(%r14), %esi
movq 0x18(%r14), %r14
movq %rbx, %rdi
callq 0x1f2c9
movl %eax, %r15d
testq %r14, %r14
je 0x1edaa
testl %r15d, %r15d
je 0x1ed8d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq -0x28(%rbp), %r15
movq $0x0, (%r15)
movq 0x110(%rdi), %rdi
xorl %r14d, %r14d
xorl %edx, %edx
movq %r15, %rcx
callq 0x1f6fc
movq (%r15), %r15
testq %r15, %r15
je 0x1f357
cmpw $0x1, 0x2e(%r15)
jne 0x1f312
movq %r15, %rdi
callq 0x1f452
jmp 0x1f357
leaq -0x1c(%rbp), %rdx
movl $0x0, (%rdx)
movq 0x118(%rbx), %rdi
movl 0x28(%r15), %esi
callq 0x1f499
movl %eax, %r14d
testl %eax, %eax
jne 0x1f341
movl -0x1c(%rbp), %esi
movq %r15, %rdi
callq 0x1f644
movl %eax, %r14d
testl %r14d, %r14d
jne 0x1f34f
movq %r15, %rdi
callq *0x100(%rbx)
movq %r15, %rdi
callq 0xdcd4
movq 0x70(%rbx), %rax
testq %rax, %rax
je 0x1f36d
movl $0x1, 0x18(%rax)
movq 0x40(%rax), %rax
jmp 0x1f35b
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq (%rdi), %rax
testq %rax, %rax
je 0x1f3a1
movq 0x38(%rax), %rcx
movq %rcx, 0x18(%rax)
movq %rcx, %rax
testq %rcx, %rcx
jne 0x1f391
movq (%rdi), %rbx
leaq -0x110(%rbp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x8200
testq %rbx, %rbx
je 0x1f421
movq %rbx, %rax
movq 0x18(%rbx), %rbx
movq $0x0, 0x18(%rax)
xorl %r14d, %r14d
movq -0x110(%rbp,%r14,8), %rdi
testq %rdi, %rdi
je 0x1f3fc
movq %rax, %rsi
callq 0x1f907
movq $0x0, -0x110(%rbp,%r14,8)
incq %r14
cmpq $0x1f, %r14
jne 0x1f3ce
movb $0x1, %cl
jmp 0x1f40b
movq %rax, -0x110(%rbp,%r14,8)
cmpq $0x1f, %r14
sete %cl
testb %cl, %cl
je 0x1f3b7
movq -0x18(%rbp), %rdi
movq %rax, %rsi
callq 0x1f907
movq %rax, -0x18(%rbp)
jmp 0x1f3b7
movl $0x1, %ebx
movq -0x110(%rbp), %rax
movq -0x110(%rbp,%rbx,8), %rsi
movq %rax, %rdi
callq 0x1f907
incq %rbx
cmpq $0x20, %rbx
jne 0x1f42d
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %rbx
pushq %rax
movq %rdi, %rbx
testb $0x2, 0x2c(%rdi)
je 0x1f469
movq %rbx, %rdi
callq 0x1cae8
movq 0x30(%rbx), %rax
decl 0x18(%rax)
cmpl $0x1, 0x28(%rbx)
jne 0x1f47e
movq $0x0, 0x48(%rax)
movq 0x75063(%rip), %rcx     # 0x944e8
movq 0x40(%rax), %rdi
movq (%rbx), %rsi
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmpq *%rcx
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: readDbPage
static int readDbPage(PgHdr *pPg, u32 iFrame){
  Pager *pPager = pPg->pPager; /* Pager object associated with page pPg */
  Pgno pgno = pPg->pgno;       /* Page number to read */
  int rc = SQLITE_OK;          /* Return code */
  int pgsz = pPager->pageSize; /* Number of bytes to read */

  assert( pPager->eState>=PAGER_READER && !MEMDB );
  assert( isOpen(pPager->fd) );

#ifndef SQLITE_OMIT_WAL
  if( iFrame ){
    /* Try to pull the page from the write-ahead log. */
    rc = sqlite3WalReadFrame(pPager->pWal, iFrame, pgsz, pPg->pData);
  }else
#endif
  {
    i64 iOffset = (pgno-1)*(i64)pPager->pageSize;
    rc = sqlite3OsRead(pPager->fd, pPg->pData, pgsz, iOffset);
    if( rc==SQLITE_IOERR_SHORT_READ ){
      rc = SQLITE_OK;
    }
  }

  if( pgno==1 ){
    if( rc ){
      /* If the read is unsuccessful, set the dbFileVers[] to something
      ** that will never be a valid file version.  dbFileVers[] is a copy
      ** of bytes 24..39 of the database.  Bytes 28..31 should always be
      ** zero or the size of the database in page. Bytes 32..35 and 35..39
      ** should be page numbers which are never 0xffffffff.  So filling
      ** pPager->dbFileVers[] with all 0xff bytes should suffice.
      **
      ** For an encrypted database, the situation is more complex:  bytes
      ** 24..39 of the database are white noise.  But the probability of
      ** white noising equaling 16 bytes of 0xff is vanishingly small so
      ** we should still be ok.
      */
      memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));
    }else{
      u8 *dbFileVers = &((u8*)pPg->pData)[24];
      memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
    }
  }
  CODEC1(pPager, pPg->pData, pgno, 3, rc = SQLITE_NOMEM);

  PAGER_INCR(sqlite3_pager_readdb_count);
  PAGER_INCR(pPager->nRead);
  IOTRACE(("PGIN %p %d\n", pPager, pgno));
  PAGERTRACE(("FETCH %d page %d hash(%08x)\n",
               PAGERID(pPager), pgno, pager_pagehash(pPg)));

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %r14
movl 0x28(%rdi), %r15d
movslq 0xbc(%r14), %rdx
testl %esi, %esi
je 0x1f6ac
movq 0x118(%r14), %rdi
movq 0x8(%rbx), %rax
movzwl 0x56(%rdi), %ecx
movl %ecx, %r8d
shll $0x10, %r8d
orl %ecx, %r8d
andl $0x1fe00, %r8d          # imm = 0x1FE00
decl %esi
leal 0x18(%r8), %ecx
imulq %rsi, %rcx
addq $0x38, %rcx
movq 0x10(%rdi), %rdi
cmpl %edx, %r8d
cmovgel %edx, %r8d
movq (%rdi), %r9
movq %rax, %rsi
movl %r8d, %edx
callq *0x10(%r9)
jmp 0x1f6cf
leal -0x1(%r15), %ecx
imulq %rdx, %rcx
movq 0x48(%r14), %rdi
movq 0x8(%rbx), %rsi
movq (%rdi), %rax
callq *0x10(%rax)
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x20a, %ecx            # imm = 0x20A
cmovnel %ecx, %eax
cmpl $0x1, %r15d
jne 0x1f6f1
testl %eax, %eax
je 0x1f6df
pcmpeqd %xmm0, %xmm0
jmp 0x1f6e8
movq 0x8(%rbx), %rcx
movdqu 0x18(%rcx), %xmm0
movdqu %xmm0, 0x84(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
testq %rdi, %rdi
setne %cl
sete %al
testq %rsi, %rsi
sete %dl
orb %al, %dl
jne 0x1f964
leaq -0x48(%rbp), %rax
movq %rsi, %rdx
movq %rdi, %r8
movl 0x28(%r8), %ecx
cmpl 0x28(%rdx), %ecx
jae 0x1f941
movq %r8, 0x18(%rax)
movq 0x18(%r8), %rdi
movq %rdx, %rsi
movq %r8, %rax
jmp 0x1f94f
movq %rdx, 0x18(%rax)
movq 0x18(%rdx), %rsi
movq %r8, %rdi
movq %rdx, %rax
testq %rdi, %rdi
setne %cl
je 0x1f968
movq %rsi, %rdx
movq %rdi, %r8
testq %rsi, %rsi
jne 0x1f928
jmp 0x1f968
leaq -0x48(%rbp), %rax
testb %cl, %cl
cmoveq %rsi, %rdi
movq %rdi, 0x18(%rax)
movq -0x30(%rbp), %rax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %rcx
movq (%rdi), %rax
leaq -0xc(%rbp), %rsi
movl $0x4, %edx
callq *0x10(%rax)
testl %eax, %eax
jne 0x1f99e
movl -0xc(%rbp), %ecx
bswapl %ecx
movl %ecx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %rbx
pushq %rax
decw 0x2e(%rdi)
je 0x1f9b8
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rdi, %rbx
movq 0x30(%rdi), %rax
decl 0x18(%rax)
testb $0x2, 0x2c(%rdi)
jne 0x1f9f4
cmpl $0x0, 0x28(%rax)
je 0x1f9b1
cmpl $0x1, 0x28(%rbx)
jne 0x1f9dc
movq $0x0, 0x48(%rax)
movq 0x74b05(%rip), %rcx     # 0x944e8
movq 0x40(%rax), %rdi
movq (%rbx), %rsi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmpq *%rcx
movq %rbx, %rdi
callq 0x1cae8
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1fa07
// File: /workspace/github_c_makefile_star2_O1/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 0x30(%rdi), %rax
movq (%rax), %rcx
movq %rcx, 0x38(%rdi)
testq %rcx, %rcx
je 0x1fa1f
movq %rdi, 0x40(%rcx)
movq %rdi, (%rax)
cmpq $0x0, 0x8(%rax)
jne 0x1fa2d
movq %rdi, 0x8(%rax)
cmpq $0x0, 0x10(%rax)
jne 0x1fa3e
testb $0x4, 0x2c(%rdi)
jne 0x1fa3e
movq %rdi, 0x10(%rax)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: readMasterJournal
static int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, u32 nMaster){
  int rc;                    /* Return code */
  u32 len;                   /* Length in bytes of master journal name */
  i64 szJ;                   /* Total size in bytes of journal file pJrnl */
  u32 cksum;                 /* MJ checksum value read from journal */
  u32 u;                     /* Unsigned loop counter */
  unsigned char aMagic[8];   /* A buffer to hold the magic header */
  zMaster[0] = '\0';

  if( SQLITE_OK!=(rc = sqlite3OsFileSize(pJrnl, &szJ))
   || szJ<16
   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-16, &len))
   || len>=nMaster 
   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-12, &cksum))
   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, aMagic, 8, szJ-8))
   || memcmp(aMagic, aJournalMagic, 8)
   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, zMaster, len, szJ-16-len))
  ){
    return rc;
  }

  /* See if the checksum matches the master journal name */
  for(u=0; u<len; u++){
    cksum -= zMaster[u];
  }
  if( cksum ){
    /* If the checksum doesn't add up, then one or more of the disk sectors
    ** containing the master journal filename is corrupted. This means
    ** definitely roll back, so just return SQLITE_OK and report a (nul)
    ** master-journal filename.
    */
    len = 0;
  }
  zMaster[len] = '\0';
   
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r13d
movq %rsi, %rbx
movq %rdi, %r15
movb $0x0, (%rsi)
movq (%rdi), %rax
leaq -0x38(%rbp), %r12
movq %r12, %rsi
callq *0x30(%rax)
movl %eax, %r14d
testl %eax, %eax
setne %al
movq (%r12), %rsi
cmpq $0x10, %rsi
setl %cl
orb %al, %cl
jne 0x1fa98
addq $-0x10, %rsi
leaq -0x2c(%rbp), %rdx
movq %r15, %rdi
callq 0x1f978
testl %eax, %eax
je 0x1faaa
movl %eax, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl -0x2c(%rbp), %r12d
xorl %r14d, %r14d
cmpl %r13d, %r12d
jae 0x1fa98
movq -0x38(%rbp), %rsi
addq $-0xc, %rsi
leaq -0x30(%rbp), %rdx
movq %r15, %rdi
callq 0x1f978
testl %eax, %eax
jne 0x1fa95
movq -0x38(%rbp), %rcx
addq $-0x8, %rcx
movq (%r15), %rax
leaq -0x40(%rbp), %rsi
movq %r15, %rdi
movl $0x8, %edx
callq *0x10(%rax)
testl %eax, %eax
jne 0x1fa95
movabsq $-0x289c5edf06fa2a27, %rax # imm = 0xD763A120F905D5D9
cmpq %rax, -0x40(%rbp)
jne 0x1fa98
movq -0x38(%rbp), %rcx
subq %r12, %rcx
addq $-0x10, %rcx
movq (%r15), %rax
movq %r15, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq *0x10(%rax)
testl %eax, %eax
jne 0x1fa95
movl -0x30(%rbp), %eax
testq %r12, %r12
je 0x1fb36
xorl %ecx, %ecx
movsbl (%rbx,%rcx), %edx
subl %edx, %eax
incq %rcx
cmpq %rcx, %r12
jne 0x1fb28
movl %eax, -0x30(%rbp)
testl %eax, %eax
je 0x1fb44
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movb $0x0, (%rbx,%rax)
jmp 0x1fa98
// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x48(%rdi), %rdi
xorl %eax, %eax
cmpq $0x0, (%rdi)
je 0x1fbf5
movb 0x13(%r14), %cl
addb $-0x4, %cl
cmpb $-0x4, %cl
ja 0x1fbf5
movl %esi, %ebx
movslq 0xbc(%r14), %r15
movq (%rdi), %rax
leaq -0x30(%rbp), %rsi
callq *0x30(%rax)
testl %eax, %eax
jne 0x1fbf5
movl %ebx, %r12d
imulq %r15, %r12
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq %r12, %rcx
je 0x1fbf5
jle 0x1fbb7
movq 0x48(%r14), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *0x20(%rax)
jmp 0x1fbeb
addq %r15, %rcx
xorl %eax, %eax
cmpq %r12, %rcx
jg 0x1fbeb
movq 0x108(%r14), %r13
movq %r13, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x8200
movq 0x48(%r14), %rdi
subq %r15, %r12
movq (%rdi), %rax
movq %r13, %rsi
movl %r15d, %edx
movq %r12, %rcx
callq *0x18(%rax)
testl %eax, %eax
jne 0x1fbf5
movl %ebx, 0x24(%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %rbx
pushq %rax
movq %rdi, %rbx
testl %esi, %esi
je 0x1fc44
movb 0x3f(%rbx), %cl
testb %cl, %cl
sete %al
testl %esi, %esi
jle 0x1fc7c
testb %cl, %cl
jne 0x1fc3c
movswl 0x3c(%rbx), %esi
addl $0x3, %esi
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movl $0x1, %edx
movl $0x5, %ecx
callq *0x70(%rax)
movb $0x1, 0x3f(%rbx)
movb $0x1, %al
jmp 0x1fc7c
cmpb $0x0, 0x3f(%rbx)
je 0x1fc7a
movb $0x0, 0x3f(%rbx)
movswl 0x3c(%rbx), %esi
addl $0x3, %esi
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movl $0x1, %edx
movl $0x6, %ecx
callq *0x70(%rax)
testl %eax, %eax
je 0x1fc71
movb $0x1, 0x3f(%rbx)
cmpb $0x0, 0x3f(%rbx)
sete %al
jmp 0x1fc7c
xorl %eax, %eax
movzbl %al, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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:
xorl %eax, %eax
cmpl $0x0, 0x3c(%rdi)
je 0x1fce3
retq
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %r14
movq 0x50(%r14), %r15
movq 0x68(%r14), %rdi
callq 0xdebf
testl %eax, %eax
jne 0x1fd9a
movaps 0x56670(%rip), %xmm0    # 0x76380
movups %xmm0, (%r15)
movb 0x31(%rbx), %al
movb %al, 0x10(%r15)
movb 0x32(%rbx), %al
movb %al, 0x11(%r15)
movw $0x101, 0x12(%r15)      # imm = 0x101
movl 0x30(%rbx), %eax
subl 0x34(%rbx), %eax
movb %al, 0x14(%r15)
movw $0x2040, 0x15(%r15)     # imm = 0x2040
movb $0x20, 0x17(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r15)
movups %xmm0, 0x28(%r15)
movups %xmm0, 0x38(%r15)
movups %xmm0, 0x48(%r15)
movups %xmm0, 0x54(%r15)
movq %r14, %rdi
movl $0xd, %esi
callq 0x20900
orb $0x2, 0x26(%rbx)
movb 0x21(%rbx), %cl
xorl %eax, %eax
movw %ax, 0x34(%r15)
movb %al, 0x36(%r15)
movb %cl, 0x37(%r15)
movb 0x22(%rbx), %cl
movw %ax, 0x40(%r15)
movb %al, 0x42(%r15)
movb %cl, 0x43(%r15)
movl $0x1, 0x3c(%rbx)
movb $0x1, 0x1f(%r15)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
movq (%rdi), %rdi
leaq -0x20(%rbp), %rdx
callq 0xd803
testl %eax, %eax
jne 0x203af
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rdx
movq %rcx, 0x50(%rdx)
movq %rax, 0x68(%rdx)
movq %r15, 0x48(%rdx)
movl %r14d, 0x70(%rdx)
xorl %eax, %eax
cmpl $0x1, %r14d
movl $0x64, %ecx
cmovnel %eax, %ecx
movb %cl, 0x5(%rdx)
movq %rdx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %r14
pushq %rbx
cmpb $0x0, 0x10(%rdi)
jne 0x203d4
movq %rdi, %rbx
cmpq $0x0, 0x118(%rdi)
je 0x203e1
movl $0x1, (%rsi)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
cmpb $0x0, 0x8(%rbx)
je 0x20416
movq 0x50(%rbx), %r14
movq (%r14), %rax
testq %rax, %rax
je 0x20400
movq %r14, %rdi
callq *0x8(%rax)
movq $0x0, (%r14)
movq %rbx, %rdi
callq 0x20726
testl %eax, %eax
jne 0x203dc
movb $0x5, 0x9(%rbx)
movb $0x0, 0x13(%rbx)
jmp 0x203da
movq 0x48(%rbx), %rax
movq (%rax), %rcx
movl $0xe, %eax
cmpl $0x2, (%rcx)
jl 0x203dc
cmpq $0x0, 0x68(%rcx)
jne 0x203e7
jmp 0x203dc
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerPagecount
static int pagerPagecount(Pager *pPager, Pgno *pnPage){
  Pgno nPage;                     /* Value to return via *pnPage */

  /* Query the WAL sub-system for the database size. The WalDbsize()
  ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or
  ** if the database size is not available. The database size is not
  ** available from the WAL sub-system if the log file is empty or
  ** contains no valid committed transactions.
  */
  assert( pPager->eState==PAGER_OPEN );
  assert( pPager->eLock>=SHARED_LOCK );
  nPage = sqlite3WalDbsize(pPager->pWal);

  /* If the database size was not available from the WAL sub-system,
  ** determine it based on the size of the database file. If the size
  ** of the database file is not an integer multiple of the page-size,
  ** round down to the nearest page. Except, any file larger than 0
  ** bytes in size is considered to contain at least one page.
  */
  if( nPage==0 ){
    i64 n = 0;                    /* Size of db file in bytes */
    assert( isOpen(pPager->fd) || pPager->tempFile );
    if( isOpen(pPager->fd) ){
      int rc = sqlite3OsFileSize(pPager->fd, &n);
      if( rc!=SQLITE_OK ){
        return rc;
      }
    }
    nPage = (Pgno)((n+pPager->pageSize-1) / pPager->pageSize);
  }

  /* If the current number of pages in the file is greater than the
  ** configured maximum pager number, increase the allowed limit so
  ** that the file can be read.
  */
  if( nPage>pPager->mxPgno ){
    pPager->mxPgno = (Pgno)nPage;
  }

  *pnPage = nPage;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x118(%rdi), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x2063e
cmpw $0x0, 0x3c(%rcx)
js 0x2063e
movl 0x5c(%rcx), %eax
testl %eax, %eax
jne 0x20688
movq $0x0, -0x18(%rbp)
movq 0x48(%r14), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x2066c
leaq -0x18(%rbp), %rsi
callq *0x30(%rax)
movl %eax, %ecx
xorl %eax, %eax
movl $0x0, %edx
testl %ecx, %ecx
jne 0x20684
jmp 0x2066c
movq -0x18(%rbp), %rax
movslq 0xbc(%r14), %rsi
addq %rsi, %rax
decq %rax
cqto
idivq %rsi
movb $0x1, %dl
testb %dl, %dl
je 0x2069c
cmpl 0xc0(%r14), %eax
jbe 0x20698
movl %eax, 0xc0(%r14)
movl %eax, (%rbx)
xorl %ecx, %ecx
movl %ecx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerOpenWalIfPresent
static int pagerOpenWalIfPresent(Pager *pPager){
  int rc = SQLITE_OK;
  assert( pPager->eState==PAGER_OPEN );
  assert( pPager->eLock>=SHARED_LOCK );

  if( !pPager->tempFile ){
    int isWal;                    /* True if WAL file exists */
    Pgno nPage;                   /* Size of the database file */

    rc = pagerPagecount(pPager, &nPage);
    if( rc ) return rc;
    if( nPage==0 ){
      rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
      if( rc==SQLITE_IOERR_DELETE_NOENT ) rc = SQLITE_OK;
      isWal = 0;
    }else{
      rc = sqlite3OsAccess(
          pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
      );
    }
    if( rc==SQLITE_OK ){
      if( isWal ){
        testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
        rc = sqlite3PagerOpenWal(pPager, 0);
      }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){
        pPager->journalMode = PAGER_JOURNALMODE_DELETE;
      }
    }
  }
  return rc;
}

// Assembly:
xorl %eax, %eax
cmpb $0x0, 0x10(%rdi)
je 0x206b0
retq
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq -0x18(%rbp), %rsi
callq 0x20615
testl %eax, %eax
jne 0x2071d
cmpl $0x0, -0x18(%rbp)
movq (%rbx), %rdi
movq 0x120(%rbx), %rsi
je 0x206e6
leaq -0x14(%rbp), %rcx
xorl %edx, %edx
callq *0x38(%rdi)
jmp 0x206fb
xorl %r14d, %r14d
xorl %edx, %edx
callq *0x30(%rdi)
cmpl $0x170a, %eax           # imm = 0x170A
cmovel %r14d, %eax
movl %r14d, -0x14(%rbp)
testl %eax, %eax
jne 0x2071d
cmpl $0x0, -0x14(%rbp)
je 0x20711
movq %rbx, %rdi
xorl %esi, %esi
callq 0x203ba
jmp 0x2071d
xorl %eax, %eax
cmpb $0x5, 0x9(%rbx)
jne 0x2071d
movb $0x0, 0x9(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq