// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3e9320
movl %eax, %eax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x70(%rbp), %rdi
xorl %edx, %edx
callq 0x3ff010
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %esi
leaq -0x70(%rbp), %rdx
callq 0x3fa640
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x3fd4d4
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3fd5c5
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x80, -0x30(%rbp)
jb 0x3fd4f4
movq -0x60(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3fa520
cmpl $0x3, -0x30(%rbp)
jb 0x3fd502
movl -0x30(%rbp), %eax
cmpl -0x64(%rbp), %eax
jbe 0x3fd507
jmp 0x3fd5af
movq -0x60(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
cmpl $0x80, -0x34(%rbp)
jb 0x3fd53b
movq -0x60(%rbp), %rdi
movl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
addq %rax, %rdi
leaq -0x34(%rbp), %rsi
callq 0x3fa520
cmpl $0x1, -0x34(%rbp)
jb 0x3fd54d
cmpl $0x9, -0x34(%rbp)
ja 0x3fd54d
cmpl $0x7, -0x34(%rbp)
jne 0x3fd54f
jmp 0x3fd5af
movl -0x34(%rbp), %eax
movl %eax, %ecx
leaq 0x1a9e35(%rip), %rax    # 0x5a7390
movzbl (%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
movl -0x64(%rbp), %eax
movl -0x30(%rbp), %ecx
addl -0x38(%rbp), %ecx
cmpl %ecx, %eax
jae 0x3fd571
jmp 0x3fd5af
movq -0x60(%rbp), %rdi
movl -0x64(%rbp), %eax
subl -0x38(%rbp), %eax
movl %eax, %eax
addq %rax, %rdi
movl -0x34(%rbp), %esi
leaq -0xa8(%rbp), %rdx
callq 0x3fa720
movq -0xa8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
leaq -0x70(%rbp), %rdi
callq 0x3c76d0
movl $0x0, -0x4(%rbp)
jmp 0x3fd5c5
leaq -0x70(%rbp), %rdi
callq 0x3c76d0
movl $0x14310, %edi          # imm = 0x14310
callq 0x3dff80
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)