// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %r12d, %r12d
leaq -0x38(%rbp), %r15
movq %r12, (%r15)
movq %r15, %rsi
callq 0x211a9
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 0x2cd65
movl %eax, %r14d
testl %eax, %eax
jne 0x2ea34
movq -0x68(%rbp), %r14
movsbl (%r14), %r12d
testl %r12d, %r12d
jns 0x2e9af
leaq -0x30(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2134f
movl (%r15), %r12d
cmpl $0x3, %r12d
jb 0x2ea06
movl -0x50(%rbp), %r13d
cmpl %r13d, %r12d
jg 0x2ea06
leal -0x1(%r12), %edi
movsbl (%r14,%rdi), %esi
testl %esi, %esi
jns 0x2e9de
addq %r14, %rdi
leaq -0x2c(%rbp), %r15
movq %r15, %rsi
callq 0x2134f
movl (%r15), %esi
leal -0xa(%rsi), %eax
cmpl $-0x9, %eax
setb %al
cmpl $0x7, %esi
sete %cl
orb %al, %cl
jne 0x2ea06
movl %esi, %eax
leaq 0x47a38(%rip), %rcx     # 0x76432
movzbl (%rax,%rcx), %eax
addl %eax, %r12d
cmpl %r12d, %r13d
jae 0x2ea49
leaq -0x70(%rbp), %rdi
callq 0xecfd
leaq 0x4adfe(%rip), %rsi     # 0x79814
leaq 0x4ab1c(%rip), %rcx     # 0x79539
movl $0xb, %r14d
movl $0xb, %edi
movl $0xf6cb, %edx           # imm = 0xF6CB
xorl %eax, %eax
callq 0xb9c7
movl %r14d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subl %eax, %r13d
addq %r13, %r14
leaq -0xa8(%rbp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x2ce53
movq 0x18(%r15), %rax
movq %rax, (%rbx)
leaq -0x70(%rbp), %rdi
callq 0xecfd
xorl %r14d, %r14d
jmp 0x2ea34