// File: /workspace/github_c_makefile_star2_O1/skeeto[P]flappy/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 isUpdate,       /* 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 assemblied record for the table */
  int i;              /* Loop counter */

  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;
    if( pIdx->pPartIdxWhere ){
      sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
    }
    sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i]);
    pik_flags = 0;
    if( useSeekResult ) pik_flags = OPFLAG_USESEEKRESULT;
    if( pIdx->autoIndex==2 && !HasRowid(pTab) ){
      assert( pParse->nested==0 );
      pik_flags |= OPFLAG_NCHANGE;
    }
    if( pik_flags )  sqlite3VdbeChangeP5(v, pik_flags);
  }
  if( !HasRowid(pTab) ) return;
  regData = regNewData + 1;
  regRec = sqlite3GetTempReg(pParse);
  sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);
  sqlite3TableAffinityStr(v, pTab);
  sqlite3ExprCacheAffinityChange(pParse, regData, pTab->nCol);
  if( pParse->nested ){
    pik_flags = 0;
  }else{
    pik_flags = OPFLAG_NCHANGE;
    pik_flags |= (isUpdate?OPFLAG_ISUPDATE:OPFLAG_LASTROWID);
  }
  if( appendBias ){
    pik_flags |= OPFLAG_APPEND;
  }
  if( useSeekResult ){
    pik_flags |= OPFLAG_USESEEKRESULT;
  }
  sqlite3VdbeAddOp3(v, OP_Insert, iDataCur, regRec, regNewData);
  if( !pParse->nested ){
    sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);
  }
  sqlite3VdbeChangeP5(v, pik_flags);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r13
movq %r8, 0x8(%rsp)
movl %ecx, %ebp
movl %edx, 0x4(%rsp)
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
callq 0x47f6a
movq %rax, %rbx
movq 0x10(%r14), %r15
testq %r15, %r15
je 0x633f1
cmpl $0x0, 0x60(%rsp)
setne %r12b
shlb $0x4, %r12b
movl (%r13), %edx
testl %edx, %edx
je 0x633e2
cmpq $0x0, 0x48(%r15)
je 0x63398
movl 0x34(%rbx), %ecx
addl $0x2, %ecx
movq %rbx, %rdi
movl $0x4a, %esi
xorl %r8d, %r8d
callq 0x47fb1
movl (%r13), %ecx
movq %rbx, %rdi
movl $0x69, %esi
movl %ebp, %edx
xorl %r8d, %r8d
callq 0x47fb1
movb 0x63(%r15), %cl
andb $0x3, %cl
movl %r12d, %eax
cmpb $0x2, %cl
jne 0x633c9
movb 0x48(%r14), %al
shrb $0x5, %al
andb $0x1, %al
orb %r12b, %al
testb %al, %al
je 0x633e2
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
je 0x633e2
movslq 0x34(%rbx), %rdx
leaq (%rdx,%rdx,2), %rdx
movb %al, -0x15(%rcx,%rdx,8)
movq 0x28(%r15), %r15
incl %ebp
addq $0x4, %r13
testq %r15, %r15
jne 0x63373
testb $0x20, 0x48(%r14)
jne 0x634e7
movl 0x50(%rsp), %r15d
movq 0x8(%rsp), %rax
leal 0x1(%rax), %r13d
movq 0x10(%rsp), %r12
movb 0x1f(%r12), %al
testb %al, %al
je 0x63429
decb %al
movb %al, 0x1f(%r12)
movzbl %al, %eax
movl 0x28(%r12,%rax,4), %ebp
jmp 0x63435
movl 0x58(%r12), %ebp
incl %ebp
movl %ebp, 0x58(%r12)
movswl 0x42(%r14), %ecx
movq %rbx, %rdi
movl $0x2d, %esi
movl %r13d, %edx
movl %ebp, %r8d
callq 0x47fb1
movq %rbx, %rdi
movq %r14, %rsi
callq 0x625b6
movswl 0x42(%r14), %edx
movq %r12, %rdi
movl %r13d, %esi
callq 0x49d08
testl %r15d, %r15d
setne %al
addb %al, %al
addb $0x3, %al
xorl %ecx, %ecx
cmpb $0x0, 0x1e(%r12)
movzbl %al, %eax
cmovnel %ecx, %eax
leal 0x8(%rax), %ecx
cmpl $0x0, 0x58(%rsp)
movzbl %cl, %ecx
cmovel %eax, %ecx
movl %ecx, %eax
orb $0x10, %al
cmpl $0x0, 0x60(%rsp)
movzbl %al, %r15d
cmovel %ecx, %r15d
movq %rbx, %rdi
movl $0x44, %esi
movl 0x4(%rsp), %edx
movl %ebp, %ecx
movq 0x8(%rsp), %r8
callq 0x47fb1
cmpb $0x0, 0x1e(%r12)
jne 0x634d1
movq (%r14), %rdx
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x11ea3
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x634e7
movslq 0x34(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movb %r15b, -0x15(%rax,%rcx,8)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq