LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BitvecTest
SQLITE_PRIVATE int sqlite3BitvecTest(Bitvec *p, u32 i){
  if( p==0 ) return 0;
  if( i>p->iSize || i==0 ) return 0;
  i--;
  while( p->iDivisor ){
    u32 bin = i/p->iDivisor;
    i = i%p->iDivisor;
    p = p->u.apSub[bin];
    if (!p) {
      return 0;
    }
  }
  if( p->iSize<=BITVEC_NBIT ){
    return (p->u.aBitmap[i/BITVEC_SZELEM] & (1<<(i&(BITVEC_SZELEM-1))))!=0;
  } else{
    u32 h = BITVEC_HASH(i++);
    while( p->u.aHash[h] ){
      if( p->u.aHash[h]==i ) return 1;
      h = (h+1) % BITVEC_NINT;
    }
    return 0;
  }
}

// Assembly:
xorl %eax, %eax
testq %rdi, %rdi
je 0x1b14c
movl %esi, %edx
decl %edx
cmpl (%rdi), %edx
jae 0x1b14c
pushq %rbp
movq %rsp, %rbp
movl 0x8(%rdi), %ecx
testl %ecx, %ecx
je 0x1b0e9
movl %edx, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %ecx
xorl %eax, %eax
movq 0x10(%rdi,%rcx,8), %rdi
testq %rdi, %rdi
jne 0x1b0cc
jmp 0x1b14b
cmpl $0xf80, (%rdi)          # imm = 0xF80
ja 0x1b108
movl %edx, %eax
shrl $0x3, %eax
movzbl 0x10(%rdi,%rax), %ecx
andl $0x7, %edx
xorl %eax, %eax
btl %edx, %ecx
setb %al
jmp 0x1b14b
movl %edx, %eax
shrl $0x2, %eax
imulq $0x21084211, %rax, %rax # imm = 0x21084211
shrq $0x22, %rax
imull $0x7c, %eax, %eax
movl %edx, %ecx
subl %eax, %ecx
movl 0x10(%rdi,%rcx,4), %esi
movl $0x0, %eax
testl %esi, %esi
je 0x1b14b
incl %edx
xorl %eax, %eax
cmpl %edx, %esi
je 0x1b146
incl %ecx
cmpl $0x7c, %ecx
cmovel %eax, %ecx
movl 0x10(%rdi,%rcx,4), %esi
testl %esi, %esi
jne 0x1b130
jmp 0x1b14b
movl $0x1, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: addToSavepointBitvecs
static int addToSavepointBitvecs(Pager *pPager, Pgno pgno){
  int ii;                   /* Loop counter */
  int rc = SQLITE_OK;       /* Result code */

  for(ii=0; ii<pPager->nSavepoint; ii++){
    PagerSavepoint *p = &pPager->aSavepoint[ii];
    if( pgno<=p->nOrig ){
      rc |= sqlite3BitvecSet(p->pInSavepoint, pgno);
      testcase( rc==SQLITE_NOMEM );
      assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x80(%rdi), %eax
testl %eax, %eax
jle 0x1b1a7
movl %esi, %ebx
movq %rdi, %r14
xorl %r12d, %r12d
movl $0x18, %r13d
xorl %r15d, %r15d
movq 0x78(%r14), %rcx
cmpl %ebx, (%rcx,%r13)
jb 0x1b196
movq -0x8(%rcx,%r13), %rdi
movl %ebx, %esi
callq 0x1b472
orl %eax, %r15d
movl 0x80(%r14), %eax
incq %r12
movslq %eax, %rcx
addq $0x30, %r13
cmpq %rcx, %r12
jl 0x1b176
jmp 0x1b1aa
xorl %r15d, %r15d
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_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: memjrnlRead
static int memjrnlRead(
  sqlite3_file *pJfd,    /* The journal file from which to read */
  void *zBuf,            /* Put the results here */
  int iAmt,              /* Number of bytes to read */
  sqlite_int64 iOfst     /* Begin reading at this offset */
){
  MemJournal *p = (MemJournal *)pJfd;
  u8 *zOut = zBuf;
  int nRead = iAmt;
  int iChunkOffset;
  FileChunk *pChunk;

  /* SQLite never tries to read past the end of a rollback journal file */
  assert( iOfst+iAmt<=p->endpoint.iOffset );

  if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
    sqlite3_int64 iOff = 0;
    for(pChunk=p->pFirst; 
        ALWAYS(pChunk) && (iOff+JOURNAL_CHUNKSIZE)<=iOfst;
        pChunk=pChunk->pNext
    ){
      iOff += JOURNAL_CHUNKSIZE;
    }
  }else{
    pChunk = p->readpoint.pChunk;
  }

  iChunkOffset = (int)(iOfst%JOURNAL_CHUNKSIZE);
  do {
    int iSpace = JOURNAL_CHUNKSIZE - iChunkOffset;
    int nCopy = MIN(nRead, (JOURNAL_CHUNKSIZE - iChunkOffset));
    memcpy(zOut, &pChunk->zChunk[iChunkOffset], nCopy);
    zOut += nCopy;
    nRead -= iSpace;
    iChunkOffset = 0;
  } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );
  p->readpoint.iOffset = iOfst+iAmt;
  p->readpoint.pChunk = pChunk;

  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r8
movl %edx, %r14d
movq %rsi, %r12
testq %rcx, %rcx
je 0x1b23c
cmpq %r8, 0x20(%rdi)
jne 0x1b23c
movq 0x28(%rdi), %r15
jmp 0x1b25c
leaq 0x8(%rdi), %r15
movl $0x3f8, %eax            # imm = 0x3F8
movq (%r15), %r15
testq %r15, %r15
je 0x1b25c
leaq 0x3f8(%rax), %rcx
cmpq %r8, %rax
movq %rcx, %rax
jle 0x1b245
movq %rdi, -0x38(%rbp)
movabsq $0x4081020408102041, %rcx # imm = 0x4081020408102041
movq %r8, %rax
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
shrq $0x8, %rdx
addl %eax, %edx
imull $0x3f8, %edx, %ecx      # imm = 0x3F8
movq %r8, -0x40(%rbp)
movl %r8d, %eax
subl %ecx, %eax
movl %r14d, -0x2c(%rbp)
movl $0x3f8, %ebx            # imm = 0x3F8
subl %eax, %ebx
cmpl %ebx, %r14d
movl %ebx, %ecx
cmovll %r14d, %ecx
cltq
leaq (%r15,%rax), %rsi
addq $0x8, %rsi
movslq %ecx, %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x82f0
subl %ebx, %r14d
js 0x1b2cc
movq (%r15), %r15
je 0x1b2cc
addq %r13, %r12
xorl %eax, %eax
testq %r15, %r15
jne 0x1b290
movslq -0x2c(%rbp), %rax
addq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rax, 0x20(%rcx)
movq %r15, 0x28(%rcx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: memjrnlWrite
static int memjrnlWrite(
  sqlite3_file *pJfd,    /* The journal file into which to write */
  const void *zBuf,      /* Take data to be written from here */
  int iAmt,              /* Number of bytes to write */
  sqlite_int64 iOfst     /* Begin writing at this offset into the file */
){
  MemJournal *p = (MemJournal *)pJfd;
  int nWrite = iAmt;
  u8 *zWrite = (u8 *)zBuf;

  /* An in-memory journal file should only ever be appended to. Random
  ** access writes are not required by sqlite.
  */
  assert( iOfst==p->endpoint.iOffset );
  UNUSED_PARAMETER(iOfst);

  while( nWrite>0 ){
    FileChunk *pChunk = p->endpoint.pChunk;
    int iChunkOffset = (int)(p->endpoint.iOffset%JOURNAL_CHUNKSIZE);
    int iSpace = MIN(nWrite, JOURNAL_CHUNKSIZE - iChunkOffset);

    if( iChunkOffset==0 ){
      /* New chunk is required to extend the file. */
      FileChunk *pNew = sqlite3_malloc(sizeof(FileChunk));
      if( !pNew ){
        return SQLITE_IOERR_NOMEM;
      }
      pNew->pNext = 0;
      if( pChunk ){
        assert( p->pFirst );
        pChunk->pNext = pNew;
      }else{
        assert( !p->pFirst );
        p->pFirst = pNew;
      }
      p->endpoint.pChunk = pNew;
    }

    memcpy(&p->endpoint.pChunk->zChunk[iChunkOffset], zWrite, iSpace);
    zWrite += iSpace;
    nWrite -= iSpace;
    p->endpoint.iOffset += iSpace;
  }

  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testl %edx, %edx
jle 0x1b3ed
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x8(%rdi), %rax
movq %rax, -0x40(%rbp)
movq 0x10(%rdi), %r12
movq %rdi, -0x38(%rbp)
movq 0x18(%r15), %r15
movq %r12, %rax
movabsq $0x4081020408102041, %rcx # imm = 0x4081020408102041
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x8, %rdx
addq %rax, %rdx
imulq $0x3f8, %rdx, %rax      # imm = 0x3F8
subq %rax, %r12
movl $0x3f8, %r13d           # imm = 0x3F8
subl %r12d, %r13d
cmpl %r13d, %ebx
cmovbl %ebx, %r13d
testq %r12, %r12
je 0x1b36c
movq %r15, %rax
movq -0x38(%rbp), %r15
jmp 0x1b3c3
callq 0x9d86
movl $0xc0a, -0x2c(%rbp)     # imm = 0xC0A
testl %eax, %eax
jne 0x1b3f4
cmpl $0x0, 0x7907d(%rip)     # 0x94400
je 0x1b399
movl $0x400, %edi            # imm = 0x400
leaq -0x48(%rbp), %rsi
callq 0x171f8
movq -0x48(%rbp), %rax
jmp 0x1b3a4
movl $0x400, %edi            # imm = 0x400
callq *0x7907c(%rip)          # 0x94420
testq %rax, %rax
je 0x1b3f4
movq $0x0, (%rax)
testq %r15, %r15
cmoveq -0x40(%rbp), %r15
movq %rax, (%r15)
movq -0x38(%rbp), %r15
movq %rax, 0x18(%r15)
leaq (%rax,%r12), %rdi
addq $0x8, %rdi
movl %r13d, %r12d
movq %r14, %rsi
movq %r12, %rdx
callq 0x82f0
addq %r12, %r14
addq 0x10(%r15), %r12
movq %r12, 0x10(%r15)
subl %r13d, %ebx
jg 0x1b322
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: memjrnlTruncate
static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
  MemJournal *p = (MemJournal *)pJfd;
  FileChunk *pChunk;
  assert(size==0);
  UNUSED_PARAMETER(size);
  pChunk = p->pFirst;
  while( pChunk ){
    FileChunk *pTmp = pChunk;
    pChunk = pChunk->pNext;
    sqlite3_free(pTmp);
  }
  sqlite3MemJournalOpen(pJfd);
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x1b430
movq (%rdi), %r15
callq 0xa3c7
movq %r15, %rdi
testq %r15, %r15
jne 0x1b420
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movq $0x0, 0x20(%r14)
leaq 0x77a05(%rip), %rax     # 0x92e50
movq %rax, (%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BitvecCreate
SQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32 iSize){
  Bitvec *p;
  assert( sizeof(*p)==BITVEC_SZ );
  p = sqlite3MallocZero( sizeof(*p) );
  if( p ){
    p->iSize = iSize;
  }
  return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
cmpl $0x0, 0x78dce(%rip)     # 0x94400
je 0x1b64a
leaq -0x18(%rbp), %r14
movl $0x200, %edi            # imm = 0x200
movq %r14, %rsi
callq 0x171f8
movq (%r14), %r14
jmp 0x1b658
movl $0x200, %edi            # imm = 0x200
callq *0x78dcb(%rip)          # 0x94420
movq %rax, %r14
testq %r14, %r14
je 0x1b670
leaq 0x4(%r14), %rdi
movl $0x1fc, %edx            # imm = 0x1FC
xorl %esi, %esi
callq 0x8200
movl %ebx, (%r14)
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BackupUpdate
SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){
  sqlite3_backup *p;                   /* Iterator variable */
  for(p=pBackup; p; p=p->pNext){
    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );
    if( !isFatalError(p->rc) && iPage<p->iNext ){
      /* The backup process p has already copied page iPage. But now it
      ** has been modified by a transaction on the source pager. Copy
      ** the new data into the backup.
      */
      int rc;
      assert( p->pDestDb );
      sqlite3_mutex_enter(p->pDestDb->mutex);
      rc = backupOnePage(p, iPage, aData, 1);
      sqlite3_mutex_leave(p->pDestDb->mutex);
      assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED );
      if( rc!=SQLITE_OK ){
        p->rc = rc;
      }
    }
  }
}

// Assembly:
testq %rdi, %rdi
je 0x1b70b
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
movl $0x61, %r12d
movl 0x30(%r15), %eax
cmpl $0x6, %eax
ja 0x1b6fa
btl %eax, %r12d
jae 0x1b6fa
cmpl %r14d, 0x18(%r15)
jbe 0x1b6fa
movq %r15, %rdi
movl %r14d, %esi
movq %rbx, %rdx
movl $0x1, %ecx
callq 0xdc62
testl %eax, %eax
je 0x1b6fa
movl %eax, 0x30(%r15)
movq 0x40(%r15), %r15
testq %r15, %r15
jne 0x1b6ca
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walChecksumBytes
static void walChecksumBytes(
  int nativeCksum, /* True for native byte-order, false for non-native */
  u8 *a,           /* Content to be checksummed */
  int nByte,       /* Bytes of content in a[].  Must be a multiple of 8. */
  const u32 *aIn,  /* Initial checksum value input */
  u32 *aOut        /* OUT: Final checksum value output */
){
  u32 s1, s2;
  u32 *aData = (u32 *)a;
  u32 *aEnd = (u32 *)&a[nByte];

  if( aIn ){
    s1 = aIn[0];
    s2 = aIn[1];
  }else{
    s1 = s2 = 0;
  }

  assert( nByte>=8 );
  assert( (nByte&0x00000007)==0 );

  if( nativeCksum ){
    do {
      s1 += *aData++ + s2;
      s2 += *aData++ + s1;
    }while( aData<aEnd );
  }else{
    do {
      s1 += BYTESWAP32(aData[0]) + s2;
      s2 += BYTESWAP32(aData[1]) + s1;
      aData += 2;
    }while( aData<aEnd );
  }

  aOut[0] = s1;
  aOut[1] = s2;
}

// Assembly:
movslq %edx, %rax
testq %rcx, %rcx
je 0x1b71c
movl (%rcx), %edx
movl 0x4(%rcx), %r9d
jmp 0x1b721
xorl %r9d, %r9d
xorl %edx, %edx
pushq %rbp
movq %rsp, %rbp
addq %rsi, %rax
testl %edi, %edi
je 0x1b743
movl %r9d, %ecx
addl %ecx, %edx
addl (%rsi), %edx
addl 0x4(%rsi), %ecx
addq $0x8, %rsi
addl %edx, %ecx
cmpq %rax, %rsi
jb 0x1b72f
jmp 0x1b762
movl (%rsi), %edi
movl 0x4(%rsi), %ecx
bswapl %edi
addl %r9d, %edx
addl %edi, %edx
bswapl %ecx
addl %r9d, %ecx
addl %edx, %ecx
addq $0x8, %rsi
movl %ecx, %r9d
cmpq %rax, %rsi
jb 0x1b743
movl %edx, (%r8)
movl %ecx, 0x4(%r8)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walWriteOneFrame
static int walWriteOneFrame(
  WalWriter *p,               /* Where to write the frame */
  PgHdr *pPage,               /* The page of the frame to be written */
  int nTruncate,              /* The commit flag.  Usually 0.  >0 for commit */
  sqlite3_int64 iOffset       /* Byte offset at which to write */
){
  int rc;                         /* Result code from subfunctions */
  void *pData;                    /* Data actually written */
  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-header in */
#if defined(SQLITE_HAS_CODEC)
  if( (pData = sqlite3PagerCodec(pPage))==0 ) return SQLITE_NOMEM;
#else
  pData = pPage->pData;
#endif
  walEncodeFrame(p->pWal, pPage->pgno, nTruncate, pData, aFrame);
  rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);
  if( rc ) return rc;
  /* Write the page data */
  rc = walWriteToLog(p, pData, p->szPage, iOffset+sizeof(aFrame));
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, -0x38(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdi, %r15
movq (%rdi), %rbx
leaq 0x60(%rbx), %r13
movl %edx, %eax
shrl $0x18, %eax
leaq -0x50(%rbp), %r12
movb %al, (%r12)
movl %edx, %eax
shrl $0x10, %eax
movb %al, 0x1(%r12)
movb %dh, -0x4e(%rbp)
movb %dl, 0x3(%r12)
movl %ecx, %eax
shrl $0x18, %eax
movb %al, 0x4(%r12)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x5(%r12)
movb %ch, -0x4a(%rbp)
movb %cl, 0x7(%r12)
movq 0x68(%rbx), %rax
movq %rax, 0x8(%r12)
xorl %r14d, %r14d
cmpb $0x0, 0x55(%rbx)
sete %r14b
movl %r14d, %edi
movq %r12, %rsi
movl $0x8, %edx
movq %r13, %rcx
movq %r13, %r8
callq 0x1b70c
movl 0x38(%rbx), %edx
movl %r14d, %edi
movq -0x30(%rbp), %r14
movq %r14, %rsi
movq %r13, %rcx
movq %r13, %r8
callq 0x1b70c
movl 0x60(%rbx), %eax
bswapl %eax
movl %eax, 0x10(%r12)
movl 0x64(%rbx), %eax
movq -0x38(%rbp), %rbx
bswapl %eax
movl %eax, 0x14(%r12)
movq %r15, %rdi
movq %r12, %rsi
movl $0x18, %edx
movq %rbx, %rcx
callq 0x1c63e
testl %eax, %eax
jne 0x1b850
movl 0x1c(%r15), %edx
addq $0x18, %rbx
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x1c63e
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walLimitSize
static void walLimitSize(Wal *pWal, i64 nMax){
  i64 sz;
  int rx;
  sqlite3BeginBenignMalloc();
  rx = sqlite3OsFileSize(pWal->pWalFd, &sz);
  if( rx==SQLITE_OK && (sz > nMax ) ){
    rx = sqlite3OsTruncate(pWal->pWalFd, nMax);
  }
  sqlite3EndBenignMalloc();
  if( rx ){
    sqlite3_log(rx, "cannot limit WAL size: %s", pWal->zWalName);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x7a6ea(%rip), %rax     # 0x95f60
testq %rax, %rax
je 0x1b87d
callq *%rax
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
leaq -0x20(%rbp), %rsi
callq *0x30(%rax)
movl %eax, %r15d
testl %eax, %eax
jne 0x1b8ab
xorl %r15d, %r15d
cmpq %r14, -0x20(%rbp)
jle 0x1b8ab
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x20(%rax)
movl %eax, %r15d
movq 0x7a6b6(%rip), %rax     # 0x95f68
testq %rax, %rax
je 0x1b8b9
callq *%rax
testl %r15d, %r15d
je 0x1b8d3
movq 0x78(%rbx), %rdx
leaq 0x5df31(%rip), %rsi     # 0x797fa
movl %r15d, %edi
xorl %eax, %eax
callq 0xb9c7
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walIndexPage
static int walIndexPage(Wal *pWal, int iPage, volatile u32 **ppPage){
  int rc = SQLITE_OK;

  /* Enlarge the pWal->apWiData[] array if required */
  if( pWal->nWiData<=iPage ){
    int nByte = sizeof(u32*)*(iPage+1);
    volatile u32 **apNew;
    apNew = (volatile u32 **)sqlite3_realloc((void *)pWal->apWiData, nByte);
    if( !apNew ){
      *ppPage = 0;
      return SQLITE_NOMEM;
    }
    memset((void*)&apNew[pWal->nWiData], 0,
           sizeof(u32*)*(iPage+1-pWal->nWiData));
    pWal->apWiData = apNew;
    pWal->nWiData = iPage+1;
  }

  /* Request a pointer to the required page from the VFS */
  if( pWal->apWiData[iPage]==0 ){
    if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){
      pWal->apWiData[iPage] = (u32 volatile *)sqlite3MallocZero(WALINDEX_PGSZ);
      if( !pWal->apWiData[iPage] ) rc = SQLITE_NOMEM;
    }else{
      rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ, 
          pWal->writeLock, (void volatile **)&pWal->apWiData[iPage]
      );
      if( rc==SQLITE_READONLY ){
        pWal->readOnly |= WAL_SHM_RDONLY;
        rc = SQLITE_OK;
      }
    }
  }

  *ppPage = pWal->apWiData[iPage];
  assert( iPage==0 || *ppPage || rc!=SQLITE_OK );
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rdi, %r14
movslq %esi, %r15
cmpl %esi, 0x28(%rdi)
jle 0x1bfc7
movq 0x30(%r14), %r13
xorl %r12d, %r12d
cmpq $0x0, (%r13,%r15,8)
jne 0x1c0ac
cmpb $0x2, 0x3f(%r14)
jne 0x1c031
cmpl $0x0, 0x78459(%rip)     # 0x94400
je 0x1c06d
leaq -0x38(%rbp), %r12
movl $0x8000, %edi           # imm = 0x8000
movq %r12, %rsi
callq 0x171f8
movq (%r12), %r12
jmp 0x1c07b
movq 0x30(%r14), %r13
callq 0x9d86
movl $0x7, %r12d
testl %eax, %eax
je 0x1bfe1
xorl %eax, %eax
jmp 0x1c0b4
movq %rbx, -0x30(%rbp)
leaq 0x1(%r15), %rbx
leal (,%rbx,8), %esi
movq %r13, %rdi
callq 0xa45c
testq %rax, %rax
je 0x1c065
movq %rax, %r13
movslq 0x28(%r14), %rax
leaq (,%rax,8), %rdi
addq %r13, %rdi
movq %rbx, %rdx
subq %rax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x8200
movq %r13, 0x30(%r14)
movl %ebx, 0x28(%r14)
movq -0x30(%rbp), %rbx
jmp 0x1bf86
leaq (,%r15,8), %r8
addq %r13, %r8
movq 0x8(%r14), %rdi
movzbl 0x40(%r14), %ecx
movq (%rdi), %rax
movl %r15d, %esi
movl $0x8000, %edx           # imm = 0x8000
callq *0x68(%rax)
movl %eax, %r12d
cmpl $0x8, %eax
jne 0x1c0ac
orb $0x2, 0x42(%r14)
xorl %r12d, %r12d
jmp 0x1c0ac
xorl %eax, %eax
movq -0x30(%rbp), %rbx
jmp 0x1c0b4
movl $0x8000, %edi           # imm = 0x8000
callq *0x783a8(%rip)          # 0x94420
movq %rax, %r12
testq %r12, %r12
je 0x1c08f
movl $0x8000, %edx           # imm = 0x8000
movq %r12, %rdi
xorl %esi, %esi
callq 0x8200
movq 0x30(%r14), %rax
movq %r12, (%rax,%r15,8)
movq 0x30(%r14), %rax
xorl %ecx, %ecx
cmpq $0x0, (%rax,%r15,8)
movl $0x7, %r12d
cmovnel %ecx, %r12d
movq 0x30(%r14), %rax
movq (%rax,%r15,8), %rax
movq %rax, (%rbx)
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walDecodeFrame
static int walDecodeFrame(
  Wal *pWal,                      /* The write-ahead log */
  u32 *piPage,                    /* OUT: Database page number for frame */
  u32 *pnTruncate,                /* OUT: New db size (or 0 if not commit) */
  u8 *aData,                      /* Pointer to page data (for checksum) */
  u8 *aFrame                      /* Frame data */
){
  int nativeCksum;                /* True for native byte-order checksums */
  u32 *aCksum = pWal->hdr.aFrameCksum;
  u32 pgno;                       /* Page number of the frame */
  assert( WAL_FRAME_HDRSIZE==24 );

  /* A frame is only valid if the salt values in the frame-header
  ** match the salt values in the wal-header. 
  */
  if( memcmp(&pWal->hdr.aSalt, &aFrame[8], 8)!=0 ){
    return 0;
  }

  /* A frame is only valid if the page number is creater than zero.
  */
  pgno = sqlite3Get4byte(&aFrame[0]);
  if( pgno==0 ){
    return 0;
  }

  /* A frame is only valid if a checksum of the WAL header,
  ** all prior frams, the first 16 bytes of this frame-header, 
  ** and the frame-data matches the checksum in the last 8 
  ** bytes of this frame-header.
  */
  nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);
  walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);
  walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);
  if( aCksum[0]!=sqlite3Get4byte(&aFrame[16]) 
   || aCksum[1]!=sqlite3Get4byte(&aFrame[20]) 
  ){
    /* Checksum failed. */
    return 0;
  }

  /* If we reach this point, the frame is valid.  Return the page number
  ** and the new database size.
  */
  *piPage = pgno;
  *pnTruncate = sqlite3Get4byte(&aFrame[4]);
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x68(%rdi), %rax
xorl %ebx, %ebx
cmpq 0x8(%r8), %rax
je 0x1c5aa
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, %r15
movl (%r8), %eax
bswapl %eax
testl %eax, %eax
je 0x1c599
movq %rdi, %r13
movl %eax, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
leaq 0x60(%rdi), %r12
xorl %r14d, %r14d
cmpb $0x0, 0x55(%rdi)
sete %r14b
movl %r14d, %edi
movq %r15, %rsi
movl $0x8, %edx
movq %rcx, -0x48(%rbp)
movq %r12, %rcx
movq %r12, %r8
callq 0x1b70c
movl 0x38(%r13), %edx
movl %r14d, %edi
movq -0x48(%rbp), %rsi
movq %r12, %rcx
movq %r12, %r8
callq 0x1b70c
movl 0x10(%r15), %eax
bswapl %eax
cmpl %eax, 0x60(%r13)
jne 0x1c599
movl 0x14(%r15), %eax
bswapl %eax
cmpl %eax, 0x64(%r13)
jne 0x1c599
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
movl 0x4(%r15), %eax
bswapl %eax
movq -0x40(%rbp), %rcx
movl %eax, (%rcx)
movl $0x1, %ebx
jmp 0x1c599
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walWriteToLog
static int walWriteToLog(
  WalWriter *p,              /* WAL to write to */
  void *pContent,            /* Content to be written */
  int iAmt,                  /* Number of bytes to write */
  sqlite3_int64 iOffset      /* Start writing at this offset */
){
  int rc;
  if( iOffset<p->iSyncPoint && iOffset+iAmt>=p->iSyncPoint ){
    int iFirstAmt = (int)(p->iSyncPoint - iOffset);
    rc = sqlite3OsWrite(p->pFd, pContent, iFirstAmt, iOffset);
    if( rc ) return rc;
    iOffset += iFirstAmt;
    iAmt -= iFirstAmt;
    pContent = (void*)(iFirstAmt + (char*)pContent);
    assert( p->syncFlags & (SQLITE_SYNC_NORMAL|SQLITE_SYNC_FULL) );
    rc = sqlite3OsSync(p->pFd, p->syncFlags);
    if( iAmt==0 || rc ) return rc;
  }
  rc = sqlite3OsWrite(p->pFd, pContent, iAmt, iOffset);
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %r12
movq 0x10(%rdi), %rax
movq %rax, %r13
subq %rcx, %r13
jle 0x1c66f
movslq %r14d, %rcx
addq %rbx, %rcx
cmpq %rax, %rcx
jge 0x1c694
movq 0x8(%r12), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
movq %r15, %rsi
movl %r14d, %edx
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq 0x8(%r12), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r13d, %edx
movq %rbx, %rcx
callq *0x18(%rax)
testl %eax, %eax
je 0x1c6bb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r12), %rdi
movl 0x18(%r12), %esi
movq (%rdi), %rax
callq *0x28(%rax)
subl %r13d, %r14d
je 0x1c6ac
testl %eax, %eax
jne 0x1c6ac
movslq %r13d, %rax
addq %rax, %rbx
addq %rax, %r15
jmp 0x1c66f
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PagerExclusiveLock
SQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager *pPager){
  int rc = SQLITE_OK;
  assert( pPager->eState==PAGER_WRITER_CACHEMOD 
       || pPager->eState==PAGER_WRITER_DBMOD 
       || pPager->eState==PAGER_WRITER_LOCKED 
  );
  assert( assert_pager_state(pPager) );
  if( 0==pagerUseWal(pPager) ){
    rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
xorl %ebx, %ebx
cmpq $0x0, 0x118(%rdi)
je 0x1c7a7
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq %rdi, %r14
movzbl 0x14(%r14), %eax
cmpl $0x4, %eax
jb 0x1c7b9
cmpl $0x5, %eax
jne 0x1c7a0
movq 0x48(%r14), %rdi
movq (%rdi), %rax
movl $0x4, %esi
callq *0x38(%rax)
cmpl $0x5, %eax
jne 0x1c7e6
movq 0xe8(%r14), %rdi
callq *0xe0(%r14)
testl %eax, %eax
jne 0x1c7aa
movl $0x5, %ebx
jmp 0x1c7a0
movl %eax, %ebx
testl %eax, %eax
jne 0x1c7a0
movb $0x4, 0x14(%r14)
xorl %ebx, %ebx
jmp 0x1c7a0
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: decodeFlags
static int decodeFlags(MemPage *pPage, int flagByte){
  BtShared *pBt;     /* A copy of pPage->pBt */

  assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );
  assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  pPage->leaf = (u8)(flagByte>>3);  assert( PTF_LEAF == 1<<3 );
  flagByte &= ~PTF_LEAF;
  pPage->childPtrSize = 4-4*pPage->leaf;
  pBt = pPage->pBt;
  if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){
    pPage->intKey = 1;
    pPage->hasData = pPage->leaf;
    pPage->maxLocal = pBt->maxLeaf;
    pPage->minLocal = pBt->minLeaf;
  }else if( flagByte==PTF_ZERODATA ){
    pPage->intKey = 0;
    pPage->hasData = 0;
    pPage->maxLocal = pBt->maxLocal;
    pPage->minLocal = pBt->minLocal;
  }else{
    return SQLITE_CORRUPT_BKPT;
  }
  pPage->max1bytePayload = pBt->max1bytePayload;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %esi, %ecx
shrl $0x3, %ecx
movb %cl, 0x3(%rdi)
andl $-0x9, %esi
movl %ecx, %eax
shll $0x2, %eax
movb $0x4, %dl
subb %al, %dl
movb %dl, 0x6(%rdi)
movq 0x48(%rdi), %rax
cmpl $0x5, %esi
je 0x1cbcf
cmpl $0x2, %esi
jne 0x1cbfd
movl $0x2a, %edx
movl $0x28, %esi
xorl %r8d, %r8d
xorl %ecx, %ecx
jmp 0x1cbdc
movl $0x2e, %edx
movl $0x2c, %esi
movb $0x1, %r8b
movb %r8b, 0x2(%rdi)
movb %cl, 0x4(%rdi)
movzwl (%rax,%rsi), %ecx
movw %cx, 0x8(%rdi)
movzwl (%rax,%rdx), %ecx
movw %cx, 0xa(%rdi)
movb 0x25(%rax), %al
movb %al, 0x7(%rdi)
xorl %ebx, %ebx
jmp 0x1cc21
leaq 0x5cc10(%rip), %rsi     # 0x79814
leaq 0x5c92e(%rip), %rcx     # 0x79539
movl $0xb, %ebx
movl $0xb, %edi
movl $0xc723, %edx           # imm = 0xC723
xorl %eax, %eax
callq 0xb9c7
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerFixMaplimit
static void pagerFixMaplimit(Pager *pPager){
#if SQLITE_MAX_MMAP_SIZE>0
  sqlite3_file *fd = pPager->fd;
  if( isOpen(fd) && fd->pMethods->iVersion>=3 ){
    sqlite3_int64 sz;
    sz = pPager->szMmap;
    pPager->bUseFetch = (sz>0);
    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, &sz);
  }
#endif
}

// Assembly:
movq %rdi, %rax
movq 0x48(%rdi), %rdi
movq (%rdi), %rcx
testq %rcx, %rcx
je 0x1cc6b
cmpl $0x3, (%rcx)
jl 0x1cc6b
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq 0xa0(%rax), %rsi
leaq -0x8(%rbp), %rdx
movq %rsi, (%rdx)
testq %rsi, %rsi
setg 0x94(%rax)
movl $0x12, %esi
callq *0x50(%rcx)
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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, 0x7905e(%rip)     # 0x95cfc
cmpl %edi, 0x79080(%rip)     # 0x95d24
jge 0x1ccac
movl %edi, 0x79078(%rip)     # 0x95d24
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpl %edi, 0x792e4(%rip)     # 0x95f9c
jl 0x1cd0f
movq 0x792ff(%rip), %rbx     # 0x95fc0
testq %rbx, %rbx
je 0x1cd0f
movq (%rbx), %rax
movq %rax, 0x792f0(%rip)     # 0x95fc0
movl 0x792f2(%rip), %eax     # 0x95fc8
leal -0x1(%rax), %ecx
movl %ecx, 0x792e9(%rip)     # 0x95fc8
xorl %ecx, %ecx
cmpl 0x792bd(%rip), %eax     # 0x95fa4
setle %cl
movl %ecx, 0x792dc(%rip)     # 0x95fcc
movl 0x78fee(%rip), %ecx     # 0x95ce4
leal 0x1(%rcx), %eax
movl %eax, 0x78fe5(%rip)     # 0x95ce4
cmpl 0x79007(%rip), %ecx     # 0x95d0c
jl 0x1cd43
movl %eax, 0x78fff(%rip)     # 0x95d0c
jmp 0x1cd43
callq 0xa38c
testq %rax, %rax
je 0x1cd41
movq %rax, %rbx
movq %rax, %rdi
callq *0x77713(%rip)          # 0x94438
addl 0x78fbd(%rip), %eax     # 0x95ce8
movl %eax, 0x78fb7(%rip)     # 0x95ce8
cmpl 0x78fd9(%rip), %eax     # 0x95d10
jle 0x1cd43
movl %eax, 0x78fd1(%rip)     # 0x95d10
jmp 0x1cd43
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x1cda8
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 0x1cd83
movq 0x38(%rdi), %r15
cmpl %r14d, 0x28(%rdi)
jbe 0x1cd7b
callq 0x1b05b
movq %r15, %rdi
testq %r15, %r15
jne 0x1cd6c
testl %r14d, %r14d
jne 0x1cdac
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x1cda9
movq 0x8(%rax), %rdi
movslq 0x20(%rbx), %rdx
xorl %esi, %esi
callq 0x8200
movl $0x1, %r14d
jmp 0x1cdac
retq
xorl %r14d, %r14d
movq 0x77745(%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_O3/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 0x1ce35
movq %rdi, %rbx
cmpq %rdi, 0x791ca(%rip)     # 0x95fa8
ja 0x1ce3c
cmpq %rbx, 0x791c9(%rip)     # 0x95fb0
jbe 0x1ce3c
movl 0x78ef5(%rip), %eax     # 0x95ce4
decl %eax
movl %eax, 0x78eed(%rip)     # 0x95ce4
cmpl 0x78f0f(%rip), %eax     # 0x95d0c
jle 0x1ce05
movl %eax, 0x78f07(%rip)     # 0x95d0c
movq 0x791b4(%rip), %rax     # 0x95fc0
movq %rax, (%rbx)
movq %rbx, 0x791aa(%rip)     # 0x95fc0
movl 0x791ac(%rip), %eax     # 0x95fc8
incl %eax
movl %eax, 0x791a4(%rip)     # 0x95fc8
xorl %ecx, %ecx
cmpl 0x79178(%rip), %eax     # 0x95fa4
setl %cl
movl %ecx, 0x79197(%rip)     # 0x95fcc
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq *0x775f3(%rip)          # 0x94438
movl 0x78e9d(%rip), %ecx     # 0x95ce8
subl %eax, %ecx
movl %ecx, 0x78e95(%rip)     # 0x95ce8
cmpl 0x78eb7(%rip), %ecx     # 0x95d10
jle 0x1ce61
movl %ecx, 0x78eaf(%rip)     # 0x95d10
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xa3c7
// File: /workspace/github_c_makefile_star2_O3/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
cmpb $0x0, 0xb(%rdi)
je 0x1d0dd
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
movq 0x50(%rbx), %rdi
movq (%rdi), %rax
movl $0x2, %esi
callq *0x28(%rax)
testl %eax, %eax
je 0x1d0c3
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x1d14a
cmpl $0x1, %eax
je 0x1d138
cmpl $0x6, %eax
je 0x1d14a
movq 0x78e47(%rip), %rax     # 0x95f60
testq %rax, %rax
je 0x1d120
callq *%rax
movq %rbx, %rdi
callq 0x1de22
movq 0x78e39(%rip), %rax     # 0x95f68
testq %rax, %rax
je 0x1d14a
callq *%rax
jmp 0x1d14a
cmpb $0x0, 0x8(%rbx)
jne 0x1d14a
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1decc
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1cfa6
// File: /workspace/github_c_makefile_star2_O3/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 0x1dbfd
cmpl $0x0, 0x28(%rbx)
jle 0x1dbf8
xorl %r14d, %r14d
movq 0x30(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0xa3c7
movq 0x30(%rbx), %rax
movq $0x0, (%rax,%r14,8)
incq %r14
movslq 0x28(%rbx), %rax
cmpq %rax, %r14
jl 0x1dbd3
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_O3/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 0x1dccc
movq %rcx, -0x30(%rbp)
movq (%rcx), %rcx
xorl %eax, %eax
xorl %r14d, %r14d
xorl %ebx, %ebx
testb $0x1, %r12b
je 0x1dc7f
movslq %r14d, %r12
testb $0x1, %r15b
je 0x1dc74
movzwl (%rsi,%r12,2), %r15d
movl (%rdi,%r15,4), %r13d
movslq %ebx, %r15
movzwl (%rcx,%r15,2), %r11d
cmpl (%rdi,%r11,4), %r13d
jae 0x1dc82
leal 0x1(%r12), %r14d
leaq (%rsi,%r12,2), %r15
jmp 0x1dc88
movslq %ebx, %r15
incl %ebx
leaq (%rcx,%r15,2), %r15
movzwl (%r15), %r11d
movl (%rdi,%r11,4), %r15d
movw %r11w, (%r9,%rax,2)
cmpl %edx, %r14d
jge 0x1dcb0
movslq %r14d, %r11
movzwl (%rsi,%r11,2), %r11d
xorl %r12d, %r12d
cmpl %r15d, (%rdi,%r11,4)
sete %r12b
addl %r12d, %r14d
cmpl %edx, %r14d
setl %r12b
incq %rax
cmpl %r10d, %ebx
setl %r15b
jl 0x1dc4e
cmpl %edx, %r14d
jl 0x1dc4e
movq -0x30(%rbp), %rcx
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_O3/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 0x1dd25
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x8(%rdi)
je 0x1dd19
movl $0x2, %r14d
movq (%rbx,%r14,8), %rdi
callq 0x1dcec
incq %r14
cmpq $0x40, %r14
jne 0x1dd07
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0xa3c7
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x1dd65
movl $0x10, %r14d
xorl %r15d, %r15d
movq 0x78(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x1dcec
incq %r15
movslq 0x80(%rbx), %rax
addq $0x30, %r14
cmpq %rax, %r15
jl 0x1dd45
cmpb $0x0, 0x8(%rbx)
movq 0x58(%rbx), %r14
movq (%r14), %rax
je 0x1ddb5
leaq 0x750d7(%rip), %rcx     # 0x92e50
cmpq %rcx, %rax
movq %rcx, %rax
jne 0x1dd8e
movq %r14, %rdi
callq *0x8(%rax)
movq $0x0, (%r14)
movq 0x78(%rbx), %rdi
callq 0xa3c7
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
testq %rax, %rax
jne 0x1dd81
jmp 0x1dd8e
// File: /workspace/github_c_makefile_star2_O3/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 0x1ddef
cmpb $0x0, 0x3f(%rbx)
jne 0x1dde7
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 0x1de1b
cmpb $0x0, 0x3f(%rbx)
jne 0x1de15
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_O3/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 0x1de3b
movl 0x2c(%rbx), %eax
jmp 0x1dea6
xorl %eax, %eax
cmpb $0x2, %r14b
jb 0x1dea6
cmpq $0x0, 0x118(%rbx)
je 0x1de79
movq %rbx, %rdi
movl $0x2, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x1e17d
movl %eax, %r14d
movzbl 0x16(%rbx), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1decc
testl %r14d, %r14d
cmovnel %r14d, %eax
jmp 0x1de93
cmpb $0x2, %r14b
je 0x1deab
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x1deab
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1e62e
cmpb $0xd, %al
je 0x1de9f
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x1dea6
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 0x1decc
cmpb $0x2, %r14b
je 0x1de93
cmpb $0x0, 0x12(%rbx)
jne 0x1de93
movl $0x4, 0x2c(%rbx)
jmp 0x1dea2
// File: /workspace/github_c_makefile_star2_O3/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
movq 0x110(%rdi), %rdi
leaq -0x28(%rbp), %r15
movq $0x0, (%r15)
xorl %r14d, %r14d
xorl %edx, %edx
movq %r15, %rcx
callq 0x1f4e2
movq (%r15), %r15
testq %r15, %r15
je 0x1f15a
cmpw $0x1, 0x2e(%r15)
jne 0x1f122
movq %r15, %rdi
callq 0x1f27c
jmp 0x1f15a
leaq -0x1c(%rbp), %rdx
movl $0x0, (%rdx)
movq 0x118(%rbx), %rdi
movl 0x28(%r15), %esi
callq 0x1f2c3
testl %eax, %eax
jne 0x1f14f
movl -0x1c(%rbp), %esi
movq %r15, %rdi
callq 0x1f42a
testl %eax, %eax
je 0x1f17e
movl %eax, %r14d
movq %r15, %rdi
callq 0xddd3
movq 0x70(%rbx), %rax
testq %rax, %rax
je 0x1f170
movl $0x1, 0x18(%rax)
movq 0x40(%rax), %rax
jmp 0x1f15e
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq *0x100(%rbx)
xorl %r14d, %r14d
jmp 0x1f152
// File: /workspace/github_c_makefile_star2_O3/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), %r14
testq %r14, %r14
je 0x1f236
movq %r14, %rax
movq 0x38(%rax), %rcx
movq %rcx, 0x18(%rax)
movq %rcx, %rax
testq %rcx, %rcx
jne 0x1f1a9
leaq -0x110(%rbp), %rdi
xorl %ebx, %ebx
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x8200
testq %r14, %r14
je 0x1f24b
movq %r14, %rax
movq 0x18(%r14), %r14
movq $0x0, 0x18(%rax)
xorl %ebx, %ebx
movq -0x110(%rbp,%rbx,8), %rdi
testq %rdi, %rdi
je 0x1f220
movq %rax, %rsi
callq 0x1f6db
movq $0x0, -0x110(%rbp,%rbx,8)
incq %rbx
cmpq $0x1f, %rbx
jne 0x1f1e4
movq -0x18(%rbp), %rdi
movq %rax, %rsi
callq 0x1f6db
movq %rax, -0x18(%rbp)
jmp 0x1f228
movq %rax, -0x110(%rbp,%rbx,8)
testq %r14, %r14
jne 0x1f1d3
movq -0x110(%rbp), %rbx
jmp 0x1f24b
leaq -0x110(%rbp), %rdi
xorl %ebx, %ebx
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x8200
movl $0x1, %r14d
movq -0x110(%rbp,%r14,8), %rsi
movq %rbx, %rdi
callq 0x1f6db
movq %rax, %rbx
incq %r14
cmpq $0x20, %r14
jne 0x1f251
movq %rbx, %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %rbp
retq