// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/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 i;              /* Loop counter */

  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++){
    /* All REPLACE indexes are at the end of the list */
    assert( pIdx->onError!=OE_Replace
         || pIdx->pNext==0
         || pIdx->pNext->onError==OE_Replace );
    if( aRegIdx[i]==0 ) continue;
    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 ){
        int r = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp2(v, OP_Integer, 0, r);
        sqlite3VdbeAddOp4(v, OP_Insert,
            iIdxCur+i, aRegIdx[i], r, (char*)pTab, P4_TABLE
        );
        sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP);
        sqlite3ReleaseTempReg(pParse, r);
      }
#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;
  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, aRegIdx[i], 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
movl %r8d, 0x1c(%rsp)
movl %ecx, %ebp
movl %edx, 0x18(%rsp)
movq %rsi, %r14
movl 0x70(%rsp), %r15d
movq %rdi, 0x28(%rsp)
callq 0x2bc630
movq %rax, %rbx
movq %r14, 0x10(%rsp)
movq 0x10(%r14), %r12
testq %r12, %r12
je 0x2e5ea0
cmpl $0x0, 0x80(%rsp)
setne %cl
shlb $0x4, %cl
movl %r15d, %eax
andb $0x2, %al
orb %cl, %al
incb %al
movl %ebp, %edx
movq %rdx, 0x30(%rsp)
xorl %ebp, %ebp
movb %cl, 0xf(%rsp)
movzbl %cl, %ecx
movl %ecx, 0x24(%rsp)
movzbl %al, %eax
movl %eax, 0x20(%rsp)
movl (%r13,%rbp,4), %edx
testl %edx, %edx
je 0x2e5e8b
cmpq $0x0, 0x48(%r12)
je 0x2e5df4
movl 0x90(%rbx), %ecx
addl $0x2, %ecx
movq %rbx, %rdi
movl $0x32, %esi
xorl %r8d, %r8d
callq 0x2a83e1
movzwl 0x63(%r12), %eax
movl %eax, %ecx
andl $0x3, %ecx
movb 0xf(%rsp), %dl
movl %edx, %r14d
cmpw $0x2, %cx
jne 0x2e5e20
movq 0x10(%rsp), %rcx
testb $-0x80, 0x40(%rcx)
movl 0x20(%rsp), %r14d
cmovel 0x24(%rsp), %r14d
movl (%r13,%rbp,4), %ecx
leal 0x1(%rcx), %r8d
xorl %edx, %edx
testb $0x8, %al
sete %dl
movzwl 0x5e(%r12,%rdx,2), %r15d
movq 0x30(%rsp), %rax
leal (%rax,%rbp), %edx
movq %rbx, %rdi
movl $0x82, %esi
callq 0x2a83e1
movq (%rbx), %rcx
cmpb $0x0, 0x61(%rcx)
jne 0x2e5e6b
movq 0x88(%rbx), %rcx
cltq
leaq (%rax,%rax,2), %rax
movb $-0x3, 0x1(%rcx,%rax,8)
movl %r15d, 0x10(%rcx,%rax,8)
movslq 0x90(%rbx), %rax
testq %rax, %rax
jle 0x2e5e8b
movzbl %r14b, %ecx
movq 0x88(%rbx), %rdx
leaq (%rax,%rax,2), %rax
movw %cx, -0x16(%rdx,%rax,8)
incq %rbp
movq 0x28(%r12), %r12
testq %r12, %r12
jne 0x2e5dc6
movl %ebp, %eax
jmp 0x2e5ea2
xorl %eax, %eax
movq 0x10(%rsp), %rcx
testb $-0x80, 0x40(%rcx)
movl 0x80(%rsp), %esi
movl 0x70(%rsp), %edx
jne 0x2e5f66
movl %edx, %ecx
orb $0x1, %cl
testl %edx, %edx
movzbl %cl, %ecx
movl $0x21, %edx
cmovnel %ecx, %edx
xorl %ecx, %ecx
movq 0x28(%rsp), %r14
cmpb $0x0, 0x1e(%r14)
cmovel %edx, %ecx
movl %ecx, %edx
orb $0x8, %dl
cmpl $0x0, 0x78(%rsp)
movzbl %dl, %edx
cmovel %ecx, %edx
movl %edx, %ecx
orb $0x10, %cl
testl %esi, %esi
movzbl %cl, %ebp
cmovel %edx, %ebp
movl (%r13,%rax,4), %ecx
movq %rbx, %rdi
movl $0x79, %esi
movl 0x18(%rsp), %edx
movl 0x1c(%rsp), %r8d
callq 0x2a83e1
cmpb $0x0, 0x1e(%r14)
jne 0x2e5f46
movq (%rbx), %rax
cmpb $0x0, 0x61(%rax)
jne 0x2e5f46
movq 0x88(%rbx), %rax
movslq 0x90(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $-0x6, -0x17(%rax,%rcx,8)
movq 0x10(%rsp), %rdx
movq %rdx, -0x8(%rax,%rcx,8)
movslq 0x90(%rbx), %rax
testq %rax, %rax
jle 0x2e5f66
movzbl %bpl, %ecx
movq 0x88(%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