// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3CompleteInsertion
SQLITE_PRIVATE void sqlite3CompleteInsertion(
  Parse *pParse,      /* The parser context */
  Table *pTab,        /* the table into which we are inserting */
  int baseCur,        /* Index of a read/write cursor pointing at pTab */
  int regRowid,       /* 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 */
){
  int i;
  Vdbe *v;
  Index *pIdx;
  u8 pik_flags;
  int regData;
  int regRec;

  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, baseCur+i+1, aRegIdx[i]);
    if( useSeekResult ){
      sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
    }
  }
  regData = regRowid + 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, baseCur, regRec, regRowid);
  if( !pParse->nested ){
    sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);
  }
  sqlite3VdbeChangeP5(v, pik_flags);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, -0x2c(%rbp)
movq %r8, %r13
movq %rcx, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
movq %rsi, %r14
movq %rdi, %r15
callq 0x45ece
movq %rax, %rbx
movq %r14, -0x38(%rbp)
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x5f9fc
movq -0x40(%rbp), %rax
leal 0x1(%rax), %r12d
movl (%r13), %ecx
testl %ecx, %ecx
je 0x5f9ec
cmpq $0x0, 0x48(%r14)
je 0x5f9bd
movl 0x34(%rbx), %eax
addl $0x2, %eax
movq %rbx, %rdi
movl $0x49, %esi
movl %ecx, %edx
movl %eax, %ecx
xorl %r8d, %r8d
callq 0x45f15
movl (%r13), %ecx
movq %rbx, %rdi
movl $0x67, %esi
movl %r12d, %edx
xorl %r8d, %r8d
callq 0x45f15
cmpl $0x0, 0x18(%rbp)
je 0x5f9ec
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x5f9ec
movslq 0x34(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $0x10, -0x15(%rax,%rcx,8)
movq 0x28(%r14), %r14
addq $0x4, %r13
incl %r12d
testq %r14, %r14
jne 0x5f990
movq -0x48(%rbp), %rax
leal 0x1(%rax), %r14d
movq %r15, %r13
movb 0x1f(%r15), %al
testb %al, %al
je 0x5fa1f
decb %al
movb %al, 0x1f(%r13)
movzbl %al, %eax
movl 0x28(%r13,%rax,4), %r12d
jmp 0x5fa2a
movl 0x58(%r13), %r12d
incl %r12d
movl %r12d, 0x58(%r13)
movq -0x38(%rbp), %r15
movswl 0x42(%r15), %ecx
movq %rbx, %rdi
movl $0x2b, %esi
movl %r14d, %edx
movl %r12d, %r8d
callq 0x45f15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5ee06
movswl 0x42(%r15), %edx
movq %r13, %rdi
movl %r14d, %esi
callq 0x4e564
cmpl $0x0, -0x2c(%rbp)
setne %al
addb %al, %al
addb $0x3, %al
xorl %ecx, %ecx
cmpb $0x0, 0x1e(%r13)
movzbl %al, %eax
cmovnel %ecx, %eax
leal 0x8(%rax), %ecx
cmpl $0x0, 0x10(%rbp)
movzbl %cl, %ecx
cmovel %eax, %ecx
movl %ecx, %eax
orb $0x10, %al
cmpl $0x0, 0x18(%rbp)
movzbl %al, %r14d
cmovel %ecx, %r14d
movq %rbx, %rdi
movl $0x42, %esi
movq -0x40(%rbp), %rdx
movl %r12d, %ecx
movq -0x48(%rbp), %r8
callq 0x45f15
cmpb $0x0, 0x1e(%r13)
jne 0x5fac7
movq (%r15), %rdx
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x11a9f
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x5fadd
movslq 0x34(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movb %r14b, -0x15(%rax,%rcx,8)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq