// File: /workspace/github_c_makefile_star2_O1/ukontainer[P]sqlite-bench/sqlite3.c
// Function: updateVirtualTable
static void updateVirtualTable(
  Parse *pParse,       /* The parsing context */
  SrcList *pSrc,       /* The virtual table to be modified */
  Table *pTab,         /* The virtual table */
  ExprList *pChanges,  /* The columns to change in the UPDATE statement */
  Expr *pRowid,        /* Expression used to recompute the rowid */
  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */
  Expr *pWhere,        /* WHERE clause of the UPDATE statement */
  int onError          /* ON CONFLICT strategy */
){
  Vdbe *v = pParse->pVdbe;  /* Virtual machine under construction */
  int ephemTab;             /* Table holding the result of the SELECT */
  int i;                    /* Loop counter */
  sqlite3 *db = pParse->db; /* Database connection */
  const char *pVTab = (const char*)sqlite3GetVTable(db, pTab);
  WhereInfo *pWInfo;
  int nArg = 2 + pTab->nCol;      /* Number of arguments to VUpdate */
  int regArg;                     /* First register in VUpdate arg array */
  int regRec;                     /* Register in which to assemble record */
  int regRowid;                   /* Register for ephem table rowid */
  int iCsr = pSrc->a[0].iCursor;  /* Cursor used for virtual table scan */
  int aDummy[2];                  /* Unused arg for sqlite3WhereOkOnePass() */
  int eOnePass;                   /* True to use onepass strategy */
  int addr;                       /* Address of OP_OpenEphemeral */

  /* Allocate nArg registers in which to gather the arguments for VUpdate. Then
  ** create and open the ephemeral table in which the records created from
  ** these arguments will be temporarily stored. */
  assert( v );
  ephemTab = pParse->nTab++;
  addr= sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, nArg);
  regArg = pParse->nMem + 1;
  pParse->nMem += nArg;
  regRec = ++pParse->nMem;
  regRowid = ++pParse->nMem;

  /* Start scanning the virtual table */
  pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0,0,WHERE_ONEPASS_DESIRED,0);
  if( pWInfo==0 ) return;

  /* Populate the argument registers. */
  for(i=0; i<pTab->nCol; i++){
    if( aXRef[i]>=0 ){
      sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);
    }else{
      sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);
      sqlite3VdbeChangeP5(v, 1); /* Enable sqlite3_vtab_nochange() */
    }
  }
  if( HasRowid(pTab) ){
    sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg);
    if( pRowid ){
      sqlite3ExprCode(pParse, pRowid, regArg+1);
    }else{
      sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg+1);
    }
  }else{
    Index *pPk;   /* PRIMARY KEY index */
    i16 iPk;      /* PRIMARY KEY column */
    pPk = sqlite3PrimaryKeyIndex(pTab);
    assert( pPk!=0 );
    assert( pPk->nKeyCol==1 );
    iPk = pPk->aiColumn[0];
    sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, iPk, regArg);
    sqlite3VdbeAddOp2(v, OP_SCopy, regArg+2+iPk, regArg+1);
  }

  eOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy);

  /* There is no ONEPASS_MULTI on virtual tables */
  assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );

  if( eOnePass ){
    /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded
    ** above. */
    sqlite3VdbeChangeToNoop(v, addr);
    sqlite3VdbeAddOp1(v, OP_Close, iCsr);
  }else{
    /* Create a record from the argument register contents and insert it into
    ** the ephemeral table. */
    sqlite3MultiWrite(pParse);
    sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec);
#ifdef SQLITE_DEBUG
    /* Signal an assert() within OP_MakeRecord that it is allowed to
    ** accept no-change records with serial_type 10 */
    sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG_MAGIC);
