// File: /workspace/github_c_makefile_star2_O3/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), %rcx
movq 0x60(%rdx), %r12
testq %r12, %r12
movq %rcx, 0x58(%rsp)
movq %r8, 0x60(%rsp)
je 0x470ea3
movq (%r13), %rax
cmpq %rax, (%r12)
je 0x470ea6
movq 0x28(%r12), %r12
testq %r12, %r12
jne 0x470e93
xorl %r12d, %r12d
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, 0x18(%rsp)
movl $0x71, %esi
movq %rdx, 0x40(%rsp)
movl %r15d, %edx
movl %ecx, 0x24(%rsp)
xorl %r8d, %r8d
callq 0x43a65f
movq %rax, 0x30(%rsp)
movl 0x38(%r13), %eax
movq %rbx, 0x50(%rsp)
movq %rax, 0x38(%rsp)
leal 0x4(%rax,%rbx), %ebx
movl %ebx, 0x38(%r13)
movl $0x0, (%rsp)
movq %r13, 0x28(%rsp)
movq %r13, %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x4, %r9d
callq 0x45cf2f
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x47101b
movl %ebx, 0x48(%rsp)
movq %r15, 0x18(%rsp)
movq 0x40(%rsp), %rcx
cmpw $0x0, 0x46(%rcx)
movq 0x58(%rsp), %rbx
jle 0x470fd1
movq 0x38(%rsp), %rax
leal 0x3(%rax), %r13d
addq $0x8, %r14
xorl %r15d, %r15d
movslq (%rbp,%r15,4), %rax
testq %rax, %rax
js 0x470f8c
shlq $0x5, %rax
movq (%r14,%rax), %rsi
leal (%r15,%r13), %edx
movq 0x28(%rsp), %rdi
callq 0x44dd91
jmp 0x470fbf
leal (%r15,%r13), %r8d
movq %rbx, %rdi
movl $0xa5, %esi
movl 0xc(%rsp), %edx
movl %r15d, %ecx
callq 0x43a65f
movslq 0xb8(%rbx), %rax
testq %rax, %rax
jle 0x470fbf
movq 0x68(%rbx), %rcx
leaq (%rax,%rax,2), %rax
movw $0x1, -0x16(%rcx,%rax,8)
incq %r15
movq 0x40(%rsp), %rcx
movswq 0x46(%rcx), %rax
cmpq %rax, %r15
jl 0x470f6a
movq 0x38(%rsp), %r13
leal 0x1(%r13), %ebp
testb $0x20, 0x40(%rcx)
jne 0x47102a
movq %rbx, %rdi
movl $0x81, %esi
movl 0xc(%rsp), %r14d
movl %r14d, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movl %r13d, %ecx
addl $0x2, %ecx
movq 0x60(%rsp), %rsi
testq %rsi, %rsi
movq 0x28(%rsp), %r15
je 0x47107d
movq %r15, %rdi
movl %ecx, %edx
callq 0x44dd91
jmp 0x471090
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x10, %rcx
movq 0x28(%rsp), %r15
movq (%rcx), %rax
movzwl 0x63(%rax), %edx
andl $0x3, %edx
leaq 0x28(%rax), %rcx
cmpw $0x2, %dx
jne 0x471033
movq 0x8(%rax), %rax
movswl (%rax), %r14d
movq %rbx, %rdi
movl $0xa5, %esi
movl 0xc(%rsp), %edx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x43a65f
leal (%r14,%r13), %edx
addl $0x3, %edx
movl %r13d, %ecx
addl $0x2, %ecx
movq %rbx, %rdi
movl $0x4f, %esi
jmp 0x471088
movq %rbx, %rdi
movl $0x81, %esi
movl %r14d, %edx
xorl %r8d, %r8d
callq 0x43a65f
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %r14
movb 0x45(%r14), %al
movb %al, 0x18(%rsp)
testb %al, %al
je 0x4710ce
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0x452f7b
movq %rbx, %rdi
movl $0x75, %esi
movl 0xc(%rsp), %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43a65f
jmp 0x471199
movq 0x38(%rsp), %rax
movq 0x50(%rsp), %rdx
leal (%rax,%rdx), %r8d
addl $0x3, %r8d
movl %r8d, 0xc(%rsp)
movq 0xa0(%r15), %rax
testq %rax, %rax
cmoveq %r15, %rax
movb $0x1, 0x20(%rax)
movq %rbx, %rdi
movl $0x66, %esi
movl %ebp, %edx
movl 0x24(%rsp), %ecx
callq 0x43a65f
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x79, %esi
movl %r13d, %edx
movl 0x48(%rsp), %r15d
movl %r15d, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movq %rbx, %rdi
movl $0x7a, %esi
movl %r13d, %edx
movl 0xc(%rsp), %ecx
movl %r15d, %r8d
callq 0x43a65f
movq 0x10(%rsp), %rdi
callq 0x45fe68
movq %rbx, %rdi
movl $0x24, %esi
movl %r13d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movq %rax, 0x30(%rsp)
cmpw $-0x1, 0x50(%rsp)
jl 0x47118f
movl 0x24(%rsp), %r15d
leal (%r14,%rbp), %r8d
movq %rbx, %rdi
movl $0x5a, %esi
movl %r13d, %edx
movl %r14d, %ecx
callq 0x43a65f
incl %r14d
cmpl %r14d, %r15d
jne 0x471170
movq 0x28(%rsp), %r15
movq 0x10(%rsp), %r14
movq %r15, %rdi
movq 0x40(%rsp), %rsi
callq 0x46e106
movq %rbx, %rdi
movl $0xa, %esi
xorl %edx, %edx
movl 0x24(%rsp), %ecx
movl %ebp, %r8d
callq 0x43a65f
movq %rbx, %rdi
movl %eax, %esi
movq %r12, %rdx
movl $0xfffffff4, %ecx       # imm = 0xFFFFFFF4
callq 0x40e765
movslq 0xb8(%rbx), %rax
testq %rax, %rax
jle 0x4711f6
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 0xa0(%r15), %rax
testq %rax, %rax
cmoveq %r15, %rax
movb $0x1, 0x21(%rax)
cmpb $0x0, 0x18(%rsp)
je 0x471225
movq %r14, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x45fe68
movq 0x30(%rsp), %r14
leal 0x1(%r14), %ecx
movq %rbx, %rdi
movl $0x5, %esi
movl %r13d, %edx
xorl %r8d, %r8d
callq 0x43a65f
movl 0xb8(%rbx), %eax
movq (%rbx), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x471259
leaq 0x133bb1(%rip), %rcx    # 0x5a4e08
jmp 0x471272
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 0x43a65f