LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/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, %rax
movl %edx, %r14d
movq %rsi, %r12
testq %rcx, %rcx
je 0x18f12
cmpq %rax, 0x20(%rdi)
jne 0x18f12
movq 0x28(%rdi), %r15
jmp 0x18f32
leaq 0x8(%rdi), %r15
movl $0x3f8, %edx            # imm = 0x3F8
movq (%r15), %r15
testq %r15, %r15
je 0x18f32
leaq 0x3f8(%rdx), %rcx
cmpq %rax, %rdx
movq %rcx, %rdx
jle 0x18f1b
movq %rdi, -0x38(%rbp)
movl $0x3f8, %ecx            # imm = 0x3F8
movq %rax, -0x40(%rbp)
cqto
idivq %rcx
movl %r14d, -0x2c(%rbp)
movl $0x3f8, %ebx            # imm = 0x3F8
subl %edx, %ebx
cmpl %ebx, %r14d
movl %ebx, %eax
cmovll %r14d, %eax
movslq %edx, %rcx
leaq (%r15,%rcx), %rsi
addq $0x8, %rsi
movslq %eax, %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x82c0
subl %ebx, %r14d
js 0x18f85
movq (%r15), %r15
je 0x18f85
addq %r13, %r12
xorl %edx, %edx
testq %r15, %r15
jne 0x18f48
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_O2/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 $0x18, %rsp
movl %edx, %ecx
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x8(%rdi), %rax
movq %rax, -0x38(%rbp)
testl %ecx, %ecx
jle 0x19046
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %r14
cqto
movl $0x3f8, %esi            # imm = 0x3F8
idivq %rsi
movq %rdx, %r12
movl $0x3f8, %r13d           # imm = 0x3F8
subl %r12d, %r13d
cmpl %r13d, %ecx
movl %ecx, -0x2c(%rbp)
cmovbl %ecx, %r13d
testq %rdx, %rdx
jne 0x19021
movl $0x400, %edi            # imm = 0x400
callq 0x9c1c
testq %rax, %rax
je 0x1904a
andq $0x0, (%rax)
testq %r14, %r14
cmoveq -0x38(%rbp), %r14
movq %rax, (%r14)
movq %rax, 0x18(%rbx)
movq %rax, %r14
leaq (%r14,%r12), %rdi
addq $0x8, %rdi
movl %r13d, %r12d
movq %r15, %rsi
movq %r12, %rdx
callq 0x82c0
addq %r12, %r15
movl -0x2c(%rbp), %ecx
subl %r13d, %ecx
addq %r12, 0x10(%rbx)
jmp 0x18fcb
xorl %eax, %eax
jmp 0x1904f
movl $0xc0a, %eax            # imm = 0xC0A
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x19085
movq (%rdi), %r15
callq 0x9c7b
movq %r15, %rdi
jmp 0x19073
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
andq $0x0, 0x20(%r14)
movups %xmm0, (%r14)
leaq 0x6ce03(%rip), %rax     # 0x85ea0
movq %rax, (%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
pushq %rax
movl %edi, %ebx
movl $0x200, %edi            # imm = 0x200
callq 0xbeb2
testq %rax, %rax
je 0x1923a
movl %ebx, (%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pager_write_changecounter
static void pager_write_changecounter(PgHdr *pPg){
  u32 change_counter;

  /* Increment the value just read and write it back to byte 24. */
  change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1;
  put32bits(((char*)pPg->pData)+24, change_counter);

  /* Also store the SQLite version number in bytes 96..99 and in
  ** bytes 92..95 store the change counter for which the version number
  ** is valid. */
  put32bits(((char*)pPg->pData)+92, change_counter);
  put32bits(((char*)pPg->pData)+96, SQLITE_VERSION_NUMBER);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x84, %edi
addq 0x20(%rbx), %rdi
callq 0x180a3
incl %eax
movq 0x8(%rbx), %rcx
bswapl %eax
movl %eax, 0x18(%rcx)
movq 0x8(%rbx), %rcx
movl %eax, 0x5c(%rcx)
movq 0x8(%rbx), %rax
movl $0xe62d00, 0x60(%rax)   # imm = 0xE62D00
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
pushq $0x61
popq %r13
pushq $0x1
popq %r12
testq %r15, %r15
je 0x192d4
movl 0x30(%r15), %eax
cmpl $0x6, %eax
ja 0x192ce
btl %eax, %r13d
jae 0x192ce
cmpl %r14d, 0x18(%r15)
jbe 0x192ce
movq %r15, %rdi
movl %r14d, %esi
movq %rbx, %rdx
movl %r12d, %ecx
callq 0xce23
testl %eax, %eax
je 0x192ce
movl %eax, 0x30(%r15)
movq 0x40(%r15), %r15
jmp 0x1929b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x192f3
movl (%rcx), %edx
movl 0x4(%rcx), %r9d
jmp 0x192f8
xorl %r9d, %r9d
xorl %edx, %edx
pushq %rbp
movq %rsp, %rbp
addq %rsi, %rax
testl %edi, %edi
je 0x1931a
movl %r9d, %ecx
addl %ecx, %edx
addl (%rsi), %edx
addl 0x4(%rsi), %ecx
addq $0x8, %rsi
addl %edx, %ecx
cmpq %rax, %rsi
jb 0x19306
jmp 0x19339
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 0x1931a
movl %edx, (%r8)
movl %ecx, 0x4(%r8)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rcx, -0x38(%rbp)
movq %rdi, %r15
movq 0x8(%rsi), %rax
movq %rax, -0x30(%rbp)
movq (%rdi), %rbx
movl 0x28(%rsi), %eax
leaq 0x60(%rbx), %r13
movl %eax, %ecx
shrl $0x18, %ecx
leaq -0x50(%rbp), %r12
movb %cl, (%r12)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%r12)
movb %ah, -0x4e(%rbp)
movb %al, 0x3(%r12)
movl %edx, %eax
shrl $0x18, %eax
movb %al, 0x4(%r12)
movl %edx, %eax
shrl $0x10, %eax
movb %al, 0x5(%r12)
movb %dh, -0x4a(%rbp)
movb %dl, 0x7(%r12)
movq 0x68(%rbx), %rax
movq %rax, 0x8(%r12)
xorl %r14d, %r14d
cmpb $0x0, 0x55(%rbx)
sete %r14b
pushq $0x8
popq %rdx
movl %r14d, %edi
movq %r12, %rsi
movq %r13, %rcx
movq %r13, %r8
callq 0x192e3
movl 0x38(%rbx), %edx
movl %r14d, %edi
movq -0x30(%rbp), %r14
movq %r14, %rsi
movq %r13, %rcx
movq %r13, %r8
callq 0x192e3
movl 0x60(%rbx), %eax
bswapl %eax
movl %eax, 0x10(%r12)
movl 0x64(%rbx), %eax
movq -0x38(%rbp), %rbx
bswapl %eax
movl %eax, 0x14(%r12)
pushq $0x18
popq %rdx
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rcx
callq 0x1a04b
testl %eax, %eax
jne 0x1942a
movl 0x1c(%r15), %edx
addq $0x18, %rbx
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x1a04b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x6fb10(%rip), %rax     # 0x88f60
testq %rax, %rax
je 0x19457
callq *%rax
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
leaq -0x20(%rbp), %rsi
callq *0x30(%rax)
movl %eax, %r15d
testl %eax, %eax
jne 0x19485
xorl %r15d, %r15d
cmpq %r14, -0x20(%rbp)
jle 0x19485
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x20(%rax)
movl %eax, %r15d
movq 0x6fadc(%rip), %rax     # 0x88f68
testq %rax, %rax
je 0x19493
callq *%rax
testl %r15d, %r15d
je 0x194ad
movq 0x78(%rbx), %rdx
leaq 0x52377(%rip), %rsi     # 0x6b81a
movl %r15d, %edi
xorl %eax, %eax
callq 0xaf99
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walIndexWriteHdr
static void walIndexWriteHdr(Wal *pWal){
  volatile WalIndexHdr *aHdr = walIndexHdr(pWal);
  const int nCksum = offsetof(WalIndexHdr, aCksum);

  assert( pWal->writeLock );
  pWal->hdr.isInit = 1;
  pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
  walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
  memcpy((void *)&aHdr[1], (void *)&pWal->hdr, sizeof(WalIndexHdr));
  walShmBarrier(pWal);
  memcpy((void *)&aHdr[0], (void *)&pWal->hdr, sizeof(WalIndexHdr));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x30(%rdi), %rax
movq (%rax), %r14
leaq 0x48(%rdi), %rsi
movb $0x1, 0x54(%rdi)
movl $0x2de218, 0x48(%rdi)   # imm = 0x2DE218
leaq 0x70(%rdi), %r8
pushq $0x1
popq %rdi
pushq $0x28
popq %rdx
xorl %ecx, %ecx
callq 0x192e3
movups 0x48(%rbx), %xmm0
movups 0x58(%rbx), %xmm1
movups 0x68(%rbx), %xmm2
movups %xmm2, 0x50(%r14)
movups %xmm1, 0x40(%r14)
movups %xmm0, 0x30(%r14)
movq %rbx, %rdi
callq 0x19e3a
movups 0x48(%rbx), %xmm0
movups 0x58(%rbx), %xmm1
movups 0x68(%rbx), %xmm2
movups %xmm2, 0x20(%r14)
movups %xmm1, 0x10(%r14)
movups %xmm0, (%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walLockExclusive
static int walLockExclusive(Wal *pWal, int lockIdx, int n){
  int rc;
  if( pWal->exclusiveMode ) return SQLITE_OK;
  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
                        SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);
  WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal,
            walLockName(lockIdx), n, rc ? "failed" : "ok"));
  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpb $0x0, 0x3f(%rdi)
je 0x1962c
xorl %eax, %eax
popq %rbp
retq
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
movq 0x70(%rax), %rax
movl $0xa, %ecx
popq %rbp
jmpq *%rax
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walUnlockExclusive
static void walUnlockExclusive(Wal *pWal, int lockIdx, int n){
  if( pWal->exclusiveMode ) return;
  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
                         SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE);
  WALTRACE(("WAL%p: release EXCLUSIVE-%s cnt=%d\n", pWal,
             walLockName(lockIdx), n));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpb $0x0, 0x3f(%rdi)
je 0x1964b
popq %rbp
retq
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
movq 0x70(%rax), %rax
movl $0x9, %ecx
popq %rbp
jmpq *%rax
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walUnlockShared
static void walUnlockShared(Wal *pWal, int lockIdx){
  if( pWal->exclusiveMode ) return;
  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,
                         SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);
  WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx)));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpb $0x0, 0x3f(%rdi)
je 0x1966a
popq %rbp
retq
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
movq 0x70(%rax), %rax
movl $0x1, %edx
movl $0x5, %ecx
popq %rbp
jmpq *%rax
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walLockShared
static int walLockShared(Wal *pWal, int lockIdx){
  int rc;
  if( pWal->exclusiveMode ) return SQLITE_OK;
  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,
                        SQLITE_SHM_LOCK | SQLITE_SHM_SHARED);
  WALTRACE(("WAL%p: acquire SHARED-%s %s\n", pWal,
            walLockName(lockIdx), rc ? "failed" : "ok"));
  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpb $0x0, 0x3f(%rdi)
je 0x19e22
xorl %eax, %eax
popq %rbp
retq
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
movq 0x70(%rax), %rax
movl $0x1, %edx
movl $0x6, %ecx
popq %rbp
jmpq *%rax
// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movslq %esi, %r15
cmpl %esi, 0x28(%rdi)
jle 0x19e73
movq 0x30(%r14), %r12
jmp 0x19eb1
leaq 0x1(%r15), %r13
leal (,%r13,8), %esi
movq 0x30(%r14), %rdi
callq 0x9ce9
testq %rax, %rax
je 0x19ee6
movq %rax, %r12
movslq 0x28(%r14), %rax
leaq (%r12,%rax,8), %rdi
movq %r13, %rdx
subq %rax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x81e0
movq %r12, 0x30(%r14)
movl %r13d, 0x28(%r14)
xorl %eax, %eax
cmpq $0x0, (%r12,%r15,8)
jne 0x19f14
cmpb $0x2, 0x3f(%r14)
jne 0x19eed
movl $0x8000, %edi           # imm = 0x8000
callq 0xbeb2
movq 0x30(%r14), %rcx
movq %rax, (%rcx,%r15,8)
movq 0x30(%r14), %rax
xorl %ecx, %ecx
cmpq $0x0, (%rax,%r15,8)
pushq $0x7
popq %rax
cmovnel %ecx, %eax
jmp 0x19f14
pushq $0x7
popq %rax
xorl %ecx, %ecx
jmp 0x19f1c
leaq (%r12,%r15,8), %r8
movq 0x8(%r14), %rdi
movzbl 0x40(%r14), %ecx
movq (%rdi), %rax
movl %r15d, %esi
movl $0x8000, %edx           # imm = 0x8000
callq *0x68(%rax)
cmpl $0x8, %eax
jne 0x19f14
orb $0x2, 0x42(%r14)
xorl %eax, %eax
movq 0x30(%r14), %rcx
movq (%rcx,%r15,8), %rcx
movq %rcx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x1a07c
movslq %r14d, %rcx
addq %rbx, %rcx
cmpq %rax, %rcx
jge 0x1a0a1
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 0x1a0c8
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 0x1a0b9
testl %eax, %eax
jne 0x1a0b9
movslq %r13d, %rax
addq %rax, %rbx
addq %rax, %r15
jmp 0x1a07c
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: walHashGet
static int walHashGet(
  Wal *pWal,                      /* WAL handle */
  int iHash,                      /* Find the iHash'th table */
  volatile ht_slot **paHash,      /* OUT: Pointer to hash index */
  volatile u32 **paPgno,          /* OUT: Pointer to page number array */
  u32 *piZero                     /* OUT: Frame associated with *paPgno[0] */
){
  int rc;                         /* Return code */
  volatile u32 *aPgno;

  rc = walIndexPage(pWal, iHash, &aPgno);
  assert( rc==SQLITE_OK || iHash>0 );

  if( rc==SQLITE_OK ){
    u32 iZero;
    volatile ht_slot *aHash;

    aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];
    if( iHash==0 ){
      aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
      iZero = 0;
    }else{
      iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
    }
  
    *paPgno = &aPgno[-1];
    *paHash = aHash;
    *piZero = iZero;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r14
movl %esi, %r12d
leaq -0x28(%rbp), %rdx
callq 0x19e51
testl %eax, %eax
jne 0x1a146
movq -0x28(%rbp), %rcx
leaq 0x4000(%rcx), %rdx
movl %r12d, %esi
shll $0xc, %esi
addl $-0x22, %esi
leaq 0x88(%rcx), %rdi
testl %r12d, %r12d
cmovneq %rcx, %rdi
cmovel %r12d, %esi
addq $-0x4, %rdi
movq %rdi, (%r15)
movq %rdx, (%r14)
movl %esi, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: journalHdrOffset
static i64 journalHdrOffset(Pager *pPager){
  i64 offset = 0;
  i64 c = pPager->journalOff;
  if( c ){
    offset = ((c-1)/JOURNAL_HDR_SZ(pPager) + 1) * JOURNAL_HDR_SZ(pPager);
  }
  assert( offset%JOURNAL_HDR_SZ(pPager)==0 );
  assert( offset>=c );
  assert( (offset-c)<JOURNAL_HDR_SZ(pPager) );
  return offset;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x60(%rdi), %rax
testq %rax, %rax
je 0x1a25e
decq %rax
movl 0xb8(%rdi), %ecx
cqto
idivq %rcx
incq %rax
imulq %rcx, %rax
jmp 0x1a260
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pager_wait_on_lock
static int pager_wait_on_lock(Pager *pPager, int locktype){
  int rc;                              /* Return code */

  /* Check that this is either a no-op (because the requested lock is 
  ** already held, or one of the transistions that the busy-handler
  ** may be invoked during, according to the comment above
  ** sqlite3PagerSetBusyhandler().
  */
  assert( (pPager->eLock>=locktype)
       || (pPager->eLock==NO_LOCK && locktype==SHARED_LOCK)
       || (pPager->eLock==RESERVED_LOCK && locktype==EXCLUSIVE_LOCK)
  );

  do {
    rc = pagerLockDb(pPager, locktype);
  }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) );
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x1a3e8
movl %eax, %r15d
cmpl $0x5, %eax
jne 0x1a3da
movq 0xe8(%r14), %rdi
callq *0xe0(%r14)
testl %eax, %eax
jne 0x1a3b6
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerLockDb
static int pagerLockDb(Pager *pPager, int eLock){
  int rc = SQLITE_OK;

  assert( eLock==SHARED_LOCK || eLock==RESERVED_LOCK || eLock==EXCLUSIVE_LOCK );
  if( pPager->eLock<eLock || pPager->eLock==UNKNOWN_LOCK ){
    rc = sqlite3OsLock(pPager->fd, eLock);
    if( rc==SQLITE_OK && (pPager->eLock!=UNKNOWN_LOCK||eLock==EXCLUSIVE_LOCK) ){
      pPager->eLock = (u8)eLock;
      IOTRACE(("LOCK %p %d\n", pPager, eLock))
    }
  }
  return rc;
}

// Assembly:
movzbl 0x14(%rdi), %eax
cmpl $0x5, %eax
setne %cl
cmpl %esi, %eax
setge %al
testb %al, %cl
jne 0x1a42c
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movq 0x48(%rdi), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
testl %eax, %eax
jne 0x1a427
cmpl $0x4, %ebx
je 0x1a421
cmpb $0x5, 0x14(%r14)
je 0x1a425
movb %bl, 0x14(%r14)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pcacheUnpin
static void pcacheUnpin(PgHdr *p){
  PCache *pCache = p->pCache;
  if( pCache->bPurgeable ){
    if( p->pgno==1 ){
      pCache->pPage1 = 0;
    }
    sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, p->pPage, 0);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x30(%rdi), %rax
cmpl $0x0, 0x28(%rax)
je 0x1a4b3
cmpl $0x1, 0x28(%rdi)
jne 0x1a49d
andq $0x0, 0x48(%rax)
movq 0x6d044(%rip), %rcx     # 0x874e8
movq 0x40(%rax), %rax
movq (%rdi), %rsi
movq %rax, %rdi
xorl %edx, %edx
popq %rbp
jmpq *%rcx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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:
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 0x1a649
cmpl $0x2, %esi
jne 0x1a672
pushq $0x2a
popq %rdx
pushq $0x28
popq %rsi
xorl %r8d, %r8d
xorl %ecx, %ecx
jmp 0x1a652
pushq $0x2e
popq %rdx
pushq $0x2c
popq %rsi
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 %eax, %eax
retq
pushq %rbp
movq %rsp, %rbp
movl $0xc723, %edi           # imm = 0xC723
callq 0x1a1fc
pushq $0xb
popq %rax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x1a6c4
cmpl $0x3, (%rcx)
jl 0x1a6c4
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)
pushq $0x12
popq %rsi
callq *0x50(%rcx)
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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, 0x6e60b(%rip)     # 0x88cfc
cmpl %edi, 0x6e62d(%rip)     # 0x88d24
jge 0x1a6ff
movl %edi, 0x6e625(%rip)     # 0x88d24
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpl %edi, 0x6e891(%rip)     # 0x88f9c
jl 0x1a762
movq 0x6e8ac(%rip), %rbx     # 0x88fc0
testq %rbx, %rbx
je 0x1a762
movq (%rbx), %rax
movq %rax, 0x6e89d(%rip)     # 0x88fc0
movl 0x6e89f(%rip), %eax     # 0x88fc8
leal -0x1(%rax), %ecx
movl %ecx, 0x6e896(%rip)     # 0x88fc8
xorl %ecx, %ecx
cmpl 0x6e86a(%rip), %eax     # 0x88fa4
setle %cl
movl %ecx, 0x6e889(%rip)     # 0x88fcc
movl 0x6e59b(%rip), %ecx     # 0x88ce4
leal 0x1(%rcx), %eax
movl %eax, 0x6e592(%rip)     # 0x88ce4
cmpl 0x6e5b4(%rip), %ecx     # 0x88d0c
jl 0x1a796
movl %eax, 0x6e5ac(%rip)     # 0x88d0c
jmp 0x1a796
callq 0x9c40
testq %rax, %rax
je 0x1a794
movq %rax, %rbx
movq %rax, %rdi
callq *0x6ccc0(%rip)          # 0x87438
addl 0x6e56a(%rip), %eax     # 0x88ce8
movl %eax, 0x6e564(%rip)     # 0x88ce8
cmpl 0x6e586(%rip), %eax     # 0x88d10
jle 0x1a796
movl %eax, 0x6e57e(%rip)     # 0x88d10
jmp 0x1a796
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BackupRestart
SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *pBackup){
  sqlite3_backup *p;                   /* Iterator variable */
  for(p=pBackup; p; p=p->pNext){
    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );
    p->iNext = 1;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testq %rdi, %rdi
je 0x1a7b6
movl $0x1, 0x18(%rdi)
movq 0x40(%rdi), %rdi
jmp 0x1a7a4
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x1a80e
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movq (%rdi), %r15
testq %r15, %r15
je 0x1a7eb
movq %r15, %rdi
movq 0x38(%r15), %r15
cmpl %r14d, 0x28(%rdi)
jbe 0x1a7d2
callq 0x18da0
jmp 0x1a7d2
testl %r14d, %r14d
jne 0x1a812
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x1a80f
movq 0x8(%rax), %rdi
movslq 0x20(%rbx), %rdx
xorl %esi, %esi
callq 0x81e0
pushq $0x1
popq %r14
jmp 0x1a812
retq
xorl %r14d, %r14d
movq 0x6ccdf(%rip), %rax     # 0x874f8
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_O2/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 0x1a89b
movq %rdi, %rbx
cmpq %rdi, 0x6e764(%rip)     # 0x88fa8
ja 0x1a8a2
cmpq %rbx, 0x6e763(%rip)     # 0x88fb0
jbe 0x1a8a2
movl 0x6e48f(%rip), %eax     # 0x88ce4
decl %eax
movl %eax, 0x6e487(%rip)     # 0x88ce4
cmpl 0x6e4a9(%rip), %eax     # 0x88d0c
jle 0x1a86b
movl %eax, 0x6e4a1(%rip)     # 0x88d0c
movq 0x6e74e(%rip), %rax     # 0x88fc0
movq %rax, (%rbx)
movq %rbx, 0x6e744(%rip)     # 0x88fc0
movl 0x6e746(%rip), %eax     # 0x88fc8
incl %eax
movl %eax, 0x6e73e(%rip)     # 0x88fc8
xorl %ecx, %ecx
cmpl 0x6e712(%rip), %eax     # 0x88fa4
setl %cl
movl %ecx, 0x6e731(%rip)     # 0x88fcc
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq *0x6cb8d(%rip)          # 0x87438
movl 0x6e437(%rip), %ecx     # 0x88ce8
subl %eax, %ecx
movl %ecx, 0x6e42f(%rip)     # 0x88ce8
cmpl 0x6e451(%rip), %ecx     # 0x88d10
jle 0x1a8c7
movl %ecx, 0x6e449(%rip)     # 0x88d10
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x9c7b
// File: /workspace/github_c_makefile_star2_O2/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 0x1ab00
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
pushq $0x2
popq %rsi
callq *0x28(%rax)
testl %eax, %eax
je 0x1aae6
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x1ab6b
cmpl $0x1, %eax
je 0x1ab59
cmpl $0x6, %eax
je 0x1ab6b
movq 0x6e426(%rip), %rax     # 0x88f60
testq %rax, %rax
je 0x1ab41
callq *%rax
movq %rbx, %rdi
callq 0x1b675
movq 0x6e418(%rip), %rax     # 0x88f68
testq %rax, %rax
je 0x1ab6b
callq *%rax
jmp 0x1ab6b
cmpb $0x0, 0x8(%rbx)
jne 0x1ab6b
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1b71b
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1a9ff
// File: /workspace/github_c_makefile_star2_O2/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 0x1b40a
xorl %r14d, %r14d
movslq 0x28(%rbx), %rax
cmpq %rax, %r14
jge 0x1b405
movq 0x30(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x9c7b
movq 0x30(%rbx), %rax
andq $0x0, (%rax,%r14,8)
incq %r14
jmp 0x1b3e1
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_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3WalEndWriteTransaction
SQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal){
  if( pWal->writeLock ){
    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
    pWal->writeLock = 0;
    pWal->truncateOnCommit = 0;
  }
  return SQLITE_OK;
}

// Assembly:
cmpb $0x0, 0x40(%rdi)
je 0x1b497
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
pushq $0x1
popq %rdx
xorl %esi, %esi
callq 0x1963f
movb %r14b, 0x40(%rbx)
movb %r14b, 0x43(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %edx, %eax
movq %r8, -0x38(%rbp)
movl (%r8), %r11d
movq %rcx, -0x30(%rbp)
movq (%rcx), %rcx
xorl %r10d, %r10d
xorl %edx, %edx
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpl %r11d, %r14d
jl 0x1b4ca
cmpl %eax, %r15d
jge 0x1b531
cmpl %eax, %r15d
jge 0x1b4f7
movslq %r15d, %r12
cmpl %r11d, %r14d
jge 0x1b4ee
movzwl (%rsi,%r12,2), %r13d
movl (%rdi,%r13,4), %ebx
movslq %r14d, %r13
movzwl (%rcx,%r13,2), %r8d
cmpl (%rdi,%r8,4), %ebx
jae 0x1b4fa
incl %r15d
leaq (%rsi,%r12,2), %r12
jmp 0x1b501
movslq %r14d, %r13
incl %r14d
leaq (%rcx,%r13,2), %r12
movzwl (%r12), %r8d
movl (%rdi,%r8,4), %r12d
movw %r8w, (%r9,%rdx)
cmpl %eax, %r15d
jge 0x1b528
movslq %r15d, %r8
movzwl (%rsi,%r8,2), %r8d
xorl %ebx, %ebx
cmpl %r12d, (%rdi,%r8,4)
sete %bl
addl %ebx, %r15d
addq $0x2, %rdx
incl %r10d
jmp 0x1b4c0
movq -0x30(%rbp), %rax
movq %rsi, (%rax)
movq -0x38(%rbp), %rax
movl %r10d, (%rax)
andl $-0x2, %edx
movq %rsi, %rdi
movq %r9, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x82c0
// File: /workspace/github_c_makefile_star2_O2/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 0x1b590
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x8(%rdi)
je 0x1b584
pushq $0x2
popq %r14
cmpq $0x40, %r14
je 0x1b584
movq (%rbx,%r14,8), %rdi
callq 0x1b557
incq %r14
jmp 0x1b570
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x9c7b
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x10
popq %r14
xorl %r15d, %r15d
movslq 0x80(%rbx), %rax
cmpq %rax, %r15
jge 0x1b5c7
movq 0x78(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x1b557
incq %r15
addq $0x30, %r14
jmp 0x1b5a5
cmpb $0x0, 0x8(%rbx)
movq 0x58(%rbx), %r14
movq (%r14), %rax
je 0x1b611
leaq 0x6a8c5(%rip), %rcx     # 0x85ea0
cmpq %rcx, %rax
movq %rcx, %rax
jne 0x1b5ed
movq %r14, %rdi
callq *0x8(%rax)
andq $0x0, (%r14)
movq 0x78(%rbx), %rdi
callq 0x9c7b
andq $0x0, 0x78(%rbx)
andl $0x0, 0x80(%rbx)
andl $0x0, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
testq %rax, %rax
jne 0x1b5e3
jmp 0x1b5ed
// File: /workspace/github_c_makefile_star2_O2/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
callq 0x1b46e
movzwl 0x3c(%rbx), %esi
testw %si, %si
js 0x1b63f
addl $0x3, %esi
movq %rbx, %rdi
callq 0x1965e
orw $-0x1, 0x3c(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pagerUnlockDb
static int pagerUnlockDb(Pager *pPager, int eLock){
  int rc = SQLITE_OK;

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
movq 0x48(%rdi), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x1b66e
movl %esi, %ebx
callq *0x40(%rax)
cmpb $0x5, 0x14(%r14)
je 0x1b670
movb %bl, 0x14(%r14)
jmp 0x1b670
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x1b68e
movl 0x2c(%rbx), %eax
jmp 0x1b6f5
xorl %eax, %eax
cmpb $0x2, %r14b
jb 0x1b6f5
cmpq $0x0, 0x118(%rbx)
je 0x1b6c8
pushq $0x2
popq %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x1b942
movl %eax, %r14d
movzbl 0x16(%rbx), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1b71b
testl %r14d, %r14d
cmovnel %r14d, %eax
jmp 0x1b6e2
cmpb $0x2, %r14b
je 0x1b6fa
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x1b6fa
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1bdb6
cmpb $0xd, %al
je 0x1b6ee
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x1b6f5
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 0x1b71b
cmpb $0x2, %r14b
je 0x1b6e2
cmpb $0x0, 0x12(%rbx)
jne 0x1b6e2
movl $0x4, 0x2c(%rbx)
jmp 0x1b6f1