// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3GenerateIndexKey
SQLITE_PRIVATE int sqlite3GenerateIndexKey(
  Parse *pParse,       /* Parsing context */
  Index *pIdx,         /* The index for which to generate a key */
  int iDataCur,        /* Cursor number from which to take column data */
  int regOut,          /* Put the new key into this register if not 0 */
  int prefixOnly,      /* Compute only a unique prefix of the key */
  int *piPartIdxLabel, /* OUT: Jump to this label to skip partial index */
  Index *pPrior,       /* Previously generated index key */
  int regPrior         /* Register holding previous generated key */
){
  Vdbe *v = pParse->pVdbe;
  int j;
  int regBase;
  int nCol;

  if( piPartIdxLabel ){
    if( pIdx->pPartIdxWhere ){
      *piPartIdxLabel = sqlite3VdbeMakeLabel(pParse);
      pParse->iSelfTab = iDataCur + 1;
      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
                            SQLITE_JUMPIFNULL);
      pParse->iSelfTab = 0;
      pPrior = 0; /* Ticket a9efb42811fa41ee 2019-11-02;
                  ** pPartIdxWhere may have corrupted regPrior registers */
    }else{
      *piPartIdxLabel = 0;
    }
  }
  nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
  regBase = sqlite3GetTempRange(pParse, nCol);
  if( pPrior && (regBase!=regPrior || pPrior->pPartIdxWhere) ) pPrior = 0;
  for(j=0; j<nCol; j++){
    if( pPrior
     && pPrior->aiColumn[j]==pIdx->aiColumn[j]
     && pPrior->aiColumn[j]!=XN_EXPR
    ){
      /* This column was already computed by the previous index */
      continue;
    }
    sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
    /* If the column affinity is REAL but the number is an integer, then it
    ** might be stored in the table as an integer (using a compact
    ** representation) then converted to REAL by an OP_RealAffinity opcode.
    ** But we are getting ready to store this value back into an index, where
    ** it should be converted by to INTEGER again.  So omit the OP_RealAffinity
    ** opcode if it is present */
    sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
  }
  if( regOut ){
    sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
    if( pIdx->pTable->pSelect ){
      const char *zAff = sqlite3IndexAffinityStr(pParse->db, pIdx);
      sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT);
    }
  }
  sqlite3ReleaseTempRange(pParse, regBase, nCol);
  return regBase;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %ebp
movl %ecx, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movq 0x60(%rsp), %r12
movq 0x10(%rdi), %rax
movq %rax, (%rsp)
testq %r9, %r9
je 0x2ca654
movq 0x48(%r15), %rsi
testq %rsi, %rsi
je 0x2ca64d
movl 0x44(%rbx), %eax
decl %eax
movl %eax, 0x44(%rbx)
movl %eax, (%r9)
movq 0x10(%rsp), %rax
incl %eax
movl %eax, 0x40(%rbx)
movl (%r9), %edx
movq %rbx, %rdi
callq 0x2ca983
movl $0x0, 0x40(%rbx)
xorl %r12d, %r12d
jmp 0x2ca654
movl $0x0, (%r9)
testl %ebp, %ebp
je 0x2ca664
movl $0x5e, %eax
testb $0x8, 0x63(%r15)
jne 0x2ca669
movl $0x60, %eax
movzwl (%r15,%rax), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2beb15
testq %r12, %r12
movl %eax, 0xc(%rsp)
je 0x2ca68f
cmpl 0x68(%rsp), %eax
jne 0x2ca68f
cmpq $0x0, 0x48(%r12)
je 0x2ca692
xorl %r12d, %r12d
movl %ebp, 0x8(%rsp)
testl %ebp, %ebp
je 0x2ca778
movq 0x10(%rsp), %rax
incl %eax
movl %eax, 0x1c(%rsp)
movl 0xc(%rsp), %eax
movq %rax, 0x20(%rsp)
movl 0x8(%rsp), %ebp
movl $0x8, %r13d
xorl %r14d, %r14d
movq 0x8(%r15), %rax
testq %r12, %r12
je 0x2ca6e8
movq 0x8(%r12), %rcx
movzwl (%rcx,%r14,2), %ecx
movzwl (%rax,%r14,2), %eax
cmpw $-0x2, %cx
je 0x2ca6ed
cmpw %ax, %cx
je 0x2ca768
jmp 0x2ca6ed
movzwl (%rax,%r14,2), %eax
cmpw $-0x2, %ax
jne 0x2ca71c
movl 0x1c(%rsp), %eax
movl %eax, 0x40(%rbx)
movq 0x50(%r15), %rax
movq (%rax,%r13), %rsi
movq 0x20(%rsp), %rax
leal (%rax,%r14), %edx
movq %rbx, %rdi
callq 0x2c00af
movl $0x0, 0x40(%rbx)
jmp 0x2ca73a
movswl %ax, %ecx
movq 0x10(%rbx), %rdi
movq 0x18(%r15), %rsi
movq 0x20(%rsp), %rax
leal (%rax,%r14), %r8d
movq 0x10(%rsp), %rdx
callq 0x2c010f
movq (%rsp), %rax
movl 0x90(%rax), %esi
testl %esi, %esi
jle 0x2ca768
movq (%rsp), %rax
movq 0x88(%rax), %rax
decl %esi
leaq (%rsi,%rsi,2), %rcx
cmpb $0x53, (%rax,%rcx,8)
jne 0x2ca768
movq (%rsp), %rdi
callq 0x2c27bc
incq %r14
addq $0x18, %r13
cmpq %r14, %rbp
jne 0x2ca6bf
movl 0x18(%rsp), %r8d
testl %r8d, %r8d
movl 0xc(%rsp), %ebp
movl 0x8(%rsp), %r14d
je 0x2ca7c7
movq (%rsp), %rdi
movl $0x5b, %esi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x2a83e1
movq 0x18(%r15), %rax
cmpq $0x0, 0x18(%rax)
je 0x2ca7c7
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x2ca9e8
movq (%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x27b778
cmpl $0x1, %r14d
jne 0x2ca7ee
testl %ebp, %ebp
je 0x2ca7fe
movzbl 0x1f(%rbx), %eax
cmpq $0x7, %rax
ja 0x2ca7fe
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%rbx)
leaq (%rbx,%rax,4), %rbx
addq $0xd4, %rbx
jmp 0x2ca7fc
cmpl %r14d, 0x28(%rbx)
jge 0x2ca7fe
movl %r14d, 0x28(%rbx)
addq $0x2c, %rbx
movl %ebp, (%rbx)
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq