// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3GenerateIndexKey
SQLITE_PRIVATE int sqlite3GenerateIndexKey(
  Parse *pParse,       /* Parsing context */
  Index *pIdx,         /* The index for which to generate a key */
  int iCur,            /* Cursor number for the pIdx->pTable table */
  int regOut,          /* Write the new index key to this register */
  int doMakeRec,       /* Run the OP_MakeRecord instruction if true */
  int *piPartIdxLabel  /* OUT: Jump to this label to skip partial index */
){
  Vdbe *v = pParse->pVdbe;
  int j;
  Table *pTab = pIdx->pTable;
  int regBase;
  int nCol;

  if( piPartIdxLabel ){
    if( pIdx->pPartIdxWhere ){
      *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
      pParse->iPartIdxTab = iCur;
      sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, 
                         SQLITE_JUMPIFNULL);
    }else{
      *piPartIdxLabel = 0;
    }
  }
  nCol = pIdx->nColumn;
  regBase = sqlite3GetTempRange(pParse, nCol+1);
  sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
  for(j=0; j<nCol; j++){
    int idx = pIdx->aiColumn[j];
    if( idx==pTab->iPKey ){
      sqlite3VdbeAddOp2(v, OP_SCopy, regBase+nCol, regBase+j);
    }else{
      sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase+j);
      sqlite3ColumnDefault(v, pTab, idx, -1);
    }
  }
  if( doMakeRec ){
    const char *zAff;
    if( pTab->pSelect
     || OptimizationDisabled(pParse->db, SQLITE_IdxRealAsInt)
    ){
      zAff = 0;
    }else{
      zAff = sqlite3IndexAffinityStr(v, pIdx);
    }
    sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut);
    sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT);
  }
  sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
  return regBase;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %r13d
movl %ecx, %r15d
movl %edx, -0x2c(%rbp)
movq %rsi, %r12
movq %rdi, %r14
movq 0x10(%rdi), %rax
movq %rax, -0x38(%rbp)
movq 0x18(%rsi), %rax
movq %rax, -0x68(%rbp)
testq %r9, %r9
je 0x4c3f7
movq %r9, %rbx
cmpq $0x0, 0x48(%r12)
je 0x4c3f1
movq -0x38(%rbp), %rdi
callq 0x4c5eb
movl %eax, (%rbx)
movl -0x2c(%rbp), %eax
movl %eax, 0x68(%r14)
movq 0x48(%r12), %rsi
movl (%rbx), %edx
movq %r14, %rdi
movl $0x8, %ecx
callq 0x4c638
jmp 0x4c3f7
movl $0x0, (%rbx)
movzwl 0x54(%r12), %ebx
leal 0x1(%rbx), %edx
movl 0x48(%r14), %eax
cmpl %ebx, %eax
movq %r14, -0x78(%rbp)
movl %r15d, -0x3c(%rbp)
movq %rdx, -0x70(%rbp)
movl %r13d, -0x40(%rbp)
jle 0x4c42b
movl 0x4c(%r14), %esi
leal (%rsi,%rdx), %ecx
movl %ecx, 0x4c(%r14)
subl %edx, %eax
movl %eax, 0x48(%r14)
jmp 0x4c438
movl 0x58(%r14), %eax
leal 0x1(%rax), %esi
addl %edx, %eax
movl %eax, 0x58(%r14)
movq %rsi, -0x50(%rbp)
leal (%rsi,%rbx), %ecx
movq -0x38(%rbp), %rdi
movl $0x60, %esi
movl -0x2c(%rbp), %edx
movl %ecx, -0x44(%rbp)
xorl %r8d, %r8d
callq 0x45f15
movq %rbx, -0x58(%rbp)
testl %ebx, %ebx
movq %r12, -0x60(%rbp)
je 0x4c4da
movl -0x58(%rbp), %eax
movq %rax, -0x80(%rbp)
movl -0x50(%rbp), %r15d
xorl %r14d, %r14d
movq -0x68(%rbp), %rbx
movq 0x8(%r12), %rax
movl (%rax,%r14,4), %r13d
movswl 0x40(%rbx), %eax
leaq (%r15,%r14), %r8
cmpl %eax, %r13d
jne 0x4c4a3
movq -0x38(%rbp), %rdi
movl $0x1d, %esi
movl -0x44(%rbp), %edx
movl %r8d, %ecx
xorl %r8d, %r8d
callq 0x45f15
jmp 0x4c4d1
movq -0x38(%rbp), %r12
movq %r12, %rdi
movl $0x29, %esi
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
callq 0x45f15
movq %r12, %rdi
movq -0x60(%rbp), %r12
movq %rbx, %rsi
movl %r13d, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x4c93d
incq %r14
cmpq %r14, -0x80(%rbp)
jne 0x4c474
cmpl $0x0, -0x40(%rbp)
movq -0x78(%rbp), %r14
movq -0x70(%rbp), %r12
movq -0x50(%rbp), %r13
je 0x4c541
movq -0x68(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x4c512
movq (%r14), %rax
testb $0x10, 0x4c(%rax)
jne 0x4c512
movq -0x38(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x4c9e0
movq %rax, %rbx
jmp 0x4c514
xorl %ebx, %ebx
movq -0x38(%rbp), %r15
movq %r15, %rdi
movl $0x2b, %esi
movl %r13d, %edx
movl %r12d, %ecx
movl -0x3c(%rbp), %r8d
callq 0x45f15
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x11a9f
movq %r14, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x4e564
movq -0x58(%rbp), %rax
cmpl %eax, 0x48(%r14)
jg 0x4c561
movl %r12d, 0x48(%r14)
movl %r13d, 0x4c(%r14)
movl %r13d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq