// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/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 = 0;
  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;
  if( pSrc->nSrc>1 ){
    Expr *pRow;
    ExprList *pList;
    if( pRowid ){
      pRow = sqlite3ExprDup(db, pRowid, 0);
    }else{
      pRow = sqlite3PExpr(pParse, TK_ROW, 0, 0);
    }
    pList = sqlite3ExprListAppend(pParse, 0, pRow);

    for(i=0; i<pTab->nCol; i++){
      if( aXRef[i]>=0 ){
        pList = sqlite3ExprListAppend(pParse, pList,
          sqlite3ExprDup(db, pChanges->a[aXRef[i]].pExpr, 0)
        );
      }else{
        pList = sqlite3ExprListAppend(pParse, pList, exprRowColumn(pParse, i));
      }
    }

    updateFromSelect(pParse, ephemTab, 0, pList, pSrc, pWhere, 0, 0);
    sqlite3ExprListDelete(db, pList);
    eOnePass = ONEPASS_OFF;
  }else{
    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++){
      assert( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 );
      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, OPFLAG_NOCHNG);/* For 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);
#if defined(SQLITE_DEBUG) && !defined(SQLITE_ENABLE_NULL_TRIM)
      /* 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 */
    if( pSrc->nSrc==1 ){
      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 $0xe0, %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 0x40f150
movq %rax, -0x50(%rbp)
movq $0x0, -0x58(%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 $0x64, %esi
callq 0x410100
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 -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jle 0x45e44f
cmpq $0x0, -0x28(%rbp)
je 0x45e2f1
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %edx, %edx
callq 0x42dee0
movq %rax, -0x88(%rbp)
jmp 0x45e30d
movq -0x8(%rbp), %rdi
movl $0x4b, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x418540
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x41d3c0
movq %rax, -0x90(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x18(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jge 0x45e403
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x45e3b1
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq -0x30(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
xorl %edx, %edx
callq 0x42dee0
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movq %rax, %rdx
callq 0x41d3c0
movq %rax, -0x90(%rbp)
jmp 0x45e3f3
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x8(%rbp), %rdi
movl -0x40(%rbp), %esi
callq 0x4605c0
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq %rax, %rdx
callq 0x41d3c0
movq %rax, -0x90(%rbp)
jmp 0x45e3f5
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x45e32f
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq -0x90(%rbp), %rcx
movq -0x10(%rbp), %r8
movq 0x10(%rbp), %r9
xorl %eax, %eax
movl %eax, %edx
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x45e7b0
movq -0x48(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x40c6a0
movl $0x0, -0x78(%rbp)
jmp 0x45e67d
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 0x4415b0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x45e4a7
jmp 0x45e79c
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x18(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jge 0x45e53b
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x45e4fd
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq -0x30(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x60(%rbp), %edx
addl $0x2, %edx
addl -0x40(%rbp), %edx
callq 0x429d30
jmp 0x45e52b
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movl -0x40(%rbp), %ecx
movl -0x60(%rbp), %r8d
addl $0x2, %r8d
addl -0x40(%rbp), %r8d
movl $0xa6, %esi
callq 0x410130
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x3cb9f0
jmp 0x45e52d
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x45e4ae
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x45e595
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movl -0x60(%rbp), %ecx
movl $0x7f, %esi
callq 0x410100
cmpq $0x0, -0x28(%rbp)
je 0x45e57c
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x60(%rbp), %edx
addl $0x1, %edx
callq 0x429d30
jmp 0x45e593
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
movl $0x7f, %esi
callq 0x410100
jmp 0x45e5f9
movq -0x18(%rbp), %rdi
callq 0x3cef20
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movw (%rax), %ax
movw %ax, -0x9a(%rbp)
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movswl -0x9a(%rbp), %ecx
movl -0x60(%rbp), %r8d
movl $0xa6, %esi
callq 0x410130
movq -0x38(%rbp), %rdi
movl -0x60(%rbp), %edx
addl $0x2, %edx
movswl -0x9a(%rbp), %eax
addl %eax, %edx
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
movl $0x4e, %esi
callq 0x410100
movq -0x58(%rbp), %rdi
leaq -0x74(%rbp), %rsi
callq 0x45a6a0
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x78(%rbp)
je 0x45e62e
movq -0x38(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x431fd0
movq -0x38(%rbp), %rdi
movl -0x6c(%rbp), %edx
movl $0x74, %esi
callq 0x42ba70
jmp 0x45e67b
movq -0x8(%rbp), %rdi
callq 0x43d980
movq -0x38(%rbp), %rdi
movl -0x60(%rbp), %edx
movl -0x5c(%rbp), %ecx
movl -0x64(%rbp), %r8d
movl $0x5b, %esi
callq 0x410130
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x68(%rbp), %ecx
movl $0x78, %esi
callq 0x410100
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x64(%rbp), %ecx
movl -0x68(%rbp), %r8d
movl $0x79, %esi
callq 0x410130
jmp 0x45e67d
cmpl $0x0, -0x78(%rbp)
jne 0x45e6e1
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x45e695
movq -0x58(%rbp), %rdi
callq 0x444120
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl $0x25, %esi
callq 0x42ba70
movl %eax, -0x7c(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x45e6df
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
movl -0x60(%rbp), %r8d
addl -0x40(%rbp), %r8d
movl $0x59, %esi
callq 0x410130
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x45e6b0
jmp 0x45e6e1
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x45a8d0
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 0x429aa0
movq -0x38(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpl $0xb, 0x18(%rbp)
jne 0x45e72e
movl $0x2, %eax
movl %eax, -0xcc(%rbp)
jmp 0x45e737
movl 0x18(%rbp), %eax
movl %eax, -0xcc(%rbp)
movq -0xc8(%rbp), %rdi
movl -0xcc(%rbp), %eax
movzwl %ax, %esi
callq 0x3cb9f0
movq -0x8(%rbp), %rdi
callq 0x42e470
cmpl $0x0, -0x78(%rbp)
jne 0x45e793
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl -0x7c(%rbp), %ecx
addl $0x1, %ecx
movl $0x5, %esi
callq 0x410100
movq -0x38(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x429a70
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %edx
movl $0x74, %esi
xorl %ecx, %ecx
callq 0x410100
jmp 0x45e79c
movq -0x58(%rbp), %rdi
callq 0x444120
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)