// File: /workspace/github_c_makefile_star2_O0/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
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x2bf30
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x8200
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
xorl %esi, %esi
movl $0x1, %ecx
leaq -0x70(%rbp), %r8
callq 0x3b790
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x3e1ca
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e2fe
movq -0x68(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x80, %eax
jge 0x3e1ef
movq -0x68(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x30(%rbp)
movl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x3e205
movq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2c290
movzbl %al, %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
cmpl $0x3, -0x30(%rbp)
jb 0x3e219
movl -0x30(%rbp), %eax
cmpl -0x50(%rbp), %eax
jle 0x3e21e
jmp 0x3e2e8
movq -0x68(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x80, %eax
jge 0x3e255
movq -0x68(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
movl $0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0x3e276
movq -0x68(%rbp), %rdi
movl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
addq %rax, %rdi
leaq -0x34(%rbp), %rsi
callq 0x2c290
movzbl %al, %eax
movl %eax, -0xb0(%rbp)
movl -0xb0(%rbp), %eax
cmpl $0x1, -0x34(%rbp)
jb 0x3e28e
cmpl $0x9, -0x34(%rbp)
ja 0x3e28e
cmpl $0x7, -0x34(%rbp)
jne 0x3e290
jmp 0x3e2e8
movl -0x34(%rbp), %edi
callq 0x3b8f0
movl %eax, -0x38(%rbp)
movl -0x50(%rbp), %eax
movl -0x30(%rbp), %ecx
addl -0x38(%rbp), %ecx
cmpl %ecx, %eax
jae 0x3e2aa
jmp 0x3e2e8
movq -0x68(%rbp), %rdi
movl -0x50(%rbp), %eax
subl -0x38(%rbp), %eax
movl %eax, %eax
addq %rax, %rdi
movl -0x34(%rbp), %esi
leaq -0xa8(%rbp), %rdx
callq 0x3b930
movq -0x90(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
leaq -0x70(%rbp), %rdi
callq 0x10190
movl $0x0, -0x4(%rbp)
jmp 0x3e2fe
leaq -0x70(%rbp), %rdi
callq 0x10190
movl $0xf6cb, %edi           # imm = 0xF6CB
callq 0x24410
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)