LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3AddInt64
SQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){
  i64 iA = *pA;
  testcase( iA==0 ); testcase( iA==1 );
  testcase( iB==-1 ); testcase( iB==0 );
  if( iB>=0 ){
    testcase( iA>0 && LARGEST_INT64 - iA == iB );
    testcase( iA>0 && LARGEST_INT64 - iA == iB - 1 );
    if( iA>0 && LARGEST_INT64 - iA < iB ) return 1;
    *pA += iB;
  }else{
    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 1 );
    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 2 );
    if( iA<0 && -(iA + LARGEST_INT64) > iB + 1 ) return 1;
    *pA += iB;
  }
  return 0; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
testq %rsi, %rsi
js 0x299be
testq %rax, %rax
setg %cl
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
subq %rax, %rdx
cmpq %rsi, %rdx
setb %dl
testb %dl, %cl
je 0x299dd
movl $0x1, %eax
jmp 0x299e5
testq %rax, %rax
jns 0x299dd
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
subq %rax, %rcx
addq $0x2, %rcx
leaq 0x1(%rsi), %rdx
cmpq %rdx, %rcx
jg 0x299b7
addq %rsi, %rax
movq %rax, (%rdi)
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeMemIntegerify
SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
  assert( (pMem->flags & MEM_RowSet)==0 );
  assert( EIGHT_BYTE_ALIGNMENT(pMem) );

  pMem->u.i = sqlite3VdbeIntValue(pMem);
  MemSetTypeFlag(pMem, MEM_Int);
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0xdfe0
movq %rax, 0x18(%rbx)
movl $0xffffbe00, %eax       # imm = 0xFFFFBE00
andl 0x24(%rbx), %eax
orl $0x4, %eax
movw %ax, 0x24(%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: applyAffinity
static void applyAffinity(
  Mem *pRec,          /* The value to apply affinity to */
  char affinity,      /* The affinity to be applied */
  u8 enc              /* Use this text encoding */
){
  if( affinity==SQLITE_AFF_TEXT ){
    /* Only attempt the conversion to TEXT if there is an integer or real
    ** representation (blob and NULL do not get converted) but no string
    ** representation.
    */
    if( 0==(pRec->flags&MEM_Str) && (pRec->flags&(MEM_Real|MEM_Int)) ){
      sqlite3VdbeMemStringify(pRec, enc);
    }
    pRec->flags &= ~(MEM_Real|MEM_Int);
  }else if( affinity!=SQLITE_AFF_NONE ){
    assert( affinity==SQLITE_AFF_INTEGER || affinity==SQLITE_AFF_REAL
             || affinity==SQLITE_AFF_NUMERIC );
    applyNumericAffinity(pRec);
    if( pRec->flags & MEM_Real ){
      sqlite3VdbeIntegerAffinity(pRec);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpl $0x62, %esi
je 0x29ab3
movq %rdi, %rbx
cmpl $0x61, %esi
jne 0x29aa5
movzwl 0x24(%rbx), %eax
movl %eax, %ecx
andl $0x2, %ecx
shrl %ecx
testb $0xc, %al
sete %sil
orb %cl, %sil
jne 0x29a9a
movzbl %dl, %esi
movq %rbx, %rdi
callq 0x21a5a
movzwl 0x24(%rbx), %eax
andl $0xfff3, %eax           # imm = 0xFFF3
movw %ax, 0x24(%rbx)
jmp 0x29ab3
movq %rbx, %rdi
callq 0xfd9d
testb $0x8, 0x24(%rbx)
jne 0x29aba
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x299e7
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeMemRealify
SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
  assert( EIGHT_BYTE_ALIGNMENT(pMem) );

  pMem->r = sqlite3VdbeRealValue(pMem);
  MemSetTypeFlag(pMem, MEM_Real);
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0xdf89
movsd %xmm0, 0x10(%rbx)
movl $0xffffbe00, %eax       # imm = 0xFFFFBE00
andl 0x24(%rbx), %eax
orl $0x8, %eax
movw %ax, 0x24(%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: sqlite3VdbeMemNumerify
SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){
  if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){
    assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
    if( 0==sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc) ){
      MemSetTypeFlag(pMem, MEM_Int);
    }else{
      pMem->r = sqlite3VdbeRealValue(pMem);
      MemSetTypeFlag(pMem, MEM_Real);
      sqlite3VdbeIntegerAffinity(pMem);
    }
  }
  assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 );
  pMem->flags &= ~(MEM_Str|MEM_Blob);
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzwl 0x24(%rdi), %eax
testb $0xd, %al
jne 0x29b4f
movq 0x8(%rbx), %rdi
leaq 0x18(%rbx), %rsi
movl 0x20(%rbx), %edx
movzbl 0x27(%rbx), %ecx
callq 0x15296
testl %eax, %eax
je 0x29b44
movq %rbx, %rdi
callq 0xdf89
movsd %xmm0, 0x10(%rbx)
movl $0xffffbe00, %eax       # imm = 0xFFFFBE00
andl 0x24(%rbx), %eax
orl $0x8, %eax
movw %ax, 0x24(%rbx)
movq %rbx, %rdi
callq 0x299e7
movzwl 0x24(%rbx), %eax
jmp 0x29b4f
movl $0xffffbe00, %eax       # imm = 0xFFFFBE00
andl 0x24(%rbx), %eax
orl $0x4, %eax
andl $0xffed, %eax           # imm = 0xFFED
movw %ax, 0x24(%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: sqlite3VdbeCursorMoveto
SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor *p){
  if( p->deferredMoveto ){
    int res, rc;
#ifdef SQLITE_TEST
    extern int sqlite3_search_count;
#endif
    assert( p->isTable );
    rc = sqlite3BtreeMovetoUnpacked(p->pCursor, 0, p->movetoTarget, 0, &res);
    if( rc ) return rc;
    p->lastRowid = p->movetoTarget;
    if( res!=0 ) return SQLITE_CORRUPT_BKPT;
    p->rowidIsValid = 1;
#ifdef SQLITE_TEST
    sqlite3_search_count++;
#endif
    p->deferredMoveto = 0;
    p->cacheStatus = CACHE_STALE;
  }else if( ALWAYS(p->pCursor) ){
    int hasMoved;
    int rc = sqlite3BtreeCursorHasMoved(p->pCursor, &hasMoved);
    if( rc ) return rc;
    if( hasMoved ){
      p->cacheStatus = CACHE_STALE;
      p->nullRow = 1;
    }
  }
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpb $0x0, 0x29(%rdi)
je 0x29d85
movq (%rbx), %rdi
movq 0x48(%rbx), %rdx
leaq -0x14(%rbp), %r8
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2a60b
testl %eax, %eax
jne 0x29dc8
movq 0x48(%rbx), %rax
movq %rax, 0x50(%rbx)
cmpl $0x0, -0x14(%rbp)
je 0x29dba
movl $0xf465, %edi           # imm = 0xF465
callq 0x1a1fc
pushq $0xb
popq %rax
jmp 0x29dc8
movq (%rbx), %r14
testq %r14, %r14
je 0x29dc6
movb 0x77(%r14), %al
cmpb $0x3, %al
jb 0x29da5
movq %r14, %rdi
callq 0x2b99e
testl %eax, %eax
jne 0x29dc8
movb 0x77(%r14), %al
cmpb $0x1, %al
jne 0x29db0
cmpl $0x0, 0x70(%r14)
je 0x29dc6
andl $0x0, 0x64(%rbx)
movb $0x1, 0x28(%rbx)
jmp 0x29dc6
movb $0x1, 0x25(%rbx)
movb $0x0, 0x29(%rbx)
andl $0x0, 0x64(%rbx)
xorl %eax, %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: sqlite3BtreeDataSize
SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
  assert( cursorHoldsMutex(pCur) );
  assert( pCur->eState==CURSOR_VALID );
  getCellInfo(pCur);
  *pSize = pCur->info.nData;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
cmpw $0x0, 0x5e(%rdi)
jne 0x29e06
leaq 0x40(%r14), %rdx
movswq 0x7a(%r14), %rax
movq 0xa8(%r14,%rax,8), %rdi
movzwl 0x7c(%r14,%rax,2), %esi
callq 0x1e40e
movb $0x1, 0x76(%r14)
movl 0x50(%r14), %eax
movl %eax, (%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BtreeKeyFetch
SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor *pCur, int *pAmt){
  const void *p = 0;
  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
  assert( cursorHoldsMutex(pCur) );
  if( ALWAYS(pCur->eState==CURSOR_VALID) ){
    p = (const void*)fetchPayload(pCur, pAmt, 0);
  }
  return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpb $0x1, 0x77(%rdi)
jne 0x29e23
xorl %edx, %edx
popq %rbp
jmp 0x2baab
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BtreeDataFetch
SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor *pCur, int *pAmt){
  const void *p = 0;
  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
  assert( cursorHoldsMutex(pCur) );
  if( ALWAYS(pCur->eState==CURSOR_VALID) ){
    p = (const void*)fetchPayload(pCur, pAmt, 1);
  }
  return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpb $0x1, 0x77(%rdi)
jne 0x29e3c
movl $0x1, %edx
popq %rbp
jmp 0x2baab
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeMemFromBtree
SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(
  BtCursor *pCur,   /* Cursor pointing at record to retrieve. */
  int offset,       /* Offset from the start of data to return bytes from. */
  int amt,          /* Number of bytes to return. */
  int key,          /* If true, retrieve from the btree key, not data. */
  Mem *pMem         /* OUT: Return data in this Mem structure. */
){
  char *zData;        /* Data from the btree layer */
  int available = 0;  /* Number of bytes available on the local btree page */
  int rc = SQLITE_OK; /* Return code */

  assert( sqlite3BtreeCursorIsValid(pCur) );

  /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() 
  ** that both the BtShared and database handle mutexes are held. */
  assert( (pMem->flags & MEM_RowSet)==0 );
  if( key ){
    zData = (char *)sqlite3BtreeKeyFetch(pCur, &available);
  }else{
    zData = (char *)sqlite3BtreeDataFetch(pCur, &available);
  }
  assert( zData!=0 );

  if( offset+amt<=available && (pMem->flags&MEM_Dyn)==0 ){
    sqlite3VdbeMemRelease(pMem);
    pMem->z = &zData[offset];
    pMem->flags = MEM_Blob|MEM_Ephem;
  }else if( SQLITE_OK==(rc = sqlite3VdbeMemGrow(pMem, amt+2, 0)) ){
    pMem->flags = MEM_Blob|MEM_Dyn|MEM_Term;
    pMem->enc = 0;
    pMem->type = SQLITE_BLOB;
    if( key ){
      rc = sqlite3BtreeKey(pCur, offset, amt, pMem->z);
    }else{
      rc = sqlite3BtreeData(pCur, offset, amt, pMem->z);
    }
    pMem->z[amt] = 0;
    pMem->z[amt+1] = 0;
    if( rc!=SQLITE_OK ){
      sqlite3VdbeMemRelease(pMem);
    }
  }
  pMem->n = amt;

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movl %ecx, %r13d
movl %edx, %r14d
movl %esi, %r15d
andl $0x0, -0x2c(%rbp)
testl %ecx, %ecx
movq %rdi, -0x38(%rbp)
leaq -0x2c(%rbp), %rsi
je 0x29e74
callq 0x29e11
jmp 0x29e79
callq 0x29e27
movq %rax, %r12
leal (%r14,%r15), %eax
cmpl -0x2c(%rbp), %eax
jg 0x29ea7
testb $0x4, 0x25(%rbx)
jne 0x29ea7
movq %rbx, %rdi
callq 0xde44
movslq %r15d, %rax
addq %rax, %r12
movq %r12, 0x8(%rbx)
movw $0x1010, 0x24(%rbx)     # imm = 0x1010
xorl %eax, %eax
jmp 0x29f10
leal 0x2(%r14), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf2c6
testl %eax, %eax
jne 0x29f10
movl $0x40610, 0x24(%rbx)    # imm = 0x40610
movq 0x8(%rbx), %rcx
testl %r13d, %r13d
je 0x29eda
movq -0x38(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x1e401
jmp 0x29ee9
movq -0x38(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x10eee
movl %eax, %r15d
movq 0x8(%rbx), %rcx
movslq %r14d, %rdx
xorl %eax, %eax
movb %al, (%rcx,%rdx)
movq 0x8(%rbx), %rcx
movb %al, 0x1(%rcx,%rdx)
testl %r15d, %r15d
je 0x29f10
movq %rbx, %rdi
callq 0xde44
movl %r15d, %eax
movl %r14d, 0x20(%rbx)
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: sqlite3VdbeSerialType
SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format){
  int flags = pMem->flags;
  int n;

  if( flags&MEM_Null ){
    return 0;
  }
  if( flags&MEM_Int ){
    /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */
#   define MAX_6BYTE ((((i64)0x00008000)<<32)-1)
    i64 i = pMem->u.i;
    u64 u;
    if( i<0 ){
      if( i<(-MAX_6BYTE) ) return 6;
      /* Previous test prevents:  u = -(-9223372036854775808) */
      u = -i;
    }else{
      u = i;
    }
    if( u<=127 ){
      return ((i&1)==i && file_format>=4) ? 8+(u32)u : 1;
    }
    if( u<=32767 ) return 2;
    if( u<=8388607 ) return 3;
    if( u<=2147483647 ) return 4;
    if( u<=MAX_6BYTE ) return 5;
    return 6;
  }
  if( flags&MEM_Real ){
    return 7;
  }
  assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) );
  n = pMem->n;
  if( flags & MEM_Zero ){
    n += pMem->u.nZero;
  }
  assert( n>=0 );
  return ((n*2) + 12 + ((flags&MEM_Str)!=0));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movzwl 0x24(%rdi), %ecx
xorl %eax, %eax
testb $0x1, %cl
jne 0x2a13c
testb $0x4, %cl
jne 0x2a0b5
testb $0x8, %cl
jne 0x2a0fa
movl 0x20(%rdi), %eax
btl $0xe, %ecx
jae 0x2a0a5
addl 0x18(%rdi), %eax
shrl %ecx
andl $0x1, %ecx
leal (%rcx,%rax,2), %eax
addl $0xc, %eax
jmp 0x2a13c
movq 0x18(%rdi), %rdx
movl $0x6, %eax
movq %rdx, %rcx
testq %rdx, %rdx
jns 0x2a0db
movabsq $-0x7fffffffffff, %rcx  # imm = 0xFFFF800000000001
cmpq %rcx, %rdx
jb 0x2a13c
movq %rdx, %rcx
negq %rcx
cmpq $0x7f, %rcx
ja 0x2a101
addl $0x8, %ecx
cmpq $0x2, %rdx
movl $0x1, %eax
cmovael %eax, %ecx
cmpl $0x4, %esi
cmovll %eax, %ecx
movl %ecx, %eax
jmp 0x2a13c
movl $0x7, %eax
jmp 0x2a13c
cmpq $0x8000, %rcx           # imm = 0x8000
jae 0x2a111
movl $0x2, %eax
jmp 0x2a13c
cmpq $0x800000, %rcx         # imm = 0x800000
jae 0x2a121
movl $0x3, %eax
jmp 0x2a13c
movq %rcx, %rdx
shrq $0x1f, %rdx
jne 0x2a131
movl $0x4, %eax
jmp 0x2a13c
shrq $0x2f, %rcx
cmpq $0x1, %rcx
sbbl $0x0, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VarintLen
SQLITE_PRIVATE int sqlite3VarintLen(u64 v){
  int i = 0;
  do{
    i++;
    v >>= 7;
  }while( v!=0 && ALWAYS(i<9) );
  return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %ecx, %ecx
leal 0x1(%rcx), %eax
cmpq $0x80, %rdi
jb 0x2a15b
shrq $0x7, %rdi
cmpl $0x8, %ecx
movl %eax, %ecx
jb 0x2a144
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PutVarint32
SQLITE_PRIVATE int sqlite3PutVarint32(unsigned char *p, u32 v){
#ifndef putVarint32
  if( (v & ~0x7f)==0 ){
    p[0] = v;
    return 1;
  }
#endif
  if( (v & ~0x3fff)==0 ){
    p[0] = (u8)((v>>7) | 0x80);
    p[1] = (u8)(v & 0x7f);
    return 2;
  }
  return sqlite3PutVarint(p, v);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpl $0x3fff, %esi           # imm = 0x3FFF
ja 0x2a181
movl %esi, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, (%rdi)
andb $0x7f, %sil
movb %sil, 0x1(%rdi)
movl $0x2, %eax
popq %rbp
retq
movl %esi, %esi
popq %rbp
jmp 0x2bb2a
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3ResetOneSchema
SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3 *db, int iDb){
  Db *pDb;
  assert( iDb<db->nDb );

  /* Case 1:  Reset the single schema identified by iDb */
  pDb = &db->aDb[iDb];
  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
  assert( pDb->pSchema!=0 );
  sqlite3SchemaClear(pDb->pSchema);

  /* If any database other than TEMP is reset, then also reset TEMP
  ** since TEMP might be holding triggers that reference tables in the
  ** other database.
  */
  if( iDb!=1 ){
    pDb = &db->aDb[1];
    assert( pDb->pSchema!=0 );
    sqlite3SchemaClear(pDb->pSchema);
  }
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rax
movslq %esi, %r14
movq %r14, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %rdi
callq 0x2bdcf
cmpl $0x1, %r14d
jne 0x2a1b6
popq %rbx
popq %r14
popq %rbp
retq
movq 0x20(%rbx), %rax
movq 0x38(%rax), %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x2bdcf
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BtreeCursor
SQLITE_PRIVATE int sqlite3BtreeCursor(
  Btree *p,                                   /* The btree */
  int iTable,                                 /* Root page of table to open */
  int wrFlag,                                 /* 1 to write. 0 read-only */
  struct KeyInfo *pKeyInfo,                   /* First arg to xCompare() */
  BtCursor *pCur                              /* Write new cursor here */
){
  int rc;
  sqlite3BtreeEnter(p);
  rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
  sqlite3BtreeLeave(p);
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %r9
movq 0x8(%rdi), %rax
movq %r9, 0x8(%rax)
testl %edx, %edx
je 0x2a2e9
testb $0x1, 0x26(%rax)
jne 0x2a334
cmpl $0x1, %esi
jne 0x2a2f8
xorl %esi, %esi
cmpl $0x0, 0x3c(%rax)
setne %sil
movl %esi, 0x30(%r8)
orw $-0x1, 0x7a(%r8)
movq %rcx, 0x20(%r8)
movq %rdi, (%r8)
movq %rax, 0x8(%r8)
movb %dl, 0x74(%r8)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%r8)
testq %rcx, %rcx
je 0x2a322
movq %r8, 0x18(%rcx)
movq %r8, 0x10(%rax)
movb $0x0, 0x77(%r8)
andq $0x0, 0x38(%r8)
xorl %eax, %eax
jmp 0x2a339
movl $0x8, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BtreeFirst
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){
  int rc;

  assert( cursorHoldsMutex(pCur) );
  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
  rc = moveToRoot(pCur);
  if( rc==SQLITE_OK ){
    if( pCur->eState==CURSOR_INVALID ){
      assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->nCell==0 );
      *pRes = 1;
    }else{
      assert( pCur->apPage[pCur->iPage]->nCell>0 );
      *pRes = 0;
      rc = moveToLeftmost(pCur);
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x2bba7
testl %eax, %eax
je 0x2a59c
popq %rbx
popq %r14
popq %rbp
retq
cmpb $0x0, 0x77(%r14)
je 0x2a5b2
andl $0x0, (%rbx)
movq %r14, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x2bee1
movl $0x1, (%rbx)
xorl %eax, %eax
jmp 0x2a597
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeAllocUnpackedRecord
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(
  KeyInfo *pKeyInfo,              /* Description of the record */
  char *pSpace,                   /* Unaligned space available */
  int szSpace,                    /* Size of pSpace[] in bytes */
  char **ppFree                   /* OUT: Caller should free this pointer */
){
  UnpackedRecord *p;              /* Unpacked record to return */
  int nOff;                       /* Increment pSpace by nOff to align it */
  int nByte;                      /* Number of bytes required for *p */

  /* We want to shift the pointer pSpace up such that it is 8-byte aligned.
  ** Thus, we need to calculate a value, nOff, between 0 and 7, to shift 
  ** it by.  If pSpace is already 8-byte aligned, nOff should be zero.
  */
  nOff = (8 - (SQLITE_PTR_TO_INT(pSpace) & 7)) & 7;
  nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nField+1);
  if( nByte>szSpace+nOff ){
    p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);
    *ppFree = (char *)p;
    if( !p ) return 0;
  }else{
    p = (UnpackedRecord*)&pSpace[nOff];
    *ppFree = 0;
  }

  p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];
  assert( pKeyInfo->aSortOrder!=0 );
  p->pKeyInfo = pKeyInfo;
  p->nField = pKeyInfo->nField + 1;
  return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rcx, %r14
movq %rsi, %rax
movq %rdi, %rbx
movl %eax, %edi
negl %edi
andl $0x7, %edi
movzwl 0xa(%rbx), %ecx
imull $0x38, %ecx, %esi
addl $0x58, %esi
addl %edi, %edx
cmpl %edx, %esi
jle 0x2abb3
movq (%rbx), %rdi
callq 0x103b4
movq %rax, (%r14)
testq %rax, %rax
je 0x2abd2
movzwl 0xa(%rbx), %ecx
jmp 0x2abbc
movl %edi, %edx
addq %rdx, %rax
andq $0x0, (%r14)
leaq 0x20(%rax), %rdx
movq %rdx, 0x18(%rax)
movq %rbx, (%rax)
incl %ecx
movw %cx, 0x8(%rax)
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
jmp 0x2abcd
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeRecordUnpack
SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(
  KeyInfo *pKeyInfo,     /* Information about the record format */
  int nKey,              /* Size of the binary record */
  const void *pKey,      /* The binary record */
  UnpackedRecord *p      /* Populate this structure before returning. */
){
  const unsigned char *aKey = (const unsigned char *)pKey;
  int d; 
  u32 idx;                        /* Offset in aKey[] to read from */
  u16 u;                          /* Unsigned loop counter */
  u32 szHdr;
  Mem *pMem = p->aMem;

  p->flags = 0;
  assert( EIGHT_BYTE_ALIGNMENT(pMem) );
  idx = getVarint32(aKey, szHdr);
  d = szHdr;
  u = 0;
  while( idx<szHdr && u<p->nField && d<=nKey ){
    u32 serial_type;

    idx += getVarint32(&aKey[idx], serial_type);
    pMem->enc = pKeyInfo->enc;
    pMem->db = pKeyInfo->db;
    /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
    pMem->zMalloc = 0;
    d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
    pMem++;
    u++;
  }
  assert( u<=pKeyInfo->nField + 1 );
  p->nField = u;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, -0x34(%rbp)
movq %rdi, -0x48(%rbp)
movq 0x18(%rcx), %r13
movq %rcx, -0x40(%rbp)
movb $0x0, 0xa(%rcx)
movsbl (%rdx), %r14d
testl %r14d, %r14d
movq %rdx, -0x30(%rbp)
js 0x2ac0c
pushq $0x1
popq %rbx
jmp 0x2ac25
leaq -0x4c(%rbp), %r14
movq %rdx, %rdi
movq %r14, %rsi
callq 0x1e561
movq -0x30(%rbp), %rdx
movzbl %al, %ebx
movl (%r14), %r14d
xorl %r15d, %r15d
movl %r14d, %r12d
cmpl %r14d, %ebx
jae 0x2ac9d
movq -0x40(%rbp), %rax
cmpw 0x8(%rax), %r15w
jae 0x2ac9d
cmpl -0x34(%rbp), %r12d
jg 0x2ac9d
movl %ebx, %edi
movsbl (%rdx,%rdi), %esi
testl %esi, %esi
js 0x2ac50
pushq $0x1
popq %rax
jmp 0x2ac66
addq %rdx, %rdi
leaq -0x38(%rbp), %rsi
callq 0x1e561
movq -0x30(%rbp), %rdx
movzbl %al, %eax
movl -0x38(%rbp), %esi
movq -0x48(%rbp), %rdi
movb 0x8(%rdi), %cl
movb %cl, 0x27(%r13)
movq (%rdi), %rcx
movq %rcx, (%r13)
andq $0x0, 0x30(%r13)
addl %eax, %ebx
movslq %r12d, %rdi
addq %rdx, %rdi
movq %r13, %rdx
callq 0x29f23
movq -0x30(%rbp), %rdx
addl %eax, %r12d
addq $0x38, %r13
incl %r15d
jmp 0x2ac2b
movq -0x40(%rbp), %rax
movw %r15w, 0x8(%rax)
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: sqlite3VdbeSorterNext
SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){
  VdbeSorter *pSorter = pCsr->pSorter;
  int rc;                         /* Return code */

  if( pSorter->aTree ){
    int iPrev = pSorter->aTree[1];/* Index of iterator to advance */
    int i;                        /* Index of aTree[] to recalculate */

    rc = vdbeSorterIterNext(db, &pSorter->aIter[iPrev]);
    for(i=(pSorter->nTree+iPrev)/2; rc==SQLITE_OK && i>0; i=i/2){
      rc = vdbeSorterDoCompare(pCsr, i);
    }

    *pbEof = (pSorter->aIter[pSorter->aTree[1]].pFile==0);
  }else{
    SorterRecord *pFree = pSorter->pRecord;
    pSorter->pRecord = pFree->pNext;
    pFree->pNext = 0;
    vdbeSorterRecordFree(db, pFree);
    *pbEof = !pSorter->pRecord;
    rc = SQLITE_OK;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq 0x58(%rsi), %r12
movq 0x30(%r12), %rax
testq %rax, %rax
je 0x2b477
movq %rsi, %r14
movslq 0x4(%rax), %r15
movq %r15, %rsi
shlq $0x6, %rsi
addq 0x28(%r12), %rsi
callq 0x2e916
movl %eax, %ecx
movl 0x14(%r12), %eax
addl %r15d, %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
movl %eax, %r15d
testl %ecx, %ecx
jne 0x2b45b
testl %r15d, %r15d
jle 0x2b45b
movq %r14, %rdi
movl %r15d, %esi
callq 0x2e7b8
shrl %r15d
xorl %ecx, %ecx
jmp 0x2b440
movq 0x28(%r12), %rax
movq 0x30(%r12), %rdx
movslq 0x4(%rdx), %rdx
shlq $0x6, %rdx
leaq (%rax,%rdx), %r14
addq $0x18, %r14
jmp 0x2b496
leaq 0x40(%r12), %r14
movq 0x40(%r12), %rsi
movq 0x10(%rsi), %rax
movq %rax, 0x40(%r12)
andq $0x0, 0x10(%rsi)
callq 0x20cb0
xorl %ecx, %ecx
xorl %eax, %eax
cmpq $0x0, (%r14)
sete %al
movl %eax, (%rbx)
movl %ecx, %eax
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: sqlite3BtreeClearTable
SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
  int rc;
  BtShared *pBt = p->pBt;
  sqlite3BtreeEnter(p);
  assert( p->inTrans==TRANS_WRITE );

  rc = saveAllCursors(pBt, (Pgno)iTable, 0);

  if( SQLITE_OK==rc ){
    /* Invalidate all incrblob cursors open on table iTable (assuming iTable
    ** is the root of a table b-tree - if it is not, the following call is
    ** a no-op).  */
    invalidateIncrblobCursors(p, 0, 1);
    rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
  }
  sqlite3BtreeLeave(p);
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r12
movq (%rdi), %rax
movq 0x8(%rdi), %r15
movq %rax, 0x8(%r15)
movq %r15, %rdi
xorl %edx, %edx
callq 0x1e0b8
testl %eax, %eax
je 0x2b4e2
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2c171
movq %r15, %rdi
movl %r14d, %esi
xorl %edx, %edx
movq %rbx, %rcx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2eaf7
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3AnalysisLoad
SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
  analysisInfo sInfo;
  HashElem *i;
  char *zSql;
  int rc;

  assert( iDb>=0 && iDb<db->nDb );
  assert( db->aDb[iDb].pBt!=0 );

  /* Clear any prior statistics */
  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
  for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
    Index *pIdx = sqliteHashData(i);
    sqlite3DefaultRowEst(pIdx);
#ifdef SQLITE_ENABLE_STAT3
    sqlite3DeleteIndexSamples(db, pIdx);
    pIdx->aSample = 0;
#endif
  }

  /* Check to make sure the sqlite_stat1 table exists */
  sInfo.db = db;
  sInfo.zDatabase = db->aDb[iDb].zName;
  if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)==0 ){
    return SQLITE_ERROR;
  }

  /* Load new statistics out of the sqlite_stat1 table */
  zSql = sqlite3MPrintf(db, 
      "SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase);
  if( zSql==0 ){
    rc = SQLITE_NOMEM;
  }else{
    rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
    sqlite3DbFree(db, zSql);
  }


  /* Load the statistics from the sqlite_stat3 table. */
#ifdef SQLITE_ENABLE_STAT3
  if( rc==SQLITE_OK ){
    int lookasideEnabled = db->lookaside.bEnabled;
    db->lookaside.bEnabled = 0;
    rc = loadStat3(db, sInfo.zDatabase);
    db->lookaside.bEnabled = lookasideEnabled;
  }
#endif

  if( rc==SQLITE_NOMEM ){
    db->mallocFailed = 1;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x20(%rdi), %rax
movslq %esi, %r14
shlq $0x5, %r14
movq 0x18(%rax,%r14), %r15
addq $0x28, %r15
movq (%r15), %r15
testq %r15, %r15
je 0x2b6bd
movq 0x10(%r15), %rdi
callq 0x2efb1
jmp 0x2b6aa
movq %rbx, -0x28(%rbp)
movq 0x20(%rbx), %rax
movq (%rax,%r14), %r14
movq %r14, -0x20(%rbp)
leaq 0x409bc(%rip), %rsi     # 0x6c090
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2eff6
testq %rax, %rax
je 0x2b735
leaq 0x40989(%rip), %rsi     # 0x6c074
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x10594
testq %rax, %rax
je 0x2b72d
movq %rax, %r14
leaq 0x3994(%rip), %rdx      # 0x2f09b
leaq -0x28(%rbp), %rcx
movq %rbx, %rdi
movq %rax, %rsi
xorl %r8d, %r8d
callq 0x113e2
movl %eax, %r15d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x968b
cmpl $0x7, %r15d
jne 0x2b739
movb $0x1, 0x50(%rbx)
pushq $0x7
jmp 0x2b737
pushq $0x1
popq %r15
movl %r15d, %eax
addq $0x18, %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: sqlite3VdbeMemSetRowSet
SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem *pMem){
  sqlite3 *db = pMem->db;
  assert( db!=0 );
  assert( (pMem->flags & MEM_RowSet)==0 );
  sqlite3VdbeMemRelease(pMem);
  pMem->zMalloc = sqlite3DbMallocRaw(db, 64);
  if( db->mallocFailed ){
    pMem->flags = MEM_Null;
  }else{
    assert( pMem->zMalloc );
    pMem->u.pRowSet = sqlite3RowSetInit(db, pMem->zMalloc, 
                                       sqlite3DbMallocSize(db, pMem->zMalloc));
    assert( pMem->u.pRowSet!=0 );
    pMem->flags = MEM_RowSet;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r15
callq 0xde44
pushq $0x40
popq %rsi
movq %r15, %rdi
callq 0x103b4
movq %rax, %r14
movq %rax, 0x30(%rbx)
movw $0x1, %ax
cmpb $0x0, 0x50(%r15)
jne 0x2b7c6
movq %r15, %rdi
movq %r14, %rsi
callq 0x155aa
andq $0x0, (%r14)
movq %r15, 0x8(%r14)
andq $0x0, 0x28(%r14)
movq %r14, %rcx
addq $0x38, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movq %rcx, 0x20(%r14)
movl %eax, %eax
addq $-0x38, %rax
pushq $0x18
popq %rcx
xorl %edx, %edx
divq %rcx
movw %ax, 0x30(%r14)
movw $0x1, 0x32(%r14)
movq %r14, 0x18(%rbx)
movw $0x20, %ax
movw %ax, 0x24(%rbx)
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: sqlite3RowSetInsert
SQLITE_PRIVATE void sqlite3RowSetInsert(RowSet *p, i64 rowid){
  struct RowSetEntry *pEntry;  /* The new entry */
  struct RowSetEntry *pLast;   /* The last prior entry */

  /* This routine is never called after sqlite3RowSetNext() */
  assert( p!=0 && (p->rsFlags & ROWSET_NEXT)==0 );

  pEntry = rowSetEntryAlloc(p);
  if( pEntry==0 ) return;
  pEntry->v = rowid;
  pEntry->pRight = 0;
  pLast = p->pLast;
  if( pLast ){
    if( (p->rsFlags & ROWSET_SORTED)!=0 && rowid<=pLast->v ){
      p->rsFlags &= ~ROWSET_SORTED;
    }
    pLast->pRight = pEntry;
  }else{
    p->pEntry = pEntry;
  }
  p->pLast = pEntry;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
callq 0x301ad
testq %rax, %rax
je 0x2b821
movq %r14, (%rax)
andq $0x0, 0x8(%rax)
movq 0x18(%rbx), %rcx
testq %rcx, %rcx
je 0x2b816
movb 0x32(%rbx), %dl
testb $0x1, %dl
je 0x2b810
cmpq %r14, (%rcx)
jl 0x2b810
andb $-0x2, %dl
movb %dl, 0x32(%rbx)
addq $0x8, %rcx
jmp 0x2b81a
leaq 0x10(%rbx), %rcx
movq %rax, (%rcx)
movq %rax, 0x18(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeMemFinalize
SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
  int rc = SQLITE_OK;
  if( ALWAYS(pFunc && pFunc->xFinalize) ){
    sqlite3_context ctx;
    assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );
    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
    memset(&ctx, 0, sizeof(ctx));
    ctx.s.flags = MEM_Null;
    ctx.s.db = pMem->db;
    ctx.pMem = pMem;
    ctx.pFunc = pFunc;
    pFunc->xFinalize(&ctx); /* IMP: R-24505-23230 */
    assert( 0==(pMem->flags&MEM_Dyn) && !pMem->xDel );
    sqlite3DbFree(pMem->db, pMem->zMalloc);
    memcpy(pMem, &ctx.s, sizeof(ctx.s));
    rc = ctx.isError;
  }
  return rc;
}

// Assembly:
xorl %eax, %eax
testq %rsi, %rsi
je 0x2b8c5
movq 0x28(%rsi), %rcx
testq %rcx, %rcx
je 0x2b8c5
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x70, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq -0x78(%rbp), %r14
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x50(%r14)
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x10(%r14)
andq $0x0, 0x60(%r14)
movw $0x1, 0x2c(%r14)
movq (%rdi), %rax
movq %rax, 0x8(%r14)
movq %rdi, 0x40(%r14)
movq %rsi, (%r14)
movq %r14, %rdi
callq *%rcx
movq (%rbx), %rdi
movq 0x30(%rbx), %rsi
callq 0x968b
movq 0x38(%r14), %rax
movq %rax, 0x30(%rbx)
movups 0x8(%r14), %xmm0
movups 0x18(%r14), %xmm1
movups 0x28(%r14), %xmm2
movups %xmm2, 0x20(%rbx)
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
movl 0x5c(%r14), %eax
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: btreeRestoreCursorPosition
static int btreeRestoreCursorPosition(BtCursor *pCur){
  int rc;
  assert( cursorHoldsMutex(pCur) );
  assert( pCur->eState>=CURSOR_REQUIRESEEK );
  if( pCur->eState==CURSOR_FAULT ){
    return pCur->skipNext;
  }
  pCur->eState = CURSOR_INVALID;
  rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
  if( rc==SQLITE_OK ){
    sqlite3_free(pCur->pKey);
    pCur->pKey = 0;
    assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
    if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
      pCur->eState = CURSOR_SKIPNEXT;
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x4, 0x77(%rdi)
jne 0x2b9b2
movl 0x70(%rbx), %eax
jmp 0x2b9f0
movb $0x0, 0x77(%rbx)
movq 0x60(%rbx), %rdx
movq 0x68(%rbx), %rsi
leaq 0x70(%rbx), %r8
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x2b9f7
testl %eax, %eax
jne 0x2b9f0
movq 0x68(%rbx), %rdi
callq 0x9c7b
andq $0x0, 0x68(%rbx)
cmpl $0x0, 0x70(%rbx)
je 0x2b9ee
cmpb $0x1, 0x77(%rbx)
jne 0x2b9ee
movb $0x2, 0x77(%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: btreeMoveto
static int btreeMoveto(
  BtCursor *pCur,     /* Cursor open on the btree to be searched */
  const void *pKey,   /* Packed key if the btree is an index */
  i64 nKey,           /* Integer key for tables.  Size of pKey for indices */
  int bias,           /* Bias search to the high end */
  int *pRes           /* Write search results here */
){
  int rc;                    /* Status code */
  UnpackedRecord *pIdxKey;   /* Unpacked index key */
  char aSpace[150];          /* Temp space for pIdxKey - to avoid a malloc */
  char *pFree = 0;

  if( pKey ){
    assert( nKey==(i64)(int)nKey );
    pIdxKey = sqlite3VdbeAllocUnpackedRecord(
        pCur->pKeyInfo, aSpace, sizeof(aSpace), &pFree
    );
    if( pIdxKey==0 ) return SQLITE_NOMEM;
    sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey);
  }else{
    pIdxKey = 0;
  }
  rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);
  if( pFree ){
    sqlite3DbFree(pCur->pKeyInfo->db, pFree);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %ecx, %r15d
movq %rdx, %r12
movq %rdi, %rbx
andq $0x0, -0x30(%rbp)
testq %rsi, %rsi
je 0x2ba62
movq %rsi, %r13
movq %r8, -0x38(%rbp)
movq 0x20(%rbx), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0x30(%rbp), %rcx
movl $0x96, %edx
callq 0x2ab76
testq %rax, %rax
je 0x2ba92
movq %rax, %r14
movq 0x20(%rbx), %rdi
movl %r12d, %esi
movq %r13, %rdx
movq %rax, %rcx
callq 0x2abd6
movq -0x30(%rbp), %r13
movq -0x38(%rbp), %r8
jmp 0x2ba68
xorl %r13d, %r13d
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl %r15d, %ecx
callq 0x2a60b
movl %eax, %r14d
testq %r13, %r13
je 0x2ba96
movq 0x20(%rbx), %rax
movq (%rax), %rdi
movq %r13, %rsi
callq 0x968b
jmp 0x2ba96
pushq $0x7
popq %r14
movl %r14d, %eax
addq $0xa8, %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: fetchPayload
static const unsigned char *fetchPayload(
  BtCursor *pCur,      /* Cursor pointing to entry to read from */
  int *pAmt,           /* Write the number of available bytes here */
  int skipKey          /* read beginning at data if this is true */
){
  unsigned char *aPayload;
  MemPage *pPage;
  u32 nKey;
  u32 nLocal;

  assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
  assert( pCur->eState==CURSOR_VALID );
  assert( cursorHoldsMutex(pCur) );
  pPage = pCur->apPage[pCur->iPage];
  assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
  if( NEVER(pCur->info.nSize==0) ){
    btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],
                   &pCur->info);
  }
  aPayload = pCur->info.pCell;
  aPayload += pCur->info.nHeader;
  if( pPage->intKey ){
    nKey = 0;
  }else{
    nKey = (int)pCur->info.nKey;
  }
  if( skipKey ){
    aPayload += nKey;
    nLocal = pCur->info.nLocal - nKey;
  }else{
    nLocal = pCur->info.nLocal;
    assert( nLocal<=nKey );
  }
  *pAmt = nLocal;
  return aPayload;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movswq 0x7a(%rdi), %rax
movq 0xa8(%rdi,%rax,8), %r13
leaq 0x40(%rdi), %r12
cmpw $0x0, 0x5e(%rdi)
jne 0x2baeb
movzwl 0x7c(%r14,%rax,2), %esi
movq %r13, %rdi
movq %r12, %rdx
callq 0x1e40e
movzwl 0x58(%r14), %eax
xorl %ecx, %ecx
cmpb $0x0, 0x2(%r13)
jne 0x2bafd
movl (%r12), %ecx
addq 0x48(%r14), %rax
testl %r15d, %r15d
je 0x2bb14
movl %ecx, %edx
addq %rdx, %rax
movzwl 0x5a(%r14), %edx
subl %ecx, %edx
jmp 0x2bb19
movzwl 0x5a(%r14), %edx
movl %edx, (%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: sqlite3PutVarint
SQLITE_PRIVATE int sqlite3PutVarint(unsigned char *p, u64 v){
  int i, j, n;
  u8 buf[10];
  if( v & (((u64)0xff000000)<<32) ){
    p[8] = (u8)v;
    v >>= 8;
    for(i=7; i>=0; i--){
      p[i] = (u8)((v & 0x7f) | 0x80);
      v >>= 7;
    }
    return 9;
  }    
  n = 0;
  do{
    buf[n++] = (u8)((v & 0x7f) | 0x80);
    v >>= 7;
  }while( v!=0 );
  buf[0] &= 0x7f;
  assert( n<=9 );
  for(i=0, j=n-1; j>=0; j--, i++){
    p[i] = buf[j];
  }
  return n;
}

// Assembly:
movq %rsi, %rax
shrq $0x38, %rax
jne 0x2bb7b
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
movq %rsi, %rcx
movl %esi, %edx
orb $-0x80, %dl
movb %dl, -0xa(%rbp,%rax)
incq %rax
shrq $0x7, %rcx
cmpq $0x7f, %rsi
movq %rcx, %rsi
ja 0x2bb3c
andb $0x7f, -0xa(%rbp)
leaq -0x1(%rax), %rcx
movq %rax, %rdx
cmpq $-0x1, %rcx
je 0x2bba5
decq %rdx
movl %edx, %esi
movb -0xa(%rbp,%rsi), %sil
movb %sil, (%rdi)
decq %rcx
incq %rdi
jmp 0x2bb60
movb %sil, 0x8(%rdi)
shrq $0x8, %rsi
movl $0x7, %ecx
movl $0x9, %eax
testl %ecx, %ecx
js 0x2bba6
movl %esi, %edx
orb $-0x80, %dl
movl %ecx, %r8d
movb %dl, (%rdi,%r8)
shrq $0x7, %rsi
decl %ecx
jmp 0x2bb8d
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: moveToChild
static int moveToChild(BtCursor *pCur, u32 newPgno){
  int rc;
  int i = pCur->iPage;
  MemPage *pNewPage;
  BtShared *pBt = pCur->pBt;

  assert( cursorHoldsMutex(pCur) );
  assert( pCur->eState==CURSOR_VALID );
  assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
  assert( pCur->iPage>=0 );
  if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){
    return SQLITE_CORRUPT_BKPT;
  }
  rc = getAndInitPage(pBt, newPgno, &pNewPage,
               pCur->wrFlag==0 ? PAGER_GET_READONLY : 0);
  if( rc ) return rc;
  pCur->apPage[i+1] = pNewPage;
  pCur->aiIdx[i+1] = 0;
  pCur->iPage++;

  pCur->info.nSize = 0;
  pCur->validNKey = 0;
  if( pNewPage->nCell<1 || pNewPage->intKey!=pCur->apPage[i]->intKey ){
    return SQLITE_CORRUPT_BKPT;
  }
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movswq 0x7a(%rdi), %r14
movl $0xd26b, %edi           # imm = 0xD26B
cmpq $0x12, %r14
jle 0x2bd1c
callq 0x1a1fc
pushq $0xb
popq %rax
jmp 0x2bd38
movq 0x8(%rbx), %rdi
xorl %ecx, %ecx
cmpb $0x0, 0x74(%rbx)
sete %cl
addl %ecx, %ecx
leaq -0x18(%rbp), %rdx
callq 0x2bd80
testl %eax, %eax
je 0x2bd41
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq -0x18(%rbp), %rcx
movq %rcx, 0xb0(%rbx,%r14,8)
andw $0x0, 0x7e(%rbx,%r14,2)
incw 0x7a(%rbx)
andw $0x0, 0x5e(%rbx)
movb $0x0, 0x76(%rbx)
movl $0xd277, %edi           # imm = 0xD277
xorl %eax, %eax
cmpw %ax, 0x10(%rcx)
je 0x2bd12
movb 0x2(%rcx), %cl
movq 0xa8(%rbx,%r14,8), %rdx
cmpb 0x2(%rdx), %cl
jne 0x2bd12
jmp 0x2bd38
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: getAndInitPage
static int getAndInitPage(
  BtShared *pBt,                  /* The database file */
  Pgno pgno,                      /* Number of the page to get */
  MemPage **ppPage,               /* Write the page pointer here */
  int bReadonly                   /* PAGER_GET_READONLY or 0 */
){
  int rc;
  assert( sqlite3_mutex_held(pBt->mutex) );
  assert( bReadonly==PAGER_GET_READONLY || bReadonly==0 );

  if( pgno>btreePagecount(pBt) ){
    rc = SQLITE_CORRUPT_BKPT;
  }else{
    rc = btreeGetPage(pBt, pgno, ppPage, bReadonly);
    if( rc==SQLITE_OK ){
      rc = btreeInitPage(*ppPage);
      if( rc!=SQLITE_OK ){
        releasePage(*ppPage);
      }
    }
  }

  testcase( pgno==0 );
  assert( pgno!=0 || rc==SQLITE_CORRUPT );
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
cmpl %esi, 0x3c(%rdi)
jae 0x2bd9c
movl $0xc81c, %edi           # imm = 0xC81C
callq 0x1a1fc
pushq $0xb
popq %r14
jmp 0x2bdc7
movq %rdx, %rbx
callq 0x1d84e
movl %eax, %r14d
testl %eax, %eax
jne 0x2bdc7
movq (%rbx), %rdi
callq 0x1a4b5
testl %eax, %eax
je 0x2bdc4
movl %eax, %r14d
movq (%rbx), %rdi
callq 0x1d90e
jmp 0x2bdc7
xorl %r14d, %r14d
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3SchemaClear
SQLITE_PRIVATE void sqlite3SchemaClear(void *p){
  Hash temp1;
  Hash temp2;
  HashElem *pElem;
  Schema *pSchema = (Schema *)p;

  temp1 = pSchema->tblHash;
  temp2 = pSchema->trigHash;
  sqlite3HashInit(&pSchema->trigHash);
  sqlite3HashClear(&pSchema->idxHash);
  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){
    sqlite3DeleteTrigger(0, (Trigger*)sqliteHashData(pElem));
  }
  sqlite3HashClear(&temp2);
  sqlite3HashInit(&pSchema->tblHash);
  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
    Table *pTab = sqliteHashData(pElem);
    sqlite3DeleteTable(0, pTab);
  }
  sqlite3HashClear(&temp1);
  sqlite3HashClear(&pSchema->fkeyHash);
  pSchema->pSeqTab = 0;
  if( pSchema->flags & DB_SchemaLoaded ){
    pSchema->iGeneration++;
    pSchema->flags &= ~DB_SchemaLoaded;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
movups 0x8(%rdi), %xmm0
movaps %xmm0, -0x30(%rbp)
movq 0x18(%rdi), %rax
movq %rax, -0x20(%rbp)
movq 0x48(%rdi), %rax
leaq -0x48(%rbp), %r15
movq %rax, 0x8(%r15)
movups 0x38(%rdi), %xmm0
movaps %xmm0, -0x8(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rdi)
andq $0x0, 0x48(%rdi)
addq $0x20, %rdi
callq 0x2be96
movq (%r15), %r15
testq %r15, %r15
je 0x2be32
movq 0x10(%r15), %rsi
xorl %edi, %edi
callq 0x9382
jmp 0x2be1d
leaq -0x50(%rbp), %rdi
callq 0x2be96
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq -0x28(%rbp), %r14
movq (%r14), %r14
testq %r14, %r14
je 0x2be60
movq 0x10(%r14), %rsi
xorl %edi, %edi
callq 0x93dc
jmp 0x2be4b
leaq -0x30(%rbp), %rdi
callq 0x2be96
leaq 0x50(%rbx), %rdi
callq 0x2be96
andq $0x0, 0x68(%rbx)
movzwl 0x72(%rbx), %eax
testb $0x1, %al
je 0x2be8b
incl 0x4(%rbx)
andl $0xfffe, %eax           # imm = 0xFFFE
movw %ax, 0x72(%rbx)
addq $0x38, %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: sqlite3HashClear
SQLITE_PRIVATE void sqlite3HashClear(Hash *pH){
  HashElem *elem;         /* For looping over all elements of the table */

  assert( pH!=0 );
  elem = pH->first;
  pH->first = 0;
  sqlite3_free(pH->ht);
  pH->ht = 0;
  pH->htsize = 0;
  while( elem ){
    HashElem *next_elem = elem->next;
    sqlite3_free(elem);
    elem = next_elem;
  }
  pH->count = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movq 0x10(%rdi), %rdi
andq $0x0, 0x8(%rbx)
callq 0x9c7b
andq $0x0, 0x10(%rbx)
andl $0x0, (%rbx)
testq %r14, %r14
je 0x2bed2
movq (%r14), %r15
movq %r14, %rdi
callq 0x9c7b
movq %r15, %r14
jmp 0x2bebd
andl $0x0, 0x4(%rbx)
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: moveToLeftmost
static int moveToLeftmost(BtCursor *pCur){
  Pgno pgno;
  int rc = SQLITE_OK;
  MemPage *pPage;

  assert( cursorHoldsMutex(pCur) );
  assert( pCur->eState==CURSOR_VALID );
  while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){
    assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
    pgno = get4byte(findCell(pPage, pCur->aiIdx[pCur->iPage]));
    rc = moveToChild(pCur, pgno);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %eax, %eax
testl %eax, %eax
jne 0x2bf38
movswq 0x7a(%rbx), %rdx
movq 0xa8(%rbx,%rdx,8), %rcx
cmpb $0x0, 0x3(%rcx)
jne 0x2bf38
movzwl 0x12(%rcx), %eax
movq 0x60(%rcx), %rsi
movzwl 0x7c(%rbx,%rdx,2), %edx
movzbl (%rsi,%rdx,2), %r8d
shll $0x8, %r8d
movzbl 0x1(%rsi,%rdx,2), %edi
orl %r8d, %edi
andl %eax, %edi
addq 0x50(%rcx), %rdi
callq 0x180a3
movq %rbx, %rdi
movl %eax, %esi
callq 0x2bcf4
jmp 0x2beec
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: moveToRightmost
static int moveToRightmost(BtCursor *pCur){
  Pgno pgno;
  int rc = SQLITE_OK;
  MemPage *pPage = 0;

  assert( cursorHoldsMutex(pCur) );
  assert( pCur->eState==CURSOR_VALID );
  while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){
    pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);
    pCur->aiIdx[pCur->iPage] = pPage->nCell;
    rc = moveToChild(pCur, pgno);
  }
  if( rc==SQLITE_OK ){
    pCur->aiIdx[pCur->iPage] = pPage->nCell-1;
    pCur->info.nSize = 0;
    pCur->validNKey = 0;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %eax, %eax
testl %eax, %eax
jne 0x2bfa8
movswq 0x7a(%rbx), %r14
movq 0xa8(%rbx,%r14,8), %r15
cmpb $0x0, 0x3(%r15)
jne 0x2bf93
movq 0x50(%r15), %rax
movzbl 0x5(%r15), %ecx
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
callq 0x180a3
movzwl 0x10(%r15), %ecx
movw %cx, 0x7c(%rbx,%r14,2)
movq %rbx, %rdi
movl %eax, %esi
callq 0x2bcf4
jmp 0x2bf4e
movl 0x10(%r15), %ecx
decl %ecx
movw %cx, 0x7c(%rbx,%r14,2)
andw $0x0, 0x5e(%rbx)
movb $0x0, 0x76(%rbx)
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: invalidateIncrblobCursors
static void invalidateIncrblobCursors(
  Btree *pBtree,          /* The database file to check */
  i64 iRow,               /* The rowid that might be changing */
  int isClearTable        /* True if all rows are being deleted */
){
  BtCursor *p;
  BtShared *pBt = pBtree->pBt;
  assert( sqlite3BtreeHoldsMutex(pBtree) );
  for(p=pBt->pCursor; p; p=p->pNext){
    if( p->isIncrblobHandle && (isClearTable || p->info.nKey==iRow) ){
      p->eState = CURSOR_INVALID;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x8(%rdi), %rax
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x2c198
cmpb $0x0, 0x78(%rax)
je 0x2c179
testl %edx, %edx
jne 0x2c192
cmpq %rsi, 0x40(%rax)
jne 0x2c179
movb $0x0, 0x77(%rax)
jmp 0x2c179
popq %rbp
retq