// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeIdxRowid
SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
  i64 nCellKey = 0;
  int rc;
  u32 szHdr;        /* Size of the header */
  u32 typeRowid;    /* Serial type of the rowid */
  u32 lenRowid;     /* Size of the rowid */
  Mem m, v;

  UNUSED_PARAMETER(db);

  /* Get the size of the index entry.  Only indices entries of less
  ** than 2GiB are support - anything large must be database corruption.
  ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so
  ** this code can safely assume that nCellKey is 32-bits  
  */
  assert( sqlite3BtreeCursorIsValid(pCur) );
  VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey);
  assert( rc==SQLITE_OK );     /* pCur is always valid so KeySize cannot fail */
  assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );

  /* Read in the complete content of the index entry */
  memset(&m, 0, sizeof(m));
  rc = sqlite3VdbeMemFromBtree(pCur, 0, (int)nCellKey, 1, &m);
  if( rc ){
    return rc;
  }

  /* The index entry must begin with a header size */
  (void)getVarint32((u8*)m.z, szHdr);
  testcase( szHdr==3 );
  testcase( szHdr==m.n );
  if( unlikely(szHdr<3 || (int)szHdr>m.n) ){
    goto idx_rowid_corruption;
  }

  /* The last field of the index should be an integer - the ROWID.
  ** Verify that the last entry really is an integer. */
  (void)getVarint32((u8*)&m.z[szHdr-1], typeRowid);
  testcase( typeRowid==1 );
  testcase( typeRowid==2 );
  testcase( typeRowid==3 );
  testcase( typeRowid==4 );
  testcase( typeRowid==5 );
  testcase( typeRowid==6 );
  testcase( typeRowid==8 );
  testcase( typeRowid==9 );
  if( unlikely(typeRowid<1 || typeRowid>9 || typeRowid==7) ){
    goto idx_rowid_corruption;
  }
  lenRowid = sqlite3VdbeSerialTypeLen(typeRowid);
  testcase( (u32)m.n==szHdr+lenRowid );
  if( unlikely((u32)m.n<szHdr+lenRowid) ){
    goto idx_rowid_corruption;
  }

  /* Fetch the integer off the end of the index record */
  sqlite3VdbeSerialGet((u8*)&m.z[m.n-lenRowid], typeRowid, &v);
  *rowid = v.u.i;
  sqlite3VdbeMemRelease(&m);
  return SQLITE_OK;

  /* Jump here if database corruption is detected after m has been
  ** allocated.  Free the m object and return SQLITE_CORRUPT. */
idx_rowid_corruption:
  testcase( m.zMalloc!=0 );
  sqlite3VdbeMemRelease(&m);
  return SQLITE_CORRUPT_BKPT;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %r12d, %r12d
leaq -0x30(%rbp), %r15
movq %r12, (%r15)
movq %r15, %rsi
callq 0x21510
leaq -0x70(%rbp), %r8
movq %r12, 0x30(%r8)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%r8)
movaps %xmm0, 0x10(%r8)
movaps %xmm0, (%r8)
movl (%r15), %edx
movq %r14, %rdi
xorl %esi, %esi
movl $0x1, %ecx
callq 0x2c477
movl %eax, %r14d
testl %eax, %eax
jne 0x2e289
movq -0x68(%rbp), %r14
movsbl (%r14), %eax
testl %eax, %eax
js 0x2e1e7
movl %eax, -0x28(%rbp)
jmp 0x2e1f3
leaq -0x28(%rbp), %rsi
movq %r14, %rdi
callq 0x216ad
movl -0x28(%rbp), %r12d
cmpl $0x3, %r12d
jb 0x2e25b
movl -0x50(%rbp), %r15d
cmpl %r15d, %r12d
jg 0x2e25b
leal -0x1(%r12), %edi
movsbl (%r14,%rdi), %eax
testl %eax, %eax
js 0x2e219
movl %eax, -0x24(%rbp)
jmp 0x2e225
addq %r14, %rdi
leaq -0x24(%rbp), %rsi
callq 0x216ad
movl -0x24(%rbp), %esi
cmpq $0x7, %rsi
sete %al
leal -0xa(%rsi), %ecx
cmpl $-0x9, %ecx
setb %cl
orb %al, %cl
jne 0x2e25b
cmpl $0xc, %esi
jb 0x2e248
leal -0xc(%rsi), %eax
shrl %eax
jmp 0x2e253
leaq 0x48193(%rip), %rax     # 0x763e2
movzbl (%rsi,%rax), %eax
addl %eax, %r12d
cmpl %r12d, %r15d
jae 0x2e29c
leaq -0x70(%rbp), %rdi
callq 0xec23
leaq 0x4b5a9(%rip), %rsi     # 0x79814
leaq 0x4b2c7(%rip), %rcx     # 0x79539
movl $0xb, %r14d
movl $0xb, %edi
movl $0xf6cb, %edx           # imm = 0xF6CB
xorl %eax, %eax
callq 0xb8cc
movl %r14d, %eax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
subl %eax, %r15d
addq %r15, %r14
leaq -0xa8(%rbp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x2c565
movq 0x18(%r15), %rax
movq %rax, (%rbx)
leaq -0x70(%rbp), %rdi
callq 0xec23
xorl %r14d, %r14d
jmp 0x2e289