// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/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;

  /* 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) );
  nCellKey = sqlite3BtreePayloadSize(pCur);
  assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );

  /* Read in the complete content of the index entry */
  sqlite3VdbeMemInit(&m, db, 0);
  rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
  if( rc ){
    return rc;
  }

  /* The index entry must begin with a header size */
  getVarint32NR((u8*)m.z, szHdr);
  testcase( szHdr==3 );
  testcase( szHdr==m.n );
  testcase( szHdr>0x7fffffff );
  assert( m.n>=0 );
  if( unlikely(szHdr<3 || szHdr>(unsigned)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. */
  getVarint32NR((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 = sqlite3SmallTypeSizes[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.szMalloc!=0 );
  sqlite3VdbeMemRelease(&m);
  return SQLITE_CORRUPT_BKPT;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rsi, %rdi
callq 0x28e1b0
movl 0x40(%r14), %esi
leaq 0x8(%rsp), %rdx
movw $0x0, 0x8(%rdx)
movq %r15, 0x28(%rdx)
movl $0x0, 0x20(%rdx)
movq %r14, %rdi
callq 0x29b66f
movl %eax, %ebp
testl %eax, %eax
jne 0x29d5de
movq 0x18(%rsp), %r14
movzbl (%r14), %r12d
movl %r12d, 0x4(%rsp)
testb %r12b, %r12b
jns 0x29d540
leaq 0x4(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x29b609
movl (%r15), %r12d
cmpl $0x3, %r12d
jb 0x29d59b
movl 0x14(%rsp), %r13d
cmpl %r13d, %r12d
ja 0x29d59b
leal -0x1(%r12), %edi
movzbl (%r14,%rdi), %esi
movl %esi, (%rsp)
testb %sil, %sil
jns 0x29d573
addq %r14, %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0x29b609
movl (%r15), %esi
leal -0xa(%rsi), %eax
cmpl $-0x9, %eax
setb %al
cmpl $0x7, %esi
sete %cl
orb %al, %cl
jne 0x29d59b
movl %esi, %eax
leaq 0x1348e1(%rip), %rcx    # 0x3d1e70
movzbl (%rax,%rcx), %eax
addl %eax, %r12d
cmpl %r12d, %r13d
jae 0x29d5ef
testb $0x24, 0x11(%rsp)
jne 0x29d5a9
cmpl $0x0, 0x28(%rsp)
je 0x29d5b3
leaq 0x8(%rsp), %rdi
callq 0x291775
leaq 0x138611(%rip), %rsi    # 0x3d5bcb
leaq 0x13871b(%rip), %rdx    # 0x3d5cdc
leaq 0x138469(%rip), %r8     # 0x3d5a31
movl $0xb, %ebp
movl $0xb, %edi
movl $0x14310, %ecx          # imm = 0x14310
xorl %eax, %eax
callq 0x274d08
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subl %eax, %r13d
addq %r13, %r14
leaq 0x40(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x29b6b7
movq (%r15), %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
testb $0x24, 0x11(%rsp)
jne 0x29d61b
cmpl $0x0, 0x28(%rsp)
je 0x29d5de
leaq 0x8(%rsp), %rdi
callq 0x291775
jmp 0x29d5de