#endif
    sqlite3VdbeAddOp2(v, OP_NewRowid, ephemTab, regRowid);
    sqlite3VdbeAddOp3(v, OP_Insert, ephemTab, regRec, regRowid);
  }


  if( eOnePass==ONEPASS_OFF ){
    /* End the virtual table scan */
    sqlite3WhereEnd(pWInfo);

    /* Begin scannning through the ephemeral table. */
    addr = sqlite3VdbeAddOp1(v, OP_Rewind, ephemTab); VdbeCoverage(v);

    /* Extract arguments from the current row of the ephemeral table and 
    ** invoke the VUpdate method.  */
    for(i=0; i<nArg; i++){
      sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i, regArg+i);
    }
  }
  sqlite3VtabMakeWritable(pParse, pTab);
  sqlite3VdbeAddOp4(v, OP_VUpdate, 0, nArg, regArg, pVTab, P4_VTAB);
  sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);
  sqlite3MayAbort(pParse);

  /* End of the ephemeral table scan. Or, if using the onepass strategy,
  ** jump to here if the scan visited zero rows. */
  if( eOnePass==ONEPASS_OFF ){
    sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr+1); VdbeCoverage(v);
    sqlite3VdbeJumpHere(v, addr);
    sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0);
  }else{
    sqlite3WhereEnd(pWInfo);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %rbp
movq %rcx, %r14
movq %rdi, %r13
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rdi), %rax
movq 0x60(%rdx), %r12
testq %r12, %r12
movq %rax, 0x58(%rsp)
je 0x4715c3
movq (%r13), %rax
cmpq %rax, (%r12)
je 0x4715c3
movq 0x28(%r12), %r12
testq %r12, %r12
jne 0x4715b3
movq %r8, 0x60(%rsp)
movl 0xa8(%rsp), %eax
movl %eax, 0x4c(%rsp)
movswl 0x46(%rdx), %ebx
leal 0x2(%rbx), %ecx
movl 0x48(%rsi), %eax
movl %eax, 0xc(%rsp)
movl 0x34(%r13), %r15d
leal 0x1(%r15), %eax
movl %eax, 0x34(%r13)
movq 0x58(%rsp), %rdi
movq %rsi, 0x20(%rsp)
movl $0x71, %esi
movq %rdx, 0x28(%rsp)
movl %r15d, %edx
movl %ecx, 0x1c(%rsp)
xorl %r8d, %r8d
callq 0x43bae0
movq %rax, 0x38(%rsp)
movl 0x38(%r13), %eax
movq %rbx, 0x50(%rsp)
movq %rax, 0x40(%rsp)
leal 0x4(%rax,%rbx), %ebx
movl %ebx, 0x38(%r13)
movl $0x0, (%rsp)
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x4, %r9d
callq 0x45dbbf
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x47173a
movl %ebx, 0x48(%rsp)
movq %r13, 0x10(%rsp)
movq %r15, 0x30(%rsp)
movq 0x28(%rsp), %rcx
cmpw $0x0, 0x46(%rcx)
movq 0x58(%rsp), %rbx
jle 0x4716f3
movq 0x40(%rsp), %rax
leal 0x3(%rax), %r13d
addq $0x8, %r14
xorl %r15d, %r15d
movslq (%rbp,%r15,4), %rax
testq %rax, %rax
js 0x4716ae
shlq $0x5, %rax
movq (%r14,%rax), %rsi
leal (%r15,%r13), %edx
movq 0x10(%rsp), %rdi
callq 0x44ea56
jmp 0x4716e1
leal (%r15,%r13), %r8d
movq %rbx, %rdi
movl $0xa5, %esi
movl 0xc(%rsp), %edx
movl %r15d, %ecx
callq 0x43bae0
movslq 0xb8(%rbx), %rax
testq %rax, %rax
jle 0x4716e1
movq 0x68(%rbx), %rcx
leaq (%rax,%rax,2), %rax
movw $0x1, -0x16(%rcx,%rax,8)
incq %r15
movq 0x28(%rsp), %rcx
movswq 0x46(%rcx), %rax
cmpq %rax, %r15
jl 0x47168c
movq 0x40(%rsp), %r14
leal 0x1(%r14), %ebp
testb $0x20, 0x40(%rcx)
jne 0x471749
movq %rbx, %rdi
movl $0x81, %esi
movl 0xc(%rsp), %r15d
movl %r15d, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movl %r14d, %ecx
addl $0x2, %ecx
movq 0x60(%rsp), %rsi
testq %rsi, %rsi
movq 0x10(%rsp), %rdi
je 0x471774
movl %ecx, %edx
callq 0x44ea56
jmp 0x471787
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rcx), %rax
testq %rax, %rax
movl 0xc(%rsp), %r15d
je 0x47178e
movq 0x30(%rsp), %r13
movzwl 0x63(%rax), %ecx
andl $0x3, %ecx
cmpw $0x2, %cx
je 0x471793
movq 0x28(%rax), %rax
testq %rax, %rax
jne 0x47175c
jmp 0x471793
movq %rbx, %rdi
movl $0x81, %esi
movl %r15d, %edx
xorl %r8d, %r8d
callq 0x43bae0
movq 0x30(%rsp), %r13
jmp 0x4717d6
movq 0x30(%rsp), %r13
movq 0x8(%rax), %rax
movswl (%rax), %r14d
movq %rbx, %rdi
movl $0xa5, %esi
movl %r15d, %edx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x43bae0
movq 0x40(%rsp), %rax
leal (%rax,%r14), %edx
addl $0x3, %edx
movq %rax, %r14
movl %r14d, %ecx
addl $0x2, %ecx
movq %rbx, %rdi
movl $0x4f, %esi
xorl %r8d, %r8d
callq 0x43bae0
movq 0x20(%rsp), %rax
movb 0x45(%rax), %al
movb %al, 0xc(%rsp)
testb %al, %al
je 0x471805
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
callq 0x453d19
movq %rbx, %rdi
movl $0x75, %esi
movl %r15d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
jmp 0x47186a
movq 0x50(%rsp), %rax
addl %eax, %r14d
addl $0x3, %r14d
movq 0x10(%rsp), %rcx
movq 0xa0(%rcx), %rax
testq %rax, %rax
cmoveq %rcx, %rax
movb $0x1, 0x20(%rax)
movq %rbx, %rdi
movl $0x66, %esi
movl %ebp, %edx
movl 0x1c(%rsp), %ecx
movl %r14d, %r8d
callq 0x43bae0
movq %rbx, %rdi
movl $0x79, %esi
movl %r13d, %edx
movl 0x48(%rsp), %r15d
movl %r15d, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movq %rbx, %rdi
movl $0x7a, %esi
movl %r13d, %edx
movl %r14d, %ecx
movl %r15d, %r8d
callq 0x43bae0
movb 0xc(%rsp), %r15b
testb %r15b, %r15b
movq 0x28(%rsp), %rsi
jne 0x4718e2
movq 0x20(%rsp), %rdi
callq 0x460b22
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x24, %esi
movl %r13d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movq %rax, 0x38(%rsp)
cmpw $-0x1, 0x50(%rsp)
jl 0x4718dd
movl 0x1c(%rsp), %r15d
leal (%r14,%rbp), %r8d
movq %rbx, %rdi
movl $0x5a, %esi
movl %r13d, %edx
movl %r14d, %ecx
callq 0x43bae0
incl %r14d
cmpl %r14d, %r15d
jne 0x4718b2
movq 0x28(%rsp), %rsi
movb 0xc(%rsp), %r15b
jmp 0x4718e2
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x46e86e
movq %rbx, %rdi
movl $0xa, %esi
xorl %edx, %edx
movl 0x1c(%rsp), %ecx
movl %ebp, %r8d
callq 0x43bae0
movq %rbx, %rdi
movl %eax, %esi
movq %r12, %rdx
movl $0xfffffff4, %ecx       # imm = 0xFFFFFFF4
callq 0x40e507
movslq 0xb8(%rbx), %rax
testq %rax, %rax
jle 0x47193c
movl 0x4c(%rsp), %edx
cmpl $0xb, %edx
movl $0x2, %ecx
cmovnel %edx, %ecx
movq 0x68(%rbx), %rdx
leaq (%rax,%rax,2), %rax
movw %cx, -0x16(%rdx,%rax,8)
movq 0x10(%rsp), %rcx
movq 0xa0(%rcx), %rax
testq %rax, %rax
cmoveq %rcx, %rax
movb $0x1, 0x21(%rax)
testb %r15b, %r15b
je 0x471970
movq 0x20(%rsp), %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x460b22
movq 0x38(%rsp), %r14
leal 0x1(%r14), %ecx
movq %rbx, %rdi
movl $0x5, %esi
movl %r13d, %edx
xorl %r8d, %r8d
callq 0x43bae0
movl 0xb8(%rbx), %eax
movq (%rbx), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x4719a4
leaq 0x133466(%rip), %rcx    # 0x5a4e08
jmp 0x4719bd
leal -0x1(%rax), %ecx
testl %r14d, %r14d
cmovnsl %r14d, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x68(%rbx), %rcx
movl %eax, 0x8(%rcx)
movq %rbx, %rdi
movl $0x75, %esi
movl %r13d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x43bae0