// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq %r9, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4299d0
movq %rax, -0x30(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x46048c
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x460355
jmp 0x460472
movq -0x38(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x460395
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movq -0x30(%rbp), %rdi
callq 0x430ae0
movq -0x50(%rbp), %rdi
movl -0x44(%rbp), %edx
movl %eax, %ecx
addl $0x2, %ecx
movl $0x32, %esi
callq 0x410100
movl 0x20(%rbp), %edx
xorl %eax, %eax
movl $0x10, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, -0x39(%rbp)
movq -0x38(%rbp), %rax
movw 0x63(%rax), %ax
andw $0x3, %ax
movzwl %ax, %eax
cmpl $0x2, %eax
jne 0x4603e6
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x4603e6
movzbl -0x39(%rbp), %eax
orl $0x1, %eax
movb %al, -0x39(%rbp)
movl 0x10(%rbp), %ecx
andl $0x2, %ecx
movzbl -0x39(%rbp), %eax
orl %ecx, %eax
movb %al, -0x39(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x18(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x38(%rbp), %rax
movw 0x63(%rax), %ax
shrw $0x3, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x46043b
movq -0x38(%rbp), %rax
movzwl 0x5e(%rax), %eax
movl %eax, -0x6c(%rbp)
jmp 0x460446
movq -0x38(%rbp), %rax
movzwl 0x60(%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x54(%rbp), %r8d
movl -0x58(%rbp), %ecx
movl -0x5c(%rbp), %edx
movq -0x68(%rbp), %rdi
movl -0x6c(%rbp), %r9d
movl $0x82, %esi
callq 0x3cb970
movq -0x30(%rbp), %rdi
movzbl -0x39(%rbp), %eax
movzwl %ax, %esi
callq 0x3cb9f0
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x460337
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x4604a2
jmp 0x460546
movq -0x8(%rbp), %rax
cmpb $0x0, 0x1e(%rax)
je 0x4604b2
movb $0x0, -0x39(%rbp)
jmp 0x4604da
movb $0x1, -0x39(%rbp)
cmpl $0x0, 0x10(%rbp)
je 0x4604c4
movl 0x10(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x4604ce
movl $0x20, %eax
movl %eax, -0x70(%rbp)
jmp 0x4604ce
movl -0x70(%rbp), %ecx
movzbl -0x39(%rbp), %eax
orl %ecx, %eax
movb %al, -0x39(%rbp)
cmpl $0x0, 0x18(%rbp)
je 0x4604ea
movzbl -0x39(%rbp), %eax
orl $0x8, %eax
movb %al, -0x39(%rbp)
cmpl $0x0, 0x20(%rbp)
je 0x4604fa
movzbl -0x39(%rbp), %eax
orl $0x10, %eax
movb %al, -0x39(%rbp)
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %edx
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movl -0x1c(%rbp), %r8d
movl $0x79, %esi
callq 0x410130
movq -0x8(%rbp), %rax
cmpb $0x0, 0x1e(%rax)
jne 0x460536
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0xfffffffa, %edx       # imm = 0xFFFFFFFA
callq 0x42a320
movq -0x30(%rbp), %rdi
movzbl -0x39(%rbp), %eax
movzwl %ax, %esi
callq 0x3cb9f0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)