// File: /workspace/github_c_makefile_star2_O3/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 %rcx, %rbp
movq %rdx, %r15
movq (%rdi), %r14
movq 0x10(%rdi), %r12
movq %rsi, 0x30(%rsp)
movl 0x34(%rsi), %r13d
testq %rcx, %rcx
sete %al
movl %r8d, 0x10(%rsp)
cmpl %r8d, %r13d
sete %cl
orb %al, %cl
movq %rdi, 0x18(%rsp)
jne 0x2e625d
movq %rdi, %rbx
testb $-0x80, 0x40(%r15)
jne 0x2e60a4
movb 0x1f(%rbx), %al
testb %al, %al
je 0x2e61ef
decb %al
movb %al, 0x1f(%rbx)
movzbl %al, %eax
movl 0xd4(%rbx,%rax,4), %ebp
jmp 0x2e61f7
movl %r13d, 0x14(%rsp)
movq %r14, 0x28(%rsp)
leaq 0x10(%r15), %rax
movq (%rax), %r13
movzwl 0x63(%r13), %ecx
andl $0x3, %ecx
leaq 0x28(%r13), %rax
cmpw $0x2, %cx
jne 0x2e60b2
movzwl 0x5e(%r13), %ecx
movl 0x38(%rbx), %eax
leal 0x1(%rax), %edx
movq %rdx, 0x20(%rsp)
addl %ecx, %eax
movl %eax, 0x38(%rbx)
movl %ecx, 0xc(%rsp)
testl %ecx, %ecx
je 0x2e6148
movl 0xc(%rsp), %r14d
xorl %ebx, %ebx
movzwl 0x60(%rbp), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x2e6126
movq 0x8(%r13), %rdx
movzwl (%rdx,%rbx,2), %edx
movq 0x8(%rbp), %rsi
shll $0x10, %eax
xorl %edi, %edi
cmpw %dx, (%rsi)
je 0x2e6121
addq $0x10000, %rdi          # imm = 0x10000
addq $0x2, %rsi
cmpq %rdi, %rax
jne 0x2e610a
jmp 0x2e6126
sarl $0x10, %edi
movl %edi, %ecx
movq 0x20(%rsp), %rax
leal (%rax,%rbx), %r8d
movq %r12, %rdi
movl $0x59, %esi
movl 0x10(%rsp), %edx
callq 0x2a83e1
incq %rbx
cmpq %r14, %rbx
jne 0x2e60eb
movq %r12, %rdi
movl $0x1e, %esi
movl 0x14(%rsp), %edx
xorl %ecx, %ecx
movq 0x20(%rsp), %r8
callq 0x2a83e1
movl %eax, %ebp
movq (%r12), %rax
cmpb $0x0, 0x61(%rax)
jne 0x2e6188
movq 0x88(%r12), %rax
movslq %ebp, %rcx
leaq (%rcx,%rcx,2), %rcx
movb $-0x3, 0x1(%rax,%rcx,8)
movl 0xc(%rsp), %edx
movl %edx, 0x10(%rax,%rcx,8)
movq %r12, %rdi
movl $0x44, %esi
movl $0xb, %edx
movl $0x2, %ecx
xorl %r8d, %r8d
callq 0x2a83e1
leaq 0xf1605(%rip), %rdx     # 0x3d77ae
movq %r12, %rdi
movl %eax, %esi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x27b778
movq 0x18(%rsp), %rcx
movq 0xa0(%rcx), %rax
testq %rax, %rax
cmoveq %rcx, %rax
movb $0x1, 0x21(%rax)
movl 0x90(%r12), %eax
movq (%r12), %rcx
cmpb $0x0, 0x61(%rcx)
movq 0x28(%rsp), %r14
je 0x2e623f
leaq 0x1d8c9b(%rip), %rcx    # 0x4bee88
jmp 0x2e625a
movl 0x38(%rbx), %ebp
incl %ebp
movl %ebp, 0x38(%rbx)
movq %r12, %rdi
movl $0x86, %esi
movl 0x10(%rsp), %edx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x2a83e1
movq %r12, %rdi
movl $0x1f, %esi
movl %r13d, %edx
xorl %ecx, %ecx
movl %ebp, %r8d
callq 0x2a83e1
testl %ebp, %ebp
je 0x2e625d
movzbl 0x1f(%rbx), %eax
cmpq $0x7, %rax
ja 0x2e625d
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%rbx)
movl %ebp, 0xd4(%rbx,%rax,4)
jmp 0x2e625d
leal -0x1(%rax), %ecx
testl %ebp, %ebp
cmovnsl %ebp, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x88(%r12), %rcx
movl %eax, 0x8(%rcx)
movq 0x30(%rsp), %rbp
movq 0x28(%rbp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x2c30e3
movq %rax, %r14
movzwl 0x46(%r15), %eax
testw %ax, %ax
jle 0x2e62bc
movl $0x19, %ebx
xorl %r13d, %r13d
movq 0x8(%r15), %rcx
cmpb $0x45, (%rcx,%rbx)
jne 0x2e62ac
movl 0x30(%rbp), %edx
addl %r13d, %edx
movq %r12, %rdi
movl $0x53, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2a83e1
movzwl 0x46(%r15), %eax
incq %r13
movswq %ax, %rcx
addq $0x20, %rbx
cmpq %rcx, %r13
jl 0x2e6285
movq 0x10(%rbp), %rdx
movq 0x18(%rbp), %rcx
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movl $0x2, %r8d
movq %rbp, %r9
callq 0x2b2e2a
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbp)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq