// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %r9, %r13
movq %r8, 0x28(%rsp)
movl %ecx, %ebp
movl %edx, 0x1c(%rsp)
movq %rsi, %r14
movl 0x70(%rsp), %r12d
movq %rdi, 0x30(%rsp)
callq 0x44e8aa
movq %rax, %rbx
movq %r14, 0x10(%rsp)
movq 0x10(%r14), %r15
testq %r15, %r15
je 0x472cbf
cmpl $0x0, 0x80(%rsp)
setne %dl
shlb $0x4, %dl
movl %r12d, %ecx
andb $0x2, %cl
orb %dl, %cl
incb %cl
xorl %eax, %eax
movb %dl, 0xf(%rsp)
movzbl %dl, %edx
movl %edx, 0x24(%rsp)
movzbl %cl, %ecx
movl %ecx, 0x20(%rsp)
movl (%r13), %edx
testl %edx, %edx
je 0x472ca4
cmpq $0x0, 0x48(%r15)
je 0x472c19
movl 0xb8(%rbx), %ecx
addl $0x2, %ecx
movq %rbx, %rdi
movl $0x32, %esi
xorl %r8d, %r8d
callq 0x43bae0
movzwl 0x63(%r15), %eax
movl %eax, %ecx
andl $0x3, %ecx
movb 0xf(%rsp), %dl
movl %edx, %r14d
cmpw $0x2, %cx
jne 0x472c44
movq 0x10(%rsp), %rcx
testb $0x20, 0x40(%rcx)
movl 0x20(%rsp), %r14d
cmovel 0x24(%rsp), %r14d
movl (%r13), %ecx
leal 0x1(%rcx), %r8d
xorl %edx, %edx
testb $0x8, %al
sete %dl
movzwl 0x5e(%r15,%rdx,2), %r12d
movq %rbx, %rdi
movl $0x85, %esi
movl %ebp, %edx
callq 0x43bae0
movq (%rbx), %rcx
cmpb $0x0, 0x61(%rcx)
jne 0x472c85
movq 0x68(%rbx), %rcx
cltq
leaq (%rax,%rax,2), %rax
movb $-0x3, 0x1(%rcx,%rax,8)
movl %r12d, 0x10(%rcx,%rax,8)
movslq 0xb8(%rbx), %rcx
movb $0x1, %al
testq %rcx, %rcx
jle 0x472ca4
movzbl %r14b, %edx
movq 0x68(%rbx), %rsi
leaq (%rcx,%rcx,2), %rcx
movw %dx, -0x16(%rsi,%rcx,8)
movq 0x28(%r15), %r15
incl %ebp
addq $0x4, %r13
testq %r15, %r15
jne 0x472bed
testb %al, %al
sete %r14b
jmp 0x472cc2
movb $0x1, %r14b
movq 0x10(%rsp), %rax
testb $0x20, 0x40(%rax)
movq 0x30(%rsp), %r12
movl 0x80(%rsp), %r13d
jne 0x472de2
movq 0x28(%rsp), %rax
leal 0x1(%rax), %edx
movb 0x1f(%r12), %al
testb %al, %al
je 0x472d03
decb %al
movb %al, 0x1f(%r12)
movzbl %al, %eax
movl 0xc4(%r12,%rax,4), %ebp
jmp 0x472d0f
movl 0x38(%r12), %ebp
incl %ebp
movl %ebp, 0x38(%r12)
movl 0x78(%rsp), %r15d
movq 0x10(%rsp), %rax
movswl 0x46(%rax), %ecx
movq %rbx, %rdi
movl $0x66, %esi
movl %ebp, %r8d
callq 0x43bae0
testb %r14b, %r14b
je 0x472d41
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
xorl %edx, %edx
callq 0x454e05
movl 0x70(%rsp), %ecx
movl %ecx, %eax
orb $0x1, %al
testl %ecx, %ecx
movzbl %al, %eax
movl $0x21, %ecx
cmovnel %eax, %ecx
xorl %eax, %eax
cmpb $0x0, 0x1e(%r12)
cmovel %ecx, %eax
movl %eax, %ecx
orb $0x8, %cl
testl %r15d, %r15d
movzbl %cl, %ecx
cmovel %eax, %ecx
movl %ecx, %eax
orb $0x10, %al
testl %r13d, %r13d
movzbl %al, %r14d
cmovel %ecx, %r14d
movq %rbx, %rdi
movl $0x7a, %esi
movl 0x1c(%rsp), %edx
movl %ebp, %ecx
movq 0x28(%rsp), %r8
callq 0x43bae0
cmpb $0x0, 0x1e(%r12)
jne 0x472dc5
movq (%rbx), %rax
cmpb $0x0, 0x61(%rax)
jne 0x472dc5
movq 0x68(%rbx), %rax
movslq 0xb8(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $-0x6, -0x17(%rax,%rcx,8)
movq 0x10(%rsp), %rdx
movq %rdx, -0x8(%rax,%rcx,8)
movslq 0xb8(%rbx), %rax
testq %rax, %rax
jle 0x472de2
movzbl %r14b, %ecx
movq 0x68(%rbx), %rdx
leaq (%rax,%rax,2), %rax
movw %cx, -0x16(%rdx,%rax,8)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq