// File: /workspace/github_c_makefile_star2_O2/ukontainer[P]sqlite-bench/sqlite3.c
// Function: sqlite3CompleteInsertion
SQLITE_PRIVATE void sqlite3CompleteInsertion(
  Parse *pParse,      /* The parser context */
  Table *pTab,        /* the table into which we are inserting */
  int iDataCur,       /* Cursor of the canonical data source */
  int iIdxCur,        /* First index cursor */
  int regNewData,     /* Range of content */
  int *aRegIdx,       /* Register used by each index.  0 for unused indices */
  int update_flags,   /* True for UPDATE, False for INSERT */
  int appendBias,     /* True if this is likely to be an append */
  int useSeekResult   /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
){
  Vdbe *v;            /* Prepared statements under construction */
  Index *pIdx;        /* An index being inserted or updated */
  u8 pik_flags;       /* flag values passed to the btree insert */
  int regData;        /* Content registers (after the rowid) */
  int regRec;         /* Register holding assembled record for the table */
  int i;              /* Loop counter */
  u8 bAffinityDone = 0; /* True if OP_Affinity has been run already */

  assert( update_flags==0
       || update_flags==OPFLAG_ISUPDATE
       || update_flags==(OPFLAG_ISUPDATE|OPFLAG_SAVEPOSITION)
  );

  v = sqlite3GetVdbe(pParse);
  assert( v!=0 );
  assert( pTab->pSelect==0 );  /* This table is not a VIEW */
  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
    if( aRegIdx[i]==0 ) continue;
    bAffinityDone = 1;
    if( pIdx->pPartIdxWhere ){
      sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
      VdbeCoverage(v);
    }
    pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0);
    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
      assert( pParse->nested==0 );
      pik_flags |= OPFLAG_NCHANGE;
      pik_flags |= (update_flags & OPFLAG_SAVEPOSITION);
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
      if( update_flags==0 ){
        sqlite3VdbeAddOp4(v, OP_InsertInt, 
            iIdxCur+i, aRegIdx[i], 0, (char*)pTab, P4_TABLE
        );
        sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP);
      }
#endif
    }
    sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i],
                         aRegIdx[i]+1,
                         pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn);
    sqlite3VdbeChangeP5(v, pik_flags);
  }
  if( !HasRowid(pTab) ) return;
  regData = regNewData + 1;
  regRec = sqlite3GetTempReg(pParse);
  sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);
  sqlite3SetMakeRecordP5(v, pTab);
  if( !bAffinityDone ){
    sqlite3TableAffinity(v, pTab, 0);
  }
  if( pParse->nested ){
    pik_flags = 0;
  }else{
    pik_flags = OPFLAG_NCHANGE;
    pik_flags |= (update_flags?update_flags:OPFLAG_LASTROWID);
  }
  if( appendBias ){
    pik_flags |= OPFLAG_APPEND;
  }
  if( useSeekResult ){
    pik_flags |= OPFLAG_USESEEKRESULT;
  }
  sqlite3VdbeAddOp3(v, OP_Insert, iDataCur, regRec, regNewData);
  if( !pParse->nested ){
    sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
  }
  sqlite3VdbeChangeP5(v, pik_flags);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r13
movq %r8, 0x20(%rsp)
movl %ecx, %ebp
movl %edx, 0x4(%rsp)
movq %rsi, %r14
cmpl $0x0, 0x70(%rsp)
setne %r12b
movq %rdi, 0x10(%rsp)
callq 0x44856b
movq %rax, %rbx
movq %r14, 0x18(%rsp)
leaq 0x10(%r14), %r15
shlb $0x4, %r12b
movl 0x60(%rsp), %eax
andb $0x2, %al
orb %r12b, %al
incb %al
xorl %r14d, %r14d
movb %r12b, 0x3(%rsp)
movzbl %r12b, %ecx
movl %ecx, 0xc(%rsp)
movzbl %al, %eax
movl %eax, 0x8(%rsp)
movq (%r15), %r15
testq %r15, %r15
je 0x46361a
movl (%r13), %edx
testl %edx, %edx
je 0x46360b
cmpq $0x0, 0x48(%r15)
je 0x46359c
movl 0xb8(%rbx), %ecx
addl $0x2, %ecx
movq %rbx, %rdi
pushq $0x32
popq %rsi
callq 0x432a3f
movzwl 0x63(%r15), %eax
movl %eax, %ecx
andl $0x3, %ecx
movb 0x3(%rsp), %dl
movl %edx, %r12d
cmpw $0x2, %cx
jne 0x4635c7
movq 0x18(%rsp), %rcx
testb $0x20, 0x40(%rcx)
movl 0x8(%rsp), %r12d
cmovel 0xc(%rsp), %r12d
movl (%r13), %ecx
leal 0x1(%rcx), %r8d
xorl %edx, %edx
testb $0x8, %al
sete %dl
movzwl 0x5e(%r15,%rdx,2), %r9d
movq %rbx, %rdi
movl $0x85, %esi
movl %ebp, %edx
callq 0x40c85b
movslq 0xb8(%rbx), %rax
movb $0x1, %r14b
testq %rax, %rax
jle 0x46360b
movzbl %r12b, %ecx
movq 0x68(%rbx), %rdx
imulq $0x18, %rax, %rax
movw %cx, -0x16(%rdx,%rax)
addq $0x28, %r15
incl %ebp
addq $0x4, %r13
jmp 0x463569
movq 0x18(%rsp), %r12
testb $0x20, 0x40(%r12)
movq 0x10(%rsp), %rdi
jne 0x4636f2
movq 0x20(%rsp), %r13
leal 0x1(%r13), %r15d
callq 0x44b9b3
movl %eax, %ebp
movswl 0x46(%r12), %ecx
pushq $0x66
popq %rsi
movq %rbx, %rdi
movl %r15d, %edx
movl %eax, %r8d
callq 0x432a44
testb %r14b, %r14b
jne 0x463669
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x44dbd1
movl 0x60(%rsp), %ecx
movl %ecx, %eax
orb $0x1, %al
testl %ecx, %ecx
movzbl %al, %eax
pushq $0x21
popq %rcx
cmovnel %eax, %ecx
xorl %eax, %eax
movq 0x10(%rsp), %r15
cmpb $0x0, 0x1e(%r15)
cmovel %ecx, %eax
movl %eax, %ecx
orb $0x8, %cl
cmpl $0x0, 0x68(%rsp)
movzbl %cl, %ecx
cmovel %eax, %ecx
movl %ecx, %eax
orb $0x10, %al
cmpl $0x0, 0x70(%rsp)
movzbl %al, %r14d
cmovel %ecx, %r14d
pushq $0x7a
popq %rsi
movq %rbx, %rdi
movl 0x4(%rsp), %edx
movl %ebp, %ecx
movl %r13d, %r8d
callq 0x432a44
cmpb $0x0, 0x1e(%r15)
jne 0x4636d5
pushq $-0x6
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x448919
movslq 0xb8(%rbx), %rax
testq %rax, %rax
jle 0x4636f2
movzbl %r14b, %ecx
movq 0x68(%rbx), %rdx
imulq $0x18, %rax, %rax
movw %cx, -0x16(%rdx,%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq