// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x452890
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movswl 0x46(%rax), %eax
addl $0x2, %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x6c(%rbp)
movq -0x8(%rbp), %rcx
movl 0x34(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x34(%rcx)
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x5c(%rbp), %ecx
movl $0x71, %esi
callq 0x453790
movl %eax, -0x7c(%rbp)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x38(%rcx)
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x38(%rcx)
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq 0x10(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
movl $0x4, %r9d
xorl %eax, %eax
movq %r8, %rcx
movl $0x0, (%rsp)
callq 0x480140
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x49ae15
jmp 0x49b0fd
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x18(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jge 0x49aea9
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x49ae6b
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq -0x30(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x60(%rbp), %edx
addl $0x2, %edx
addl -0x40(%rbp), %edx
callq 0x46be40
jmp 0x49ae99
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movl -0x40(%rbp), %ecx
movl -0x60(%rbp), %r8d
addl $0x2, %r8d
addl -0x40(%rbp), %r8d
movl $0xa5, %esi
callq 0x4537c0
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x411430
jmp 0x49ae9b
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x49ae1c
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0x49af01
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movl -0x60(%rbp), %ecx
movl $0x81, %esi
callq 0x453790
cmpq $0x0, -0x28(%rbp)
je 0x49aee8
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x60(%rbp), %edx
addl $0x1, %edx
callq 0x46be40
jmp 0x49aeff
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
movl $0x81, %esi
callq 0x453790
jmp 0x49af65
movq -0x18(%rbp), %rdi
callq 0x414850
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movw (%rax), %ax
movw %ax, -0x8a(%rbp)
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movswl -0x8a(%rbp), %ecx
movl -0x60(%rbp), %r8d
movl $0xa5, %esi
callq 0x4537c0
movq -0x38(%rbp), %rdi
movl -0x60(%rbp), %edx
addl $0x2, %edx
movswl -0x8a(%rbp), %eax
addl %eax, %edx
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
movl $0x4f, %esi
callq 0x453790
movq -0x58(%rbp), %rdi
leaq -0x74(%rbp), %rsi
callq 0x4974f0
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x78(%rbp)
je 0x49af9a
movq -0x38(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x472f20
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movl $0x75, %esi
callq 0x46e2d0
jmp 0x49afe7
movq -0x8(%rbp), %rdi
callq 0x47c980
movq -0x38(%rbp), %rdi
movl -0x60(%rbp), %edx
movl -0x5c(%rbp), %ecx
movl -0x64(%rbp), %r8d
movl $0x66, %esi
callq 0x4537c0
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x68(%rbp), %ecx
movl $0x79, %esi
callq 0x453790
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x64(%rbp), %ecx
movl -0x68(%rbp), %r8d
movl $0x7a, %esi
callq 0x4537c0
cmpl $0x0, -0x78(%rbp)
jne 0x49b042
movq -0x58(%rbp), %rdi
callq 0x481df0
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl $0x24, %esi
callq 0x46e2d0
movl %eax, -0x7c(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x49b040
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
movl -0x60(%rbp), %r8d
addl -0x40(%rbp), %r8d
movl $0x5a, %esi
callq 0x4537c0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x49b011
jmp 0x49b042
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x497720
movq -0x38(%rbp), %rdi
movl -0x5c(%rbp), %ecx
movl -0x60(%rbp), %r8d
movq -0x50(%rbp), %r9
movl $0xa, %esi
xorl %edx, %edx
movl $0xfffffff4, (%rsp)     # imm = 0xFFFFFFF4
callq 0x46bbd0
movq -0x38(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpl $0xb, 0x18(%rbp)
jne 0x49b08f
movl $0x2, %eax
movl %eax, -0x9c(%rbp)
jmp 0x49b098
movl 0x18(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x98(%rbp), %rdi
movl -0x9c(%rbp), %eax
movzwl %ax, %esi
callq 0x411430
movq -0x8(%rbp), %rdi
callq 0x46ff70
cmpl $0x0, -0x78(%rbp)
jne 0x49b0f4
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x7c(%rbp), %ecx
addl $0x1, %ecx
movl $0x5, %esi
callq 0x453790
movq -0x38(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x46bba0
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl $0x75, %esi
xorl %ecx, %ecx
callq 0x453790
jmp 0x49b0fd
movq -0x58(%rbp), %rdi
callq 0x481df0
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)