// File: /workspace/github_c_makefile_star2_O1/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, -0x34(%rbp)
movq %r8, %r13
movq %rcx, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
movq %rsi, %r14
movq %rdi, %r15
callq 0x45b57
movq %rax, %rbx
movq %r14, -0x30(%rbp)
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x5fb45
movq -0x40(%rbp), %rax
leal 0x1(%rax), %r12d
movl (%r13), %edx
testl %edx, %edx
je 0x5fb35
cmpq $0x0, 0x48(%r14)
je 0x5fb02
movl 0x34(%rbx), %ecx
addl $0x2, %ecx
movq %rbx, %rdi
movl $0x49, %esi
xorl %r8d, %r8d
callq 0x45b9e
movl (%r13), %ecx
movq %rbx, %rdi
movl $0x67, %esi
movl %r12d, %edx
xorl %r8d, %r8d
callq 0x45b9e
cmpl $0x0, 0x18(%rbp)
je 0x5fb35
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x5fb35
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 0x5fadd
movq -0x48(%rbp), %rax
leal 0x1(%rax), %r13d
movb 0x1f(%r15), %al
testb %al, %al
je 0x5fb65
decb %al
movb %al, 0x1f(%r15)
movzbl %al, %eax
movl 0x28(%r15,%rax,4), %r12d
jmp 0x5fb70
movl 0x58(%r15), %r12d
incl %r12d
movl %r12d, 0x58(%r15)
movq -0x30(%rbp), %r14
movswl 0x42(%r14), %ecx
movq %rbx, %rdi
movl $0x2b, %esi
movl %r13d, %edx
movl %r12d, %r8d
callq 0x45b9e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5ef59
movswl 0x42(%r14), %edx
movq %r15, %rdi
movl %r13d, %esi
callq 0x4e50d
cmpl $0x0, -0x34(%rbp)
setne %al
addb %al, %al
addb $0x3, %al
xorl %ecx, %ecx
cmpb $0x0, 0x1e(%r15)
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 0x45b9e
cmpb $0x0, 0x1e(%r15)
jne 0x5fc11
movq -0x30(%rbp), %rax
movq (%rax), %rdx
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x11975
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x5fc27
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