// File: /workspace/github_c_makefile_star2_O1/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 0x2d3f3f
movq 0x48(%r15), %rsi
testq %rsi, %rsi
je 0x2d3f38
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 0x2d4269
movl $0x0, 0x40(%rbx)
xorl %r12d, %r12d
jmp 0x2d3f3f
movl $0x0, (%r9)
testl %ebp, %ebp
je 0x2d3f4f
movl $0x5e, %eax
testb $0x8, 0x63(%r15)
jne 0x2d3f54
movl $0x60, %eax
movzwl (%r15,%rax), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2c8275
testq %r12, %r12
movl %eax, 0xc(%rsp)
je 0x2d3f7a
cmpl 0x68(%rsp), %eax
jne 0x2d3f7a
cmpq $0x0, 0x48(%r12)
je 0x2d3f7d
xorl %r12d, %r12d
movl %ebp, 0x8(%rsp)
testl %ebp, %ebp
je 0x2d405e
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
testq %r12, %r12
je 0x2d3fce
movq 0x8(%r12), %rax
movzwl (%rax,%r14,2), %eax
cmpw $-0x2, %ax
je 0x2d3fce
movq 0x8(%r15), %rcx
cmpw (%rcx,%r14,2), %ax
je 0x2d404e
movq 0x8(%r15), %rax
movswl (%rax,%r14,2), %ecx
cmpl $-0x2, %ecx
jne 0x2d4005
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 0x2c9826
movl $0x0, 0x40(%rbx)
jmp 0x2d4020
movq 0x10(%rbx), %rdi
movq 0x18(%r15), %rsi
movq 0x20(%rsp), %rax
leal (%rax,%r14), %r8d
movq 0x10(%rsp), %rdx
callq 0x2c9886
movq (%rsp), %rax
movl 0x90(%rax), %esi
testl %esi, %esi
jle 0x2d404e
movq (%rsp), %rax
movq 0x88(%rax), %rax
decl %esi
leaq (%rsi,%rsi,2), %rcx
cmpb $0x53, (%rax,%rcx,8)
jne 0x2d404e
movq (%rsp), %rdi
callq 0x2cbeef
incq %r14
addq $0x18, %r13
cmpq %r14, %rbp
jne 0x2d3faa
movl 0x18(%rsp), %r8d
testl %r8d, %r8d
movl 0xc(%rsp), %ebp
movl 0x8(%rsp), %r14d
je 0x2d40ad
movq (%rsp), %rdi
movl $0x5b, %esi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x2b200c
movq 0x18(%r15), %rax
cmpq $0x0, 0x18(%rax)
je 0x2d40ad
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x2d42ce
movq (%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x285198
cmpl $0x1, %r14d
jne 0x2d40d4
testl %ebp, %ebp
je 0x2d40e4
movzbl 0x1f(%rbx), %eax
cmpq $0x7, %rax
ja 0x2d40e4
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%rbx)
leaq (%rbx,%rax,4), %rbx
addq $0xd4, %rbx
jmp 0x2d40e2
cmpl %r14d, 0x28(%rbx)
jge 0x2d40e4
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