// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: updateFromSelect
static void updateFromSelect(
  Parse *pParse,                  /* Parse context */
  int iEph,                       /* Cursor for open eph. table */
  Index *pPk,                     /* PK if table 0 is WITHOUT ROWID */
  ExprList *pChanges,             /* List of expressions to return */
  SrcList *pTabList,              /* List of tables to select from */
  Expr *pWhere,                   /* WHERE clause for query */
  ExprList *pOrderBy,             /* ORDER BY clause */
  Expr *pLimit                    /* LIMIT clause */
){
  int i;
  SelectDest dest;
  Select *pSelect = 0;
  ExprList *pList = 0;
  ExprList *pGrp = 0;
  Expr *pLimit2 = 0;
  ExprList *pOrderBy2 = 0;
  sqlite3 *db = pParse->db;
  Table *pTab = pTabList->a[0].pTab;
  SrcList *pSrc;
  Expr *pWhere2;
  int eDest;

#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
  if( pOrderBy && pLimit==0 ) {
    sqlite3ErrorMsg(pParse, "ORDER BY without LIMIT on UPDATE");
    return;
  }
  pOrderBy2 = sqlite3ExprListDup(db, pOrderBy, 0);
  pLimit2 = sqlite3ExprDup(db, pLimit, 0);
#else
  UNUSED_PARAMETER(pOrderBy);
  UNUSED_PARAMETER(pLimit);
#endif

  pSrc = sqlite3SrcListDup(db, pTabList, 0);
  pWhere2 = sqlite3ExprDup(db, pWhere, 0);

  assert( pTabList->nSrc>1 );
  if( pSrc ){
    pSrc->a[0].iCursor = -1;
    pSrc->a[0].pTab->nTabRef--;
    pSrc->a[0].pTab = 0;
  }
  if( pPk ){
    for(i=0; i<pPk->nKeyCol; i++){
      Expr *pNew = exprRowColumn(pParse, pPk->aiColumn[i]);
#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
      if( pLimit ){
        pGrp = sqlite3ExprListAppend(pParse, pGrp, sqlite3ExprDup(db, pNew, 0));
      }
#endif
      pList = sqlite3ExprListAppend(pParse, pList, pNew);
    }
    eDest = SRT_Upfrom;
  }else if( pTab->pSelect ){
    for(i=0; i<pTab->nCol; i++){
      pList = sqlite3ExprListAppend(pParse, pList, exprRowColumn(pParse, i));
    }
    eDest = SRT_Table;
  }else{
    eDest = IsVirtual(pTab) ? SRT_Table : SRT_Upfrom;
    pList = sqlite3ExprListAppend(pParse, 0, sqlite3PExpr(pParse,TK_ROW,0,0));
#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
    if( pLimit ){
      pGrp = sqlite3ExprListAppend(pParse, 0, sqlite3PExpr(pParse,TK_ROW,0,0));
    }
#endif
  }
  if( ALWAYS(pChanges) ){
    for(i=0; i<pChanges->nExpr; i++){
      pList = sqlite3ExprListAppend(pParse, pList,
          sqlite3ExprDup(db, pChanges->a[i].pExpr, 0)
      );
    }
  }
  pSelect = sqlite3SelectNew(pParse, pList,
      pSrc, pWhere2, pGrp, 0, pOrderBy2, SF_UpdateFrom|SF_IncludeHidden, pLimit2
  );
  sqlite3SelectDestInit(&dest, eDest, iEph);
  dest.iSDParm2 = (pPk ? pPk->nKeyCol : -1);
  sqlite3Select(pParse, pSelect, &dest);
  sqlite3SelectDelete(db, pSelect);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %rbp
movq %rcx, %r13
movq %rdx, %r15
movl %esi, 0x1c(%rsp)
movq %rdi, %r14
movq (%rdi), %rbx
movq 0x28(%r8), %r12
movq %rbx, %rdi
movq %r8, %rsi
xorl %edx, %edx
callq 0x2cc81d
movq %rax, 0x20(%rsp)
testq %rbp, %rbp
je 0x2ed4b7
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2cbf97
jmp 0x2ed4b9
xorl %eax, %eax
movq 0x20(%rsp), %rcx
testq %rcx, %rcx
je 0x2ed4d9
movl $0xffffffff, 0x48(%rcx) # imm = 0xFFFFFFFF
movq 0x28(%rcx), %rdx
decl 0x3c(%rdx)
movq $0x0, 0x28(%rcx)
testq %r15, %r15
movq %rbx, 0x10(%rsp)
movq %rax, 0x28(%rsp)
je 0x2ed547
movb $0xf, 0xf(%rsp)
cmpw $0x0, 0x5e(%r15)
je 0x2ed59d
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x8(%r15), %rax
movzwl (%rax,%rbx,2), %r12d
movq %r14, %rdi
movl $0x4b, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2b6fa0
testq %rax, %rax
je 0x2ed524
incl %r12d
movw %r12w, 0x30(%rax)
movq %r14, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x2bb1a3
movq %rax, %rbp
incq %rbx
movzwl 0x5e(%r15), %eax
cmpq %rax, %rbx
jb 0x2ed4fd
jmp 0x2ed5d2
cmpq $0x0, 0x18(%r12)
je 0x2ed5a1
movb $0xe, 0xf(%rsp)
xorl %ebx, %ebx
cmpw $0x0, 0x46(%r12)
jle 0x2ed59d
xorl %ebp, %ebp
movq %r14, %rdi
movl $0x4b, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2b6fa0
testq %rax, %rax
je 0x2ed57e
leal 0x1(%rbx), %ecx
movw %cx, 0x30(%rax)
movq %r14, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x2bb1a3
movq %rax, %rbp
incl %ebx
movswl 0x46(%r12), %eax
cmpl %eax, %ebx
jl 0x2ed561
jmp 0x2ed5d2
xorl %ebp, %ebp
jmp 0x2ed5d2
cmpl $0x0, 0x54(%r12)
sete %bl
movq %r14, %rdi
movl $0x4b, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2b6fa0
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2bb1a3
movq %rax, %rbp
orb $0xe, %bl
movb %bl, 0xf(%rsp)
testq %r13, %r13
je 0x2ed620
cmpl $0x0, (%r13)
jle 0x2ed620
leaq 0x8(%r13), %r12
xorl %ebx, %ebx
movq (%r12), %rsi
testq %rsi, %rsi
je 0x2ed600
movq 0x10(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2cbf97
movq %rax, %rdx
jmp 0x2ed602
xorl %edx, %edx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2bb1a3
movq %rax, %rbp
incq %rbx
movslq (%r13), %rax
addq $0x18, %r12
cmpq %rax, %rbx
jl 0x2ed5e4
subq $0x8, %rsp
xorl %ebx, %ebx
movq %r14, %rdi
movq %rbp, %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x820000               # imm = 0x820000
pushq %rbx
callq 0x2bb03c
addq $0x20, %rsp
movq %rax, %r12
movb 0xf(%rsp), %al
movb %al, 0x30(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x34(%rsp)
movl $0x0, 0x38(%rsp)
movq %rbx, 0x48(%rsp)
movq %rbx, 0x3c(%rsp)
testq %r15, %r15
je 0x2ed67d
movzwl 0x5e(%r15), %eax
jmp 0x2ed682
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rbx
leaq 0x30(%rsp), %rdx
movl %eax, 0x8(%rdx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2b9266
testq %r12, %r12
je 0x2ed6bd
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2afecb
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq