// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x80, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rsi, %rdi
callq 0x297df9
movl 0x40(%r14), %esi
leaq 0x10(%rsp), %rdx
movw $0x0, 0x8(%rdx)
movq %r15, 0x28(%rdx)
movl $0x0, 0x20(%rdx)
movq %r14, %rdi
callq 0x2a4772
movl %eax, %ebp
testl %eax, %eax
jne 0x2a6bc1
movq 0x20(%rsp), %r14
movzbl (%r14), %eax
movl %eax, 0xc(%rsp)
testb %al, %al
jns 0x2a6b1f
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x2a470c
movl 0xc(%rsp), %r12d
cmpl $0x3, %r12d
jb 0x2a6b7e
movl 0x1c(%rsp), %r15d
cmpl %r15d, %r12d
ja 0x2a6b7e
leal -0x1(%r12), %edi
movzbl (%r14,%rdi), %eax
movl %eax, 0x8(%rsp)
testb %al, %al
jns 0x2a6b53
addq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2a470c
movl 0x8(%rsp), %esi
cmpq $0x7, %rsi
sete %al
leal -0xa(%rsi), %ecx
cmpl $-0x9, %ecx
setb %cl
orb %al, %cl
jne 0x2a6b7e
leaq 0x134a7e(%rip), %rax    # 0x3db5f0
movzbl (%rsi,%rax), %eax
addl %eax, %r12d
cmpl %r12d, %r15d
jae 0x2a6bd3
testb $0x24, 0x19(%rsp)
jne 0x2a6b8c
cmpl $0x0, 0x30(%rsp)
je 0x2a6b96
leaq 0x10(%rsp), %rdi
callq 0x29b45b
leaq 0x138782(%rip), %rsi    # 0x3df31f
leaq 0x13888c(%rip), %rdx    # 0x3df430
leaq 0x1385da(%rip), %r8     # 0x3df185
movl $0xb, %ebp
movl $0xb, %edi
movl $0x14310, %ecx          # imm = 0x14310
xorl %eax, %eax
callq 0x27e637
movl %ebp, %eax
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
subl %eax, %r15d
addq %r15, %r14
leaq 0x48(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x2a47ba
movq (%r15), %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
testb $0x24, 0x19(%rsp)
jne 0x2a6bff
cmpl $0x0, 0x30(%rsp)
je 0x2a6bc1
leaq 0x10(%rsp), %rdi
callq 0x29b45b
jmp 0x2a6bc1