// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3UpsertDoUpdate
SQLITE_PRIVATE void sqlite3UpsertDoUpdate(
  Parse *pParse,        /* The parsing and code-generating context */
  Upsert *pUpsert,      /* The ON CONFLICT clause for the upsert */
  Table *pTab,          /* The table being updated */
  Index *pIdx,          /* The UNIQUE constraint that failed */
  int iCur              /* Cursor for pIdx (or pTab if pIdx==NULL) */
){
  Vdbe *v = pParse->pVdbe;
  sqlite3 *db = pParse->db;
  SrcList *pSrc;            /* FROM clause for the UPDATE */
  int iDataCur;
  int i;

  assert( v!=0 );
  assert( pUpsert!=0 );
  VdbeNoopComment((v, "Begin DO UPDATE of UPSERT"));
  iDataCur = pUpsert->iDataCur;
  if( pIdx && iCur!=iDataCur ){
    if( HasRowid(pTab) ){
      int regRowid = sqlite3GetTempReg(pParse);
      sqlite3VdbeAddOp2(v, OP_IdxRowid, iCur, regRowid);
      sqlite3VdbeAddOp3(v, OP_SeekRowid, iDataCur, 0, regRowid);
      VdbeCoverage(v);
      sqlite3ReleaseTempReg(pParse, regRowid);
    }else{
      Index *pPk = sqlite3PrimaryKeyIndex(pTab);
      int nPk = pPk->nKeyCol;
      int iPk = pParse->nMem+1;
      pParse->nMem += nPk;
      for(i=0; i<nPk; i++){
        int k;
        assert( pPk->aiColumn[i]>=0 );
        k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
        sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);
        VdbeComment((v, "%s.%s", pIdx->zName,
                    pTab->aCol[pPk->aiColumn[i]].zName));
      }
      sqlite3VdbeVerifyAbortable(v, OE_Abort);
      i = sqlite3VdbeAddOp4Int(v, OP_Found, iDataCur, 0, iPk, nPk);
      VdbeCoverage(v);
      sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0,
            "corrupt database", P4_STATIC);
      sqlite3MayAbort(pParse);
      sqlite3VdbeJumpHere(v, i);
    }
  }
  /* pUpsert does not own pUpsertSrc - the outer INSERT statement does.  So
  ** we have to make a copy before passing it down into sqlite3Update() */
  pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
  /* excluded.* columns of type REAL need to be converted to a hard real */
  for(i=0; i<pTab->nCol; i++){
    if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
      sqlite3VdbeAddOp1(v, OP_RealAffinity, pUpsert->regData+i);
    }
  }
  sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,
      pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert);
  pUpsert->pUpsertSet = 0;    /* Will have been deleted by sqlite3Update() */
  pUpsert->pUpsertWhere = 0;  /* Will have been deleted by sqlite3Update() */
  VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movq (%rdi), %r13
movq 0x10(%rdi), %r12
movq %rsi, 0x10(%rsp)
movl 0x34(%rsi), %r14d
movq %rcx, 0x30(%rsp)
testq %rcx, %rcx
sete %al
movl %r8d, 0xc(%rsp)
cmpl %r8d, %r14d
sete %cl
orb %al, %cl
movq %rdi, 0x20(%rsp)
jne 0x283012
movq %rdi, %rbp
testb $-0x80, 0x40(%r15)
jne 0x282f58
movq %rbp, %rdi
callq 0x267d61
movl %eax, %ebx
movq %r12, %rdi
movl $0x86, %esi
movl 0xc(%rsp), %edx
movl %eax, %ecx
callq 0x24d51a
pushq $0x1f
popq %rsi
movq %r12, %rdi
movl %r14d, %edx
xorl %ecx, %ecx
movl %ebx, %r8d
callq 0x24d51f
testl %ebx, %ebx
je 0x283012
movzbl 0x1f(%rbp), %eax
cmpq $0x7, %rax
ja 0x283012
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%rbp)
movl %ebx, 0xd4(%rbp,%rax,4)
jmp 0x283012
movl %r14d, 0x1c(%rsp)
movq %r13, 0x28(%rsp)
movq %r15, %rdi
callq 0x2293af
movq %rax, %rbx
movzwl 0x5e(%rax), %r14d
movl 0x38(%rbp), %eax
leal 0x1(%rax), %r13d
addl %r14d, %eax
movl %eax, 0x38(%rbp)
xorl %ebp, %ebp
cmpq %rbp, %r14
je 0x282fb4
movq 0x8(%rbx), %rax
movswl (%rax,%rbp,2), %esi
movq 0x30(%rsp), %rdi
callq 0x267859
movswl %ax, %ecx
leal (%r13,%rbp), %r8d
movq %r12, %rdi
pushq $0x59
popq %rsi
movl 0xc(%rsp), %edx
callq 0x24d51f
incq %rbp
jmp 0x282f81
pushq $0x1e
popq %rsi
movq %r12, %rdi
movl 0x1c(%rsp), %edx
xorl %ecx, %ecx
movl %r13d, %r8d
movl %r14d, %r9d
callq 0x226fc2
movl %eax, %ebx
orl $-0x1, (%rsp)
leaq 0xf4bf6(%rip), %r9      # 0x377bce
pushq $0x44
popq %rsi
pushq $0xb
popq %rdx
pushq $0x2
popq %rcx
movq %r12, %rdi
xorl %r8d, %r8d
callq 0x264609
movq 0x20(%rsp), %rcx
movq 0xa0(%rcx), %rax
testq %rax, %rax
cmoveq %rcx, %rax
movb $0x1, 0x21(%rax)
movq %r12, %rdi
movl %ebx, %esi
callq 0x2645f8
movq 0x28(%rsp), %r13
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rsi
xorl %r14d, %r14d
movq %r13, %rdi
xorl %edx, %edx
callq 0x269ff5
movq %rax, %rbx
pushq $0x19
popq %r13
pushq $0x53
popq %rbp
movswq 0x46(%r15), %rax
cmpq %rax, %r14
jge 0x283065
movq 0x8(%r15), %rax
cmpb $0x45, (%rax,%r13)
jne 0x28305c
movq 0x10(%rsp), %rax
movl 0x30(%rax), %edx
addl %r14d, %edx
movq %r12, %rdi
movl %ebp, %esi
callq 0x265d5c
incq %r14
addq $0x20, %r13
jmp 0x283032
movq 0x10(%rsp), %r14
movq 0x10(%r14), %rdx
movq 0x18(%r14), %rcx
pushq $0x2
popq %r8
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %r9
callq 0x25cd10
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq