LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3StrAccumReset
SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){
  if( p->zText!=p->zBase ){
    if( p->useMalloc==1 ){
      sqlite3DbFree(p->db, p->zText);
    }else{
      sqlite3_free(p->zText);
    }
  }
  p->zText = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x10(%rdi), %rsi
cmpq 0x8(%rdi), %rsi
je 0x157b7
cmpb $0x1, 0x24(%rbx)
jne 0x157af
movq (%rbx), %rdi
callq 0x968b
jmp 0x157b7
movq %rsi, %rdi
callq 0x9c7b
andq $0x0, 0x10(%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: sqlite3DbRealloc
SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, int n){
  void *pNew = 0;
  assert( db!=0 );
  assert( sqlite3_mutex_held(db->mutex) );
  if( db->mallocFailed==0 ){
    if( p==0 ){
      return sqlite3DbMallocRaw(db, n);
    }
    if( isLookaside(db, p) ){
      if( n<=db->lookaside.sz ){
        return p;
      }
      pNew = sqlite3DbMallocRaw(db, n);
      if( pNew ){
        memcpy(pNew, p, db->lookaside.sz);
        sqlite3DbFree(db, p);
      }
    }else{
      assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );
      assert( sqlite3MemdebugHasType(p, MEMTYPE_LOOKASIDE|MEMTYPE_HEAP) );
      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
      pNew = sqlite3_realloc(p, n);
      if( !pNew ){
        sqlite3MemdebugSetType(p, MEMTYPE_DB|MEMTYPE_HEAP);
        db->mallocFailed = 1;
      }
      sqlite3MemdebugSetType(pNew, MEMTYPE_DB | 
            (db->lookaside.bEnabled ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));
    }
  }
  return pNew;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpb $0x0, 0x50(%rdi)
je 0x157e3
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0x1585d
cmpq %rbx, 0x170(%r14)
ja 0x15841
cmpq %rbx, 0x178(%r14)
jbe 0x15841
movzwl 0x150(%r14), %eax
cmpl %edx, %eax
jge 0x157d5
movq %r14, %rdi
movl %edx, %esi
callq 0x103b4
testq %rax, %rax
je 0x157d3
movq %rax, %r15
movzwl 0x150(%r14), %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x82c0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x968b
movq %r15, %rbx
jmp 0x157d5
movq %rbx, %rdi
movl %edx, %esi
callq 0x9ce9
movq %rax, %rbx
testq %rax, %rax
jne 0x157d5
movb $0x1, 0x50(%r14)
jmp 0x157d3
movq %r14, %rdi
movl %edx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x103b4
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: unixClose
static int unixClose(sqlite3_file *id){
  int rc = SQLITE_OK;
  unixFile *pFile = (unixFile *)id;
  verifyDbFile(pFile);
  unixUnlock(id, NO_LOCK);
  unixEnterMutex();

  /* unixFile.pInode is always valid here. Otherwise, a different close
  ** routine (e.g. nolockClose()) would be called instead.
  */
  assert( pFile->pInode->nLock>0 || pFile->pInode->bProcessLock==0 );
  if( ALWAYS(pFile->pInode) && pFile->pInode->nLock ){
    /* If there are outstanding locks, do not actually close the file just
    ** yet because that would clear those locks.  Instead, add the file
    ** descriptor to pInode->pUnused list.  It will be automatically closed 
    ** when the last lock is cleared.
    */
    setPendingFd(pFile);
  }
  releaseInodeInfo(pFile);
  rc = closeUnixFile(id);
  unixLeaveMutex();
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x169a9
movq %rbx, %rdi
xorl %esi, %esi
callq 0x15eec
movq 0x10(%rbx), %r14
testq %r14, %r14
je 0x158fc
cmpl $0x0, 0x28(%r14)
je 0x158c0
movq 0x30(%rbx), %rax
movq 0x30(%r14), %rcx
movq %rcx, 0x8(%rax)
movq %rax, 0x30(%r14)
orl $-0x1, 0x18(%rbx)
andq $0x0, 0x30(%rbx)
decl 0x18(%r14)
jne 0x158fc
movq %rbx, %rdi
callq 0x16cd1
movq 0x38(%r14), %rax
movq 0x40(%r14), %rcx
leaq 0x38(%rcx), %rdx
testq %rcx, %rcx
leaq 0x7366c(%rip), %rsi     # 0x88f50
cmovneq %rdx, %rsi
movq %rax, (%rsi)
testq %rax, %rax
je 0x158f4
movq %rcx, 0x40(%rax)
movq %r14, %rdi
callq 0x9c7b
movq %rbx, %rdi
callq 0x16a55
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: unixTruncate
static int unixTruncate(sqlite3_file *id, i64 nByte){
  unixFile *pFile = (unixFile *)id;
  int rc;
  assert( pFile );
  SimulateIOError( return SQLITE_IOERR_TRUNCATE );

  /* If the user has configured a chunk-size for this file, truncate the
  ** file so that it consists of an integer number of chunks (i.e. the
  ** actual file size after the operation may be larger than the requested
  ** size).
  */
  if( pFile->szChunk>0 ){
    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;
  }

  rc = robust_ftruncate(pFile->h, (off_t)nByte);
  if( rc ){
    pFile->lastErrno = errno;
    return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
  }else{
#ifdef SQLITE_DEBUG
    /* If we are doing a normal write to a database file (as opposed to
    ** doing a hot-journal rollback or a write to some file other than a
    ** normal database file) and we truncate the file to zero length,
    ** that effectively updates the change counter.  This might happen
    ** when restoring a database using the backup API from a zero-length
    ** source.
    */
    if( pFile->inNormalWrite && nByte==0 ){
      pFile->transCntrChng = 1;
    }
#endif

    /* If the file was just truncated to a size smaller than the currently
    ** mapped region, reduce the effective mapping size as well. SQLite will
    ** use read() and write() to access data beyond this point from now on.  
    */
    if( nByte<pFile->mmapSize ){
      pFile->mmapSize = nByte;
    }

    return SQLITE_OK;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl 0x48(%rdi), %eax
testl %eax, %eax
jle 0x15b4e
movl %eax, %ecx
addq %rcx, %r14
decq %r14
movq %r14, %rax
cqto
idivq %rcx
subq %rdx, %r14
movl 0x18(%rbx), %edi
movq %r14, %rsi
callq 0x16e2d
testl %eax, %eax
je 0x15b89
callq 0x8050
movl (%rax), %eax
movl %eax, 0x20(%rbx)
movq 0x38(%rbx), %rdx
leaq 0x55af1(%rip), %rsi     # 0x6b663
movl $0x60a, %r15d           # imm = 0x60A
movl $0x60a, %edi            # imm = 0x60A
movl $0x680a, %ecx           # imm = 0x680A
callq 0x16c4b
jmp 0x15b96
xorl %r15d, %r15d
cmpq 0x50(%rbx), %r14
jge 0x15b96
movq %r14, 0x50(%rbx)
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: unixSync
static int unixSync(sqlite3_file *id, int flags){
  int rc;
  unixFile *pFile = (unixFile*)id;

  int isDataOnly = (flags&SQLITE_SYNC_DATAONLY);
  int isFullsync = (flags&0x0F)==SQLITE_SYNC_FULL;

  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */
  assert((flags&0x0F)==SQLITE_SYNC_NORMAL
      || (flags&0x0F)==SQLITE_SYNC_FULL
  );

  /* Unix cannot, but some systems may return SQLITE_FULL from here. This
  ** line is to test that doing so does not cause any problems.
  */
  SimulateDiskfullError( return SQLITE_FULL );

  assert( pFile );
  OSTRACE(("SYNC    %-3d\n", pFile->h));
  rc = full_fsync(pFile->h, isFullsync, isDataOnly);
  SimulateIOError( rc=1 );
  if( rc ){
    pFile->lastErrno = errno;
    return unixLogError(SQLITE_IOERR_FSYNC, "full_fsync", pFile->zPath);
  }

  /* Also fsync the directory containing the file if the DIRSYNC flag
  ** is set.  This is a one-time occurrence.  Many systems (examples: AIX)
  ** are unable to fsync a directory, so ignore errors on the fsync.
  */
  if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){
    int dirfd;
    OSTRACE(("DIRSYNC %s (have_fullfsync=%d fullsync=%d)\n", pFile->zPath,
            HAVE_FULLFSYNC, isFullsync));
    rc = osOpenDirectory(pFile->zPath, &dirfd);
    if( rc==SQLITE_OK && dirfd>=0 ){
      full_fsync(dirfd, 0, 0);
      robust_close(pFile, dirfd, __LINE__);
    }else if( rc==SQLITE_CANTOPEN ){
      rc = SQLITE_OK;
    }
    pFile->ctrlFlags &= ~UNIXFILE_DIRSYNC;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl 0x18(%rdi), %edi
callq 0x8300
testl %eax, %eax
je 0x15bea
callq 0x8050
movl (%rax), %eax
movl %eax, 0x20(%rbx)
movq 0x38(%rbx), %rdx
leaq 0x55b50(%rip), %rsi     # 0x6b723
movl $0x40a, %r14d           # imm = 0x40A
movl $0x40a, %edi            # imm = 0x40A
movl $0x67de, %ecx           # imm = 0x67DE
callq 0x16c4b
jmp 0x15c40
xorl %r14d, %r14d
testb $0x8, 0x1e(%rbx)
je 0x15c40
movq 0x38(%rbx), %rdi
leaq -0x14(%rbp), %r14
movq %r14, %rsi
callq *0x71dec(%rip)          # 0x879f0
testl %eax, %eax
sete %cl
movl (%r14), %edi
testl %edi, %edi
setns %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x15c32
callq 0x8300
movl -0x14(%rbp), %esi
movq %rbx, %rdi
movl $0x67ec, %edx           # imm = 0x67EC
callq 0x16d1b
xorl %r14d, %r14d
jmp 0x15c3c
xorl %r14d, %r14d
cmpl $0xe, %eax
cmovnel %eax, %r14d
andb $-0x9, 0x1e(%rbx)
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: unixFileSize
static int unixFileSize(sqlite3_file *id, i64 *pSize){
  int rc;
  struct stat buf;
  assert( id );
  rc = osFstat(((unixFile*)id)->h, &buf);
  SimulateIOError( rc=1 );
  if( rc!=0 ){
    ((unixFile*)id)->lastErrno = errno;
    return SQLITE_IOERR_FSTAT;
  }
  *pSize = buf.st_size;

  /* When opening a zero-size database, the findInodeInfo() procedure
  ** writes a single byte into that file in order to work around a bug
  ** in the OS-X msdos filesystem.  In order to avoid problems with upper
  ** layers, we need to report this file size as zero even though it is
  ** really 1.   Ticket #3260.
  */
  if( *pSize==1 ) *pSize = 0;


  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x18(%rdi), %edi
leaq -0xa0(%rbp), %rsi
callq *0x71c60(%rip)          # 0x878d0
testl %eax, %eax
je 0x15c86
callq 0x8050
movl (%rax), %eax
movl %eax, 0x20(%r14)
movl $0x70a, %eax            # imm = 0x70A
jmp 0x15c9c
movq -0x70(%rbp), %rcx
xorl %eax, %eax
cmpq $0x1, %rcx
movl $0x0, %edx
cmovneq %rcx, %rdx
movq %rdx, (%rbx)
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: unixCheckReservedLock
static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
  int rc = SQLITE_OK;
  int reserved = 0;
  unixFile *pFile = (unixFile*)id;

  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );

  assert( pFile );
  unixEnterMutex(); /* Because pFile->pInode is shared across threads */

  /* Check if a thread in this process holds such a lock */
  if( pFile->pInode->eFileLock>SHARED_LOCK ){
    reserved = 1;
  }

  /* Otherwise see if some other process holds it.
  */
#ifndef __DJGPP__
  if( !reserved && !pFile->pInode->bProcessLock ){
    struct flock lock;
    lock.l_whence = SEEK_SET;
    lock.l_start = RESERVED_BYTE;
    lock.l_len = 1;
    lock.l_type = F_WRLCK;
    if( osFcntl(pFile->h, F_GETLK, &lock) ){
      rc = SQLITE_IOERR_CHECKRESERVEDLOCK;
      pFile->lastErrno = errno;
    } else if( lock.l_type!=F_UNLCK ){
      reserved = 1;
    }
  }
#endif
  
  unixLeaveMutex();
  OSTRACE(("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved));

  *pResOut = reserved;
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq 0x10(%rdi), %rax
cmpb $0x1, 0x14(%rax)
ja 0x160ac
xorl %r15d, %r15d
cmpb $0x0, 0x15(%rax)
movl $0x0, %eax
jne 0x160b2
movq %rdi, %r14
movslq 0x717d4(%rip), %rax     # 0x87840
incq %rax
leaq -0x38(%rbp), %rdx
movq %rax, 0x8(%rdx)
movq $0x1, 0x10(%rdx)
movl $0x1, (%rdx)
movl 0x18(%rdi), %edi
xorl %r15d, %r15d
pushq $0x5
popq %rsi
xorl %eax, %eax
callq *0x7186a(%rip)          # 0x87900
testl %eax, %eax
je 0x160c0
callq 0x8050
movl (%rax), %eax
movl %eax, 0x20(%r14)
movl $0xe0a, %eax            # imm = 0xE0A
jmp 0x160b2
xorl %eax, %eax
pushq $0x1
popq %r15
movl %r15d, (%rbx)
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
cmpw $0x2, -0x38(%rbp)
setne %r15b
xorl %eax, %eax
jmp 0x160b2
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: unixFetch
static int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
#if SQLITE_MAX_MMAP_SIZE>0
  unixFile *pFd = (unixFile *)fd;   /* The underlying database file */
#endif
  *pp = 0;

#if SQLITE_MAX_MMAP_SIZE>0
  if( pFd->mmapSizeMax>0 ){
    if( pFd->pMapRegion==0 ){
      int rc = unixMapfile(pFd, -1);
      if( rc!=SQLITE_OK ) return rc;
    }
    if( pFd->mmapSize >= iOff+nAmt ){
      *pp = &((u8 *)pFd->pMapRegion)[iOff];
      pFd->nFetchOut++;
    }
  }
#endif
  return SQLITE_OK;
}

// Assembly:
andq $0x0, (%rcx)
cmpq $0x0, 0x60(%rdi)
jle 0x16977
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %rbx
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %r14
cmpq $0x0, 0x68(%rdi)
je 0x1697a
movslq %r12d, %rax
addq %r15, %rax
cmpq %rax, 0x50(%r14)
jl 0x16973
addq 0x68(%r14), %r15
movq %r15, (%rbx)
incl 0x4c(%r14)
xorl %eax, %eax
jmp 0x16989
xorl %eax, %eax
retq
pushq $-0x1
popq %rsi
movq %r14, %rdi
callq 0x170d0
testl %eax, %eax
je 0x1695c
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: verifyDbFile
static void verifyDbFile(unixFile *pFile){
  struct stat buf;
  int rc;
  if( pFile->ctrlFlags & UNIXFILE_WARNED ){
    /* One or more of the following warnings have already been issued.  Do not
    ** repeat them so as not to clutter the error log */
    return;
  }
  rc = osFstat(pFile->h, &buf);
  if( rc!=0 ){
    sqlite3_log(SQLITE_WARNING, "cannot fstat db file %s", pFile->zPath);
    pFile->ctrlFlags |= UNIXFILE_WARNED;
    return;
  }
  if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){
    sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath);
    pFile->ctrlFlags |= UNIXFILE_WARNED;
    return;
  }
  if( buf.st_nlink>1 ){
    sqlite3_log(SQLITE_WARNING, "multiple links to file: %s", pFile->zPath);
    pFile->ctrlFlags |= UNIXFILE_WARNED;
    return;
  }
  if( pFile->pInode!=0
   && ((rc = osStat(pFile->zPath, &buf))!=0
       || buf.st_ino!=pFile->pInode->fileId.ino)
  ){
    sqlite3_log(SQLITE_WARNING, "file renamed while open: %s", pFile->zPath);
    pFile->ctrlFlags |= UNIXFILE_WARNED;
    return;
  }
}

// Assembly:
testb $0x1, 0x1f(%rdi)
jne 0x169f4
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movl 0x18(%rdi), %edi
leaq -0x98(%rbp), %rsi
callq *0x70f02(%rip)          # 0x878d0
testl %eax, %eax
je 0x169f5
leaq 0x54bff(%rip), %rsi     # 0x6b5d8
movq 0x38(%rbx), %rdx
pushq $0x1c
popq %rdi
xorl %eax, %eax
callq 0xaf99
orb $0x1, 0x1f(%rbx)
addq $0x98, %rsp
popq %rbx
popq %rbp
retq
movq -0x88(%rbp), %rax
cmpq $0x1, %rax
je 0x16a16
testq %rax, %rax
jne 0x16a4c
testb $0x20, 0x1e(%rbx)
jne 0x16a16
leaq 0x54bdc(%rip), %rsi     # 0x6b5f0
jmp 0x169d9
cmpq $0x0, 0x10(%rbx)
je 0x169eb
movq 0x38(%rbx), %rdi
leaq -0x98(%rbp), %rsi
callq *0x70e8a(%rip)          # 0x878b8
leaq 0x54bf3(%rip), %rsi     # 0x6b628
testl %eax, %eax
jne 0x169d9
movq -0x90(%rbp), %rax
movq 0x10(%rbx), %rcx
cmpq 0x8(%rcx), %rax
jne 0x169d9
jmp 0x169eb
leaq 0x54bba(%rip), %rsi     # 0x6b60d
jmp 0x169d9
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: closeUnixFile
static int closeUnixFile(sqlite3_file *id){
  unixFile *pFile = (unixFile*)id;
  unixUnmapfile(pFile);
  if( pFile->h>=0 ){
    robust_close(pFile, pFile->h, __LINE__);
    pFile->h = -1;
  }
#if OS_VXWORKS
  if( pFile->pId ){
    if( pFile->ctrlFlags & UNIXFILE_DELETE ){
      osUnlink(pFile->pId->zCanonicalName);
    }
    vxworksReleaseFileId(pFile->pId);
    pFile->pId = 0;
  }
#endif
  OSTRACE(("CLOSE   %-3d\n", pFile->h));
  OpenCounter(-1);
  sqlite3_free(pFile->pUnused);
  memset(pFile, 0, sizeof(unixFile));
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x16d5c
movl 0x18(%rbx), %esi
testl %esi, %esi
js 0x16a7b
movq %rbx, %rdi
movl $0x6173, %edx           # imm = 0x6173
callq 0x16d1b
orl $-0x1, 0x18(%rbx)
movq 0x30(%rbx), %rdi
callq 0x9c7b
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rbx)
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%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: openDirectory
static int openDirectory(const char *zFilename, int *pFd){
  int ii;
  int fd = -1;
  char zDirname[MAX_PATHNAME+1];

  sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename);
  for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--);
  if( ii>0 ){
    zDirname[ii] = '\0';
    fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);
    if( fd>=0 ){
      OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname));
    }
  }
  *pFd = fd;
  return (fd>=0?SQLITE_OK:unixLogError(SQLITE_CANTOPEN_BKPT, "open", zDirname));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x210, %rsp            # imm = 0x210
movq %rsi, %rbx
movq %rdi, %rcx
leaq 0x54c29(%rip), %rdx     # 0x6b6f9
leaq -0x220(%rbp), %r14
movl $0x200, %edi            # imm = 0x200
movq %r14, %rsi
xorl %eax, %eax
callq 0xaf26
movq %r14, %rdi
callq 0x8170
movl %eax, %ecx
cmpl $0x2, %ecx
jl 0x16b05
movl %ecx, %edx
cmpb $0x2f, -0x220(%rbp,%rdx)
je 0x16b0c
decl %ecx
jmp 0x16af0
testl %eax, %eax
jle 0x16b2f
pushq $0x1
popq %rdx
movb $0x0, -0x220(%rbp,%rdx)
leaq -0x220(%rbp), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
xorl %edx, %edx
callq 0x16ba9
movl %eax, (%rbx)
testl %eax, %eax
jns 0x16b5b
jmp 0x16b32
orl $-0x1, (%rbx)
movl $0x67b5, %edi           # imm = 0x67B5
callq 0x16cb0
leaq 0x54b01(%rip), %rsi     # 0x6b644
pushq $0xe
popq %r14
leaq -0x220(%rbp), %rdx
movl %r14d, %edi
movl $0x67b5, %ecx           # imm = 0x67B5
callq 0x16c4b
movl %r14d, %eax
addq $0x210, %rsp            # imm = 0x210
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: robust_open
static int robust_open(const char *z, int f, mode_t m){
  int fd;
  mode_t m2 = m ? m : SQLITE_DEFAULT_FILE_PERMISSIONS;
  do{
#if defined(O_CLOEXEC)
    fd = osOpen(z,f|O_CLOEXEC,m2);
#else
    fd = osOpen(z,f,m2);
#endif
  }while( fd<0 && errno==EINTR );
  if( fd>=0 ){
    if( m!=0 ){
      struct stat statbuf;
      if( osFstat(fd, &statbuf)==0 
       && statbuf.st_size==0
       && (statbuf.st_mode&0777)!=m 
      ){
        osFchmod(fd, m);
      }
    }
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
    osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
#endif
  }
  return fd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %r12
testl %edx, %edx
movl $0x1a4, %r13d           # imm = 0x1A4
cmovnel %edx, %r13d
orl $0x80000, %r15d         # imm = 0x80000
movq %r12, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq *0x70c71(%rip)          # 0x87858
movl %eax, %r14d
testl %eax, %eax
jns 0x16bfa
callq 0x8050
cmpl $0x4, (%rax)
je 0x16bd8
jmp 0x16c36
testl %ebx, %ebx
je 0x16c36
leaq -0xb8(%rbp), %rsi
movl %r14d, %edi
callq *0x70cc2(%rip)          # 0x878d0
testl %eax, %eax
jne 0x16c36
cmpq $0x0, -0x88(%rbp)
jne 0x16c36
movl $0x1ff, %eax            # imm = 0x1FF
andl -0xa0(%rbp), %eax
cmpl %ebx, %eax
je 0x16c36
movl %r14d, %edi
movl %ebx, %esi
callq *0x70d72(%rip)          # 0x879a8
movl %r14d, %eax
addq $0x98, %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: closePendingFds
static void closePendingFds(unixFile *pFile){
  unixInodeInfo *pInode = pFile->pInode;
  UnixUnusedFd *p;
  UnixUnusedFd *pNext;
  for(p=pInode->pUnused; p; p=pNext){
    pNext = p->pNext;
    robust_close(pFile, p->fd, __LINE__);
    sqlite3_free(p);
  }
  pInode->pUnused = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %r15
movq 0x30(%r15), %r14
testq %r14, %r14
je 0x16d0d
movq 0x8(%r14), %r12
movl (%r14), %esi
movq %rbx, %rdi
movl $0x5ea1, %edx           # imm = 0x5EA1
callq 0x16d1b
movq %r14, %rdi
callq 0x9c7b
movq %r12, %r14
jmp 0x16ce7
andq $0x0, 0x30(%r15)
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: unixUnmapfile
static void unixUnmapfile(unixFile *pFd){
  assert( pFd->nFetchOut==0 );
#if SQLITE_MAX_MMAP_SIZE>0
  if( pFd->pMapRegion ){
    osMunmap(pFd->pMapRegion, pFd->mmapSizeActual);
    pFd->pMapRegion = 0;
    pFd->mmapSize = 0;
    pFd->mmapSizeActual = 0;
  }
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x68(%rdi), %rdi
testq %rdi, %rdi
je 0x16d84
movq 0x58(%rbx), %rsi
callq *0x70cf0(%rip)          # 0x87a68
andq $0x0, 0x68(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%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: seekAndWriteFd
static int seekAndWriteFd(
  int fd,                         /* File descriptor to write to */
  i64 iOff,                       /* File offset to begin writing at */
  const void *pBuf,               /* Copy data from this buffer to the file */
  int nBuf,                       /* Size of buffer pBuf in bytes */
  int *piErrno                    /* OUT: Error number if error occurs */
){
  int rc = 0;                     /* Value returned by system call */

  assert( nBuf==(nBuf&0x1ffff) );
  nBuf &= 0x1ffff;
  TIMER_START;

#if defined(USE_PREAD)
  do{ rc = osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );
#elif defined(USE_PREAD64)
  do{ rc = osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
#else
  do{
    i64 iSeek = lseek(fd, iOff, SEEK_SET);
    SimulateIOError( iSeek-- );

    if( iSeek!=iOff ){
      if( piErrno ) *piErrno = (iSeek==-1 ? errno : 0);
      return -1;
    }
    rc = osWrite(fd, pBuf, nBuf);
  }while( rc<0 && errno==EINTR );
#endif

  TIMER_END;
  OSTRACE(("WRITE   %-3d %5d %7lld %llu\n", fd, rc, iOff, TIMER_ELAPSED));

  if( rc<0 && piErrno ) *piErrno = errno;
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, -0x30(%rbp)
movl %ecx, %r15d
movq %rdx, %r12
movq %rsi, %r13
movl %edi, %ebx
andl $0x1ffff, %r15d         # imm = 0x1FFFF
movl %ebx, %edi
movq %r13, %rsi
xorl %edx, %edx
callq 0x82f0
cmpq %r13, %rax
jne 0x16dfd
movl %ebx, %edi
movq %r12, %rsi
movq %r15, %rdx
callq *0x70b82(%rip)          # 0x87960
movq %rax, %r14
testl %r14d, %r14d
jns 0x16e1b
callq 0x8050
movl (%rax), %ecx
cmpl $0x4, %ecx
je 0x16dbf
movq -0x30(%rbp), %rbx
testq %rbx, %rbx
jne 0x16e19
jmp 0x16e1b
movq -0x30(%rbp), %rbx
pushq $-0x1
popq %r14
testq %rbx, %rbx
je 0x16e1b
xorl %ecx, %ecx
cmpq $-0x1, %rax
jne 0x16e19
callq 0x8050
movl (%rax), %ecx
movl %ecx, (%rbx)
movl %r14d, %eax
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: unixFileLock
static int unixFileLock(unixFile *pFile, struct flock *pLock){
  int rc;
  unixInodeInfo *pInode = pFile->pInode;
  assert( unixMutexHeld() );
  assert( pInode!=0 );
  if( ((pFile->ctrlFlags & UNIXFILE_EXCL)!=0 || pInode->bProcessLock)
   && ((pFile->ctrlFlags & UNIXFILE_RDONLY)==0)
  ){
    if( pInode->bProcessLock==0 ){
      struct flock lock;
      assert( pInode->nLock==0 );
      lock.l_whence = SEEK_SET;
      lock.l_start = SHARED_FIRST;
      lock.l_len = SHARED_SIZE;
      lock.l_type = F_WRLCK;
      rc = osFcntl(pFile->h, F_SETLK, &lock);
      if( rc<0 ) return rc;
      pInode->bProcessLock = 1;
      pInode->nLock++;
    }else{
      rc = 0;
    }
  }else{
    rc = osFcntl(pFile->h, F_SETLK, pLock);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rdx
movq 0x10(%rdi), %rbx
movzwl 0x1e(%rdi), %eax
testb $0x1, %al
jne 0x16e8c
testb $0x2, %al
jne 0x16e9f
cmpb $0x0, 0x15(%rbx)
jne 0x16e96
jmp 0x16e9f
testb $0x2, %al
jne 0x16e9f
cmpb $0x0, 0x15(%rbx)
je 0x16eb6
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
movq 0x70a5a(%rip), %rcx     # 0x87900
movl 0x18(%rdi), %edi
pushq $0x6
popq %rsi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %rbp
jmpq *%rcx
movslq 0x70983(%rip), %rax     # 0x87840
addq $0x2, %rax
leaq -0x28(%rbp), %rdx
movq %rax, 0x8(%rdx)
movq $0x1fe, 0x10(%rdx)      # imm = 0x1FE
movl $0x1, (%rdx)
movl 0x18(%rdi), %edi
pushq $0x6
popq %rsi
xorl %eax, %eax
callq *0x70a1b(%rip)          # 0x87900
testl %eax, %eax
js 0x16e98
movb $0x1, 0x15(%rbx)
incl 0x28(%rbx)
jmp 0x16e98
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: unixModeBit
static void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){
  if( *pArg<0 ){
    *pArg = (pFile->ctrlFlags & mask)!=0;
  }else if( (*pArg)==0 ){
    pFile->ctrlFlags &= ~mask;
  }else{
    pFile->ctrlFlags |= mask;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpl $0x0, (%rdx)
js 0x16f42
je 0x16f53
movzbl %sil, %eax
orw %ax, 0x1e(%rdi)
jmp 0x16f5e
movzbl %sil, %eax
xorl %ecx, %ecx
testw %ax, 0x1e(%rdi)
setne %cl
movl %ecx, (%rdx)
jmp 0x16f5e
notb %sil
movsbl %sil, %eax
andw %ax, 0x1e(%rdi)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: unixMapfile
static int unixMapfile(unixFile *pFd, i64 nByte){
#if SQLITE_MAX_MMAP_SIZE>0
  i64 nMap = nByte;
  int rc;

  assert( nMap>=0 || pFd->nFetchOut==0 );
  if( pFd->nFetchOut>0 ) return SQLITE_OK;

  if( nMap<0 ){
    struct stat statbuf;          /* Low-level file information */
    rc = osFstat(pFd->h, &statbuf);
    if( rc!=SQLITE_OK ){
      return SQLITE_IOERR_FSTAT;
    }
    nMap = statbuf.st_size;
  }
  if( nMap>pFd->mmapSizeMax ){
    nMap = pFd->mmapSizeMax;
  }

  if( nMap!=pFd->mmapSize ){
    if( nMap>0 ){
      unixRemapfile(pFd, nMap);
    }else{
      unixUnmapfile(pFd);
    }
  }
#endif

  return SQLITE_OK;
}

// Assembly:
cmpl $0x0, 0x4c(%rdi)
jle 0x170d9
xorl %eax, %eax
retq
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
testq %rsi, %rsi
js 0x1719b
movq 0x50(%rbx), %r12
movq 0x60(%rbx), %r14
cmpq %r14, %rsi
cmovlq %rsi, %r14
cmpq %r12, %r14
je 0x17229
testq %r14, %r14
jle 0x171c2
movl 0x18(%rbx), %r8d
movq 0x68(%rbx), %r15
xorl %eax, %eax
testb $0x2, 0x1e(%rbx)
sete %cl
testq %r15, %r15
je 0x171cc
movb %cl, -0x29(%rbp)
movl %r8d, -0x30(%rbp)
movq 0x58(%rbx), %rsi
andq $-0x200, %r12           # imm = 0xFE00
subq %r12, %rsi
je 0x17155
leaq (%r15,%r12), %rdi
callq *0x70913(%rip)          # 0x87a68
pushq $0x1
popq %rcx
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq *0x70917(%rip)          # 0x87a80
movq %rax, %r13
incq %rax
cmpq $0x1, %rax
ja 0x171f2
movq %r15, %rdi
movq %r12, %rsi
callq *0x708e7(%rip)          # 0x87a68
leaq 0x5454e(%rip), %r12     # 0x6b6d6
testq %r13, %r13
movl -0x30(%rbp), %r8d
movl $0x0, %eax
movb -0x29(%rbp), %cl
jne 0x171f9
jmp 0x171d3
movl 0x18(%rbx), %edi
leaq -0xc0(%rbp), %rsi
callq *0x70725(%rip)          # 0x878d0
movl %eax, %ecx
movl $0x70a, %eax            # imm = 0x70A
testl %ecx, %ecx
jne 0x1722b
movq -0x90(%rbp), %rsi
jmp 0x170f9
movq %rbx, %rdi
callq 0x16d5c
jmp 0x17229
leaq 0x544f7(%rip), %r12     # 0x6b6ca
movb %cl, %al
leal 0x1(,%rax,2), %edx
pushq $0x1
popq %rcx
xorl %edi, %edi
movq %r14, %rsi
xorl %r9d, %r9d
callq *0x70863(%rip)          # 0x87a50
movq %rax, %r13
jmp 0x171f9
leaq 0x544dd(%rip), %r12     # 0x6b6d6
cmpq $-0x1, %r13
jne 0x1721d
movq 0x38(%rbx), %rdx
xorl %r13d, %r13d
xorl %edi, %edi
movq %r12, %rsi
movl $0x6c6c, %ecx           # imm = 0x6C6C
callq 0x16c4b
andq $0x0, 0x60(%rbx)
xorl %r14d, %r14d
movq %r13, 0x68(%rbx)
movq %r14, 0x58(%rbx)
movq %r14, 0x50(%rbx)
xorl %eax, %eax
addq $0x98, %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: unixShmPurge
static void unixShmPurge(unixFile *pFd){
  unixShmNode *p = pFd->pInode->pShmNode;
  assert( unixMutexHeld() );
  if( p && p->nRef==0 ){
    int i;
    assert( p->pInode==pFd->pInode );
    sqlite3_mutex_free(p->mutex);
    for(i=0; i<p->nRegion; i++){
      if( p->h>=0 ){
        osMunmap(p->apRegion[i], p->szRegion);
      }else{
        sqlite3_free(p->apRegion[i]);
      }
    }
    sqlite3_free(p->apRegion);
    if( p->h>=0 ){
      robust_close(pFd, p->h, __LINE__);
      p->h = -1;
    }
    p->pInode->pShmNode = 0;
    sqlite3_free(p);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x10(%rdi), %rax
movq 0x20(%rax), %rbx
testq %rbx, %rbx
je 0x172aa
cmpl $0x0, 0x30(%rbx)
je 0x172b5
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %r14
xorl %r15d, %r15d
movzwl 0x20(%rbx), %eax
cmpq %rax, %r15
jae 0x172f0
cmpl $0x0, 0x18(%rbx)
js 0x172de
movq 0x28(%rbx), %rax
movq (%rax,%r15,8), %rdi
movslq 0x1c(%rbx), %rsi
callq *0x7078c(%rip)          # 0x87a68
jmp 0x172eb
movq 0x28(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x9c7b
incq %r15
jmp 0x172bb
movq 0x28(%rbx), %rdi
callq 0x9c7b
movl 0x18(%rbx), %esi
testl %esi, %esi
js 0x17311
movq %r14, %rdi
movl $0x6a18, %edx           # imm = 0x6A18
callq 0x16d1b
orl $-0x1, 0x18(%rbx)
movq (%rbx), %rax
andq $0x0, 0x20(%rax)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x9c7b
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: dotlockClose
static int dotlockClose(sqlite3_file *id) {
  int rc = SQLITE_OK;
  if( id ){
    unixFile *pFile = (unixFile*)id;
    dotlockUnlock(id, NO_LOCK);
    sqlite3_free(pFile->lockingContext);
    rc = closeUnixFile(id);
  }
  return rc;
}

// Assembly:
testq %rdi, %rdi
je 0x1737f
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %esi, %esi
callq 0x173f8
movq 0x28(%rbx), %rdi
callq 0x9c7b
movq %rbx, %rdi
callq 0x16a55
addq $0x8, %rsp
popq %rbx
popq %rbp
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: dotlockLock
static int dotlockLock(sqlite3_file *id, int eFileLock) {
  unixFile *pFile = (unixFile*)id;
  char *zLockFile = (char *)pFile->lockingContext;
  int rc = SQLITE_OK;


  /* If we have any lock, then the lock file already exists.  All we have
  ** to do is adjust our internal record of the lock level.
  */
  if( pFile->eFileLock > NO_LOCK ){
    pFile->eFileLock = eFileLock;
    /* Always update the timestamp on the old file */
#ifdef HAVE_UTIME
    utime(zLockFile, NULL);
#else
    utimes(zLockFile, NULL);
#endif
    return SQLITE_OK;
  }
  
  /* grab an exclusive lock */
  rc = osMkdir(zLockFile, 0777);
  if( rc<0 ){
    /* failed to open/create the lock directory */
    int tErrno = errno;
    if( EEXIST == tErrno ){
      rc = SQLITE_BUSY;
    } else {
      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
      if( IS_LOCK_ERROR(rc) ){
        pFile->lastErrno = tErrno;
      }
    }
    return rc;
  } 
  
  /* got it, set the type and return ok */
  pFile->eFileLock = eFileLock;
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
cmpb $0x0, 0x1c(%rbx)
je 0x173ac
movb %r15b, 0x1c(%rbx)
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x8250
jmp 0x173ea
movl $0x1ff, %esi            # imm = 0x1FF
callq *0x70651(%rip)          # 0x87a08
testl %eax, %eax
js 0x173c4
movl %eax, %r14d
movb %r15b, 0x1c(%rbx)
jmp 0x173ea
callq 0x8050
movl (%rax), %r15d
pushq $0x5
popq %r14
cmpl $0x11, %r15d
je 0x173ea
movl %r15d, %edi
callq 0x16ef2
cmpl $0x5, %eax
je 0x173ea
movl %r15d, 0x20(%rbx)
movl %eax, %r14d
movl %r14d, %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: dotlockUnlock
static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
  unixFile *pFile = (unixFile*)id;
  char *zLockFile = (char *)pFile->lockingContext;
  int rc;

  assert( pFile );
  OSTRACE(("UNLOCK  %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock,
           pFile->eFileLock, getpid()));
  assert( eFileLock<=SHARED_LOCK );
  
  /* no-op if possible */
  if( pFile->eFileLock==eFileLock ){
    return SQLITE_OK;
  }

  /* To downgrade to shared, simply update our internal notion of the
  ** lock state.  No need to mess with the file on disk.
  */
  if( eFileLock==SHARED_LOCK ){
    pFile->eFileLock = SHARED_LOCK;
    return SQLITE_OK;
  }
  
  /* To fully unlock the database, delete the lock file */
  assert( eFileLock==NO_LOCK );
  rc = osRmdir(zLockFile);
  if( rc<0 && errno==ENOTDIR ) rc = osUnlink(zLockFile);
  if( rc<0 ){
    int tErrno = errno;
    rc = 0;
    if( ENOENT != tErrno ){
      rc = SQLITE_IOERR_UNLOCK;
    }
    if( IS_LOCK_ERROR(rc) ){
      pFile->lastErrno = tErrno;
    }
    return rc; 
  }
  pFile->eFileLock = NO_LOCK;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movzbl 0x1c(%rdi), %eax
xorl %ebx, %ebx
cmpl %esi, %eax
je 0x17432
movq %rdi, %r14
cmpl $0x1, %esi
jne 0x1741c
movb $0x1, 0x1c(%r14)
jmp 0x17432
movq 0x28(%r14), %r15
movq %r15, %rdi
callq *0x705f7(%rip)          # 0x87a20
testl %eax, %eax
js 0x1743d
movb $0x0, 0x1c(%r14)
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x8050
movq %rax, %r12
movl (%rax), %eax
cmpl $0x14, %eax
jne 0x1745d
movq %r15, %rdi
callq *0x70583(%rip)          # 0x879d8
testl %eax, %eax
jns 0x1742d
movl (%r12), %eax
cmpl $0x2, %eax
je 0x17432
movl %eax, 0x20(%r14)
movl $0x80a, %ebx            # imm = 0x80A
jmp 0x17432
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: dotlockCheckReservedLock
static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {
  int rc = SQLITE_OK;
  int reserved = 0;
  unixFile *pFile = (unixFile*)id;

  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
  
  assert( pFile );

  /* Check if a thread in this process holds such a lock */
  if( pFile->eFileLock>SHARED_LOCK ){
    /* Either this connection or some other connection in the same process
    ** holds a lock on the file.  No need to check further. */
    reserved = 1;
  }else{
    /* The lock is held if and only if the lockfile exists */
    const char *zLockFile = (const char*)pFile->lockingContext;
    reserved = osAccess(zLockFile, 0)==0;
  }
  OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved));
  *pResOut = reserved;
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
cmpb $0x1, 0x1c(%rdi)
jbe 0x17481
pushq $0x1
popq %rcx
jmp 0x17494
movq 0x28(%rdi), %rdi
xorl %esi, %esi
callq *0x703fb(%rip)          # 0x87888
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, (%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VMPrintf
SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
  char *z;
  char zBase[SQLITE_PRINT_BUF_SIZE];
  StrAccum acc;
  assert( db!=0 );
  sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),
                      db->aLimit[SQLITE_LIMIT_LENGTH]);
  acc.db = db;
  sqlite3VXPrintf(&acc, 1, zFormat, ap);
  z = sqlite3StrAccumFinish(&acc);
  if( acc.accError==STRACCUM_NOMEM ){
    db->mallocFailed = 1;
  }
  return z;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x70, %rsp
movq %rdx, %rcx
movq %rsi, %rdx
movq %rdi, %rbx
movl 0x68(%rdi), %eax
leaq -0x80(%rbp), %rsi
leaq -0x38(%rbp), %r14
movq %rsi, 0x8(%r14)
movq %rsi, 0x10(%r14)
movabsq $0x4600000000, %rsi     # imm = 0x4600000000
movq %rsi, 0x18(%r14)
movl %eax, 0x20(%r14)
movw $0x1, 0x24(%r14)
movq %rdi, (%r14)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x9ed1
movq %r14, %rdi
callq 0xadc3
cmpb $0x1, 0x25(%r14)
jne 0x1751a
movb $0x1, 0x50(%rbx)
addq $0x70, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3OpenTempDatabase
SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *pParse){
  sqlite3 *db = pParse->db;
  if( db->aDb[1].pBt==0 && !pParse->explain ){
    int rc;
    Btree *pBt;
    static const int flags = 
          SQLITE_OPEN_READWRITE |
          SQLITE_OPEN_CREATE |
          SQLITE_OPEN_EXCLUSIVE |
          SQLITE_OPEN_DELETEONCLOSE |
          SQLITE_OPEN_TEMP_DB;

    rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pBt, 0, flags);
    if( rc!=SQLITE_OK ){
      sqlite3ErrorMsg(pParse, "unable to open a temporary database "
        "file for storing temporary tables");
      pParse->rc = rc;
      return 1;
    }
    db->aDb[1].pBt = pBt;
    assert( db->aDb[1].pSchema );
    if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
      db->mallocFailed = 1;
      return 1;
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq (%rdi), %rbx
movq 0x20(%rbx), %rax
xorl %r15d, %r15d
cmpq $0x0, 0x28(%rax)
jne 0x175ab
movq %rdi, %r14
cmpb $0x0, 0x200(%rdi)
jne 0x175ab
movq (%rbx), %rdi
leaq -0x20(%rbp), %rcx
xorl %esi, %esi
movq %rbx, %rdx
xorl %r8d, %r8d
movl $0x21e, %r9d            # imm = 0x21E
callq 0x175b9
testl %eax, %eax
je 0x17582
movl %eax, %r15d
leaq 0x54234(%rip), %rsi     # 0x6b7a6
movq %r14, %rdi
xorl %eax, %eax
callq 0x104d6
movl %r15d, 0x18(%r14)
jmp 0x175a7
movq -0x20(%rbp), %rdi
movq 0x20(%rbx), %rax
movq %rdi, 0x28(%rax)
movl 0x58(%rbx), %esi
pushq $-0x1
popq %rdx
xorl %r15d, %r15d
xorl %ecx, %ecx
callq 0x14f93
cmpl $0x7, %eax
jne 0x175ab
movb $0x1, 0x50(%rbx)
pushq $0x1
popq %r15
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: btreeInvokeBusyHandler
static int btreeInvokeBusyHandler(void *pArg){
  BtShared *pBt = (BtShared*)pArg;
  assert( pBt->db );
  assert( sqlite3_mutex_held(pBt->db->mutex) );
  return sqlite3InvokeBusyHandler(&pBt->db->busyHandler);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq 0x8(%rdi), %rbx
movq 0x2a8(%rbx), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x1809c
movl 0x2b8(%rbx), %esi
testl %esi, %esi
js 0x1809c
movq 0x2b0(%rbx), %rdi
callq *%rcx
testl %eax, %eax
je 0x18093
movl 0x2b8(%rbx), %ecx
incl %ecx
jmp 0x18096
pushq $-0x1
popq %rcx
movl %ecx, 0x2b8(%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: setSectorSize
static void setSectorSize(Pager *pPager){
  assert( isOpen(pPager->fd) || pPager->tempFile );

  if( pPager->tempFile
   || (sqlite3OsDeviceCharacteristics(pPager->fd) & 
              SQLITE_IOCAP_POWERSAFE_OVERWRITE)!=0
  ){
    /* Sector size doesn't matter for temporary files. Also, the file
    ** may not have been opened yet, in which case the OsSectorSize()
    ** call will segfault. */
    pPager->sectorSize = 512;
  }else{
    pPager->sectorSize = sqlite3SectorSize(pPager->fd);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl $0x200, %r14d           # imm = 0x200
cmpb $0x0, 0x10(%rdi)
jne 0x18360
movq 0x48(%rbx), %rdi
movq (%rdi), %rax
callq *0x60(%rax)
btl $0xc, %eax
jb 0x18360
movq 0x48(%rbx), %rdi
callq 0x18445
movl %eax, %r14d
movl %r14d, 0xb8(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3SectorSize
SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *pFile){
  int iRet = sqlite3OsSectorSize(pFile);
  if( iRet<32 ){
    iRet = 512;
  }else if( iRet>MAX_SECTOR_SIZE ){
    assert( MAX_SECTOR_SIZE>=512 );
    iRet = MAX_SECTOR_SIZE;
  }
  return iRet;
}

// Assembly:
movq (%rdi), %rax
movq 0x58(%rax), %rax
testq %rax, %rax
je 0x1846e
pushq %rbp
movq %rsp, %rbp
callq *%rax
movl $0x10000, %ecx          # imm = 0x10000
cmpl %ecx, %eax
cmovbl %eax, %ecx
cmpl $0x20, %eax
movl $0x200, %eax            # imm = 0x200
cmovgel %ecx, %eax
popq %rbp
retq
movl $0x1000, %eax           # imm = 0x1000
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: subjRequiresPage
static int subjRequiresPage(PgHdr *pPg){
  Pager *pPager = pPg->pPager;
  PagerSavepoint *p;
  Pgno pgno;
  int i;
  if( pPager->nSavepoint ){
    pgno = pPg->pgno;
    for(i=0; i<pPager->nSavepoint; i++){
      p = &pPager->aSavepoint[i];
      if( p->nOrig>=pgno && 0==sqlite3BitvecTest(p->pInSavepoint, pgno) ){
        return 1;
      }
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x20(%rdi), %r15
movl 0x80(%r15), %eax
xorl %ebx, %ebx
testl %eax, %eax
je 0x184cf
testl %eax, %eax
cmovlel %ebx, %eax
movl 0x28(%rdi), %r14d
imulq $0x30, %rax, %r12
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x184cf
movq 0x78(%r15), %rax
cmpl %r14d, 0x18(%rax,%r13)
jb 0x184c4
movq 0x10(%rax,%r13), %rdi
movl %r14d, %esi
callq 0x18dd4
testl %eax, %eax
je 0x184ca
addq $0x30, %r13
jmp 0x184a3
pushq $0x1
popq %rax
movl %eax, %ebx
movl %ebx, %eax
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: subjournalPage
static int subjournalPage(PgHdr *pPg){
  int rc = SQLITE_OK;
  Pager *pPager = pPg->pPager;
  if( pPager->journalMode!=PAGER_JOURNALMODE_OFF ){

    /* Open the sub-journal, if it has not already been opened */
    assert( pPager->useJournal );
    assert( isOpen(pPager->jfd) || pagerUseWal(pPager) );
    assert( isOpen(pPager->sjfd) || pPager->nSubRec==0 );
    assert( pagerUseWal(pPager) 
         || pageInJournal(pPg) 
         || pPg->pgno>pPager->dbOrigSize 
    );
    rc = openSubJournal(pPager);

    /* If the sub-journal was opened successfully (or was already open),
    ** write the journal record into the file.  */
    if( rc==SQLITE_OK ){
      void *pData = pPg->pData;
      i64 offset = (i64)pPager->nSubRec*(4+pPager->pageSize);
      char *pData2;
  
      CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM, pData2);
      PAGERTRACE(("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno));
      rc = write32bits(pPager->sjfd, offset, pPg->pgno);
      if( rc==SQLITE_OK ){
        rc = sqlite3OsWrite(pPager->sjfd, pData2, pPager->pageSize, offset+4);
      }
    }
  }
  if( rc==SQLITE_OK ){
    pPager->nSubRec++;
    assert( pPager->nSavepoint>0 );
    rc = addToSavepointBitvecs(pPager, pPg->pgno);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r14
movq 0x20(%rdi), %rbx
movb 0x9(%rbx), %al
cmpb $0x2, %al
jne 0x18510
incl 0x38(%rbx)
movl 0x28(%r14), %esi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x18e7d
movq 0x58(%rbx), %rdx
cmpq $0x0, (%rdx)
jne 0x1853e
cmpb $0x4, %al
je 0x18524
cmpb $0x0, 0x18(%rbx)
je 0x18593
xorps %xmm0, %xmm0
andq $0x0, 0x28(%rdx)
movups %xmm0, 0x18(%rdx)
movups %xmm0, 0x8(%rdx)
leaq 0x6d965(%rip), %rax     # 0x85ea0
movq %rax, (%rdx)
movq 0x8(%r14), %r15
movl 0x38(%rbx), %eax
movslq 0xbc(%rbx), %r12
addq $0x4, %r12
imulq %rax, %r12
movq 0x58(%rbx), %rdi
movl 0x28(%r14), %edx
movq %r12, %rsi
callq 0x18e5b
testl %eax, %eax
jne 0x1858a
movq 0x58(%rbx), %rdi
movl 0xbc(%rbx), %edx
addq $0x4, %r12
movq (%rdi), %rax
movq %r15, %rsi
movq %r12, %rcx
callq *0x18(%rax)
testl %eax, %eax
je 0x184f9
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rdi
xorl %esi, %esi
movl $0x201e, %ecx           # imm = 0x201E
xorl %r8d, %r8d
callq *0x28(%rdi)
testl %eax, %eax
jne 0x1858a
jmp 0x1853e
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PcacheMakeClean
SQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr *p){
  if( (p->flags & PGHDR_DIRTY) ){
    pcacheRemoveFromDirtyList(p);
    p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC);
    if( p->nRef==0 ){
      pcacheUnpin(p);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
testb $0x2, 0x2c(%rdi)
je 0x18dbf
movq %rdi, %rbx
callq 0x1a42f
andb $-0x7, 0x2c(%rbx)
cmpw $0x0, 0x2e(%rbx)
je 0x18dc6
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1a484
// File: /workspace/github_c_makefile_star2_O2/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 %ecx, %ecx
testq %rdi, %rdi
je 0x18e58
movl %esi, %edx
decl %edx
cmpl (%rdi), %edx
jae 0x18e58
pushq %rbp
movq %rsp, %rbp
movl 0x8(%rdi), %ecx
testl %ecx, %ecx
je 0x18e02
movl %edx, %eax
xorl %edx, %edx
divl %ecx
xorl %ecx, %ecx
movq 0x10(%rdi,%rax,8), %rdi
testq %rdi, %rdi
jne 0x18de7
jmp 0x18e57
cmpl $0xf80, (%rdi)          # imm = 0xF80
ja 0x18e21
movl %edx, %eax
shrl $0x3, %eax
movzbl 0x10(%rdi,%rax), %eax
andl $0x7, %edx
xorl %ecx, %ecx
btl %edx, %eax
setb %cl
jmp 0x18e57
movl %edx, %esi
incl %esi
xorl %ecx, %ecx
movl $0x7c, %r8d
movl %edx, %eax
xorl %edx, %edx
divl %r8d
movl $0x1, %eax
movl %edx, %r8d
movl 0x10(%rdi,%r8,4), %r8d
testl %r8d, %r8d
je 0x18e57
cmpl %esi, %r8d
je 0x18e55
incl %edx
cmpl $0x7c, %edx
cmovel %ecx, %edx
jmp 0x18e39
movl %eax, %ecx
popq %rbp
movl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/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 %esi, %ebx
movq %rdi, %r14
xorl %r12d, %r12d
pushq $0x18
popq %r13
xorl %r15d, %r15d
movslq 0x80(%r14), %rax
cmpq %rax, %r12
jge 0x18ec8
movq 0x78(%r14), %rax
cmpl %ebx, (%rax,%r13)
jb 0x18ebf
movq -0x8(%rax,%r13), %rdi
movl %ebx, %esi
callq 0x190c4
orl %eax, %r15d
incq %r12
addq $0x30, %r13
jmp 0x18e9a
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq