// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %r9, %r13
movl %r8d, 0x14(%rsp)
movl %ecx, 0x8(%rsp)
movl %edx, 0x10(%rsp)
movq %rsi, %r14
cmpl $0x0, 0x70(%rsp)
setne %r15b
movl 0x60(%rsp), %r12d
movq %rdi, 0x20(%rsp)
callq 0x2645be
movq %rax, %rbx
movq %r14, (%rsp)
leaq 0x10(%r14), %rbp
shlb $0x4, %r15b
movl %r12d, %eax
andb $0x2, %al
orb %r15b, %al
incb %al
movl 0x8(%rsp), %ecx
movq %rcx, 0x8(%rsp)
xorl %r12d, %r12d
movzbl %r15b, %ecx
movl %ecx, 0x1c(%rsp)
movzbl %al, %eax
movl %eax, 0x18(%rsp)
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x282d29
movl (%r13,%r12,4), %edx
testl %edx, %edx
je 0x282d1d
cmpq $0x0, 0x48(%rbp)
je 0x282cac
movl 0x90(%rbx), %ecx
addl $0x2, %ecx
movq %rbx, %rdi
pushq $0x32
popq %rsi
callq 0x24d51a
movzwl 0x63(%rbp), %eax
movl %eax, %ecx
andl $0x3, %ecx
movl %r15d, %r14d
cmpw $0x2, %cx
jne 0x282cd1
movq (%rsp), %rcx
testb $-0x80, 0x40(%rcx)
movl 0x18(%rsp), %r14d
cmovel 0x1c(%rsp), %r14d
movl (%r13,%r12,4), %ecx
leal 0x1(%rcx), %r8d
xorl %edx, %edx
testb $0x8, %al
sete %dl
movzwl 0x5e(%rbp,%rdx,2), %r9d
movq 0x8(%rsp), %rax
leal (%rax,%r12), %edx
movq %rbx, %rdi
movl $0x82, %esi
callq 0x226fc2
movslq 0x90(%rbx), %rax
testq %rax, %rax
jle 0x282d1d
movzbl %r14b, %ecx
movq 0x88(%rbx), %rdx
imulq $0x18, %rax, %rax
movw %cx, -0x16(%rdx,%rax)
addq $0x28, %rbp
incq %r12
jmp 0x282c77
movq (%rsp), %rax
testb $-0x80, 0x40(%rax)
jne 0x282dca
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 0x20(%rsp), %r14
cmpb $0x0, 0x1e(%r14)
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, %ebp
cmovel %ecx, %ebp
movl %r12d, %eax
movl (%r13,%rax,4), %ecx
pushq $0x79
popq %rsi
movq %rbx, %rdi
movl 0x10(%rsp), %edx
movl 0x14(%rsp), %r8d
callq 0x24d51f
cmpb $0x0, 0x1e(%r14)
jne 0x282daa
pushq $-0x6
popq %rdx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x26495f
movslq 0x90(%rbx), %rax
testq %rax, %rax
jle 0x282dca
movzbl %bpl, %ecx
movq 0x88(%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