// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: renameColumnFunc
static void renameColumnFunc(
  sqlite3_context *context,
  int NotUsed,
  sqlite3_value **argv
){
  sqlite3 *db = sqlite3_context_db_handle(context);
  RenameCtx sCtx;
  const char *zSql = (const char*)sqlite3_value_text(argv[0]);
  const char *zDb = (const char*)sqlite3_value_text(argv[3]);
  const char *zTable = (const char*)sqlite3_value_text(argv[4]);
  int iCol = sqlite3_value_int(argv[5]);
  const char *zNew = (const char*)sqlite3_value_text(argv[6]);
  int bQuote = sqlite3_value_int(argv[7]);
  int bTemp = sqlite3_value_int(argv[8]);
  const char *zOld;
  int rc;
  Parse sParse;
  Walker sWalker;
  Index *pIdx;
  int i;
  Table *pTab;
#ifndef SQLITE_OMIT_AUTHORIZATION
  sqlite3_xauth xAuth = db->xAuth;
#endif

  UNUSED_PARAMETER(NotUsed);
  if( zSql==0 ) return;
  if( zTable==0 ) return;
  if( zNew==0 ) return;
  if( iCol<0 ) return;
  sqlite3BtreeEnterAll(db);
  pTab = sqlite3FindTable(db, zTable, zDb);
  if( pTab==0 || iCol>=pTab->nCol ){
    sqlite3BtreeLeaveAll(db);
    return;
  }
  zOld = pTab->aCol[iCol].zName;
  memset(&sCtx, 0, sizeof(sCtx));
  sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);

#ifndef SQLITE_OMIT_AUTHORIZATION
  db->xAuth = 0;
#endif
  rc = renameParseSql(&sParse, zDb, db, zSql, bTemp);

  /* Find tokens that need to be replaced. */
  memset(&sWalker, 0, sizeof(Walker));
  sWalker.pParse = &sParse;
  sWalker.xExprCallback = renameColumnExprCb;
  sWalker.xSelectCallback = renameColumnSelectCb;
  sWalker.u.pRename = &sCtx;

  sCtx.pTab = pTab;
  if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
  if( sParse.pNewTable ){
    Select *pSelect = sParse.pNewTable->pSelect;
    if( pSelect ){
      pSelect->selFlags &= ~SF_View;
      sParse.rc = SQLITE_OK;
      sqlite3SelectPrep(&sParse, pSelect, 0);
      rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc);
      if( rc==SQLITE_OK ){
        sqlite3WalkSelect(&sWalker, pSelect);
      }
      if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
    }else{
      /* A regular table */
      int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);
      FKey *pFKey;
      assert( sParse.pNewTable->pSelect==0 );
      sCtx.pTab = sParse.pNewTable;
      if( bFKOnly==0 ){
        renameTokenFind(
            &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName
        );
        if( sCtx.iCol<0 ){
          renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey);
        }
        sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck);
        for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
          sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
        }
        for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){
          sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
        }
      }
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
      for(i=0; i<sParse.pNewTable->nCol; i++){
        sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt);
      }
#endif

      for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
        for(i=0; i<pFKey->nCol; i++){
          if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){
            renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);
          }
          if( 0==sqlite3_stricmp(pFKey->zTo, zTable)
           && 0==sqlite3_stricmp(pFKey->aCol[i].zCol, zOld)
          ){
            renameTokenFind(&sParse, &sCtx, (void*)pFKey->aCol[i].zCol);
          }
        }
      }
    }
  }else if( sParse.pNewIndex ){
    sqlite3WalkExprList(&sWalker, sParse.pNewIndex->aColExpr);
    sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
  }else{
    /* A trigger */
    TriggerStep *pStep;
    rc = renameResolveTrigger(&sParse);
    if( rc!=SQLITE_OK ) goto renameColumnFunc_done;

    for(pStep=sParse.pNewTrigger->step_list; pStep; pStep=pStep->pNext){
      if( pStep->zTarget ){
        Table *pTarget = sqlite3LocateTable(&sParse, 0, pStep->zTarget, zDb);
        if( pTarget==pTab ){
          if( pStep->pUpsert ){
            ExprList *pUpsertSet = pStep->pUpsert->pUpsertSet;
            renameColumnElistNames(&sParse, &sCtx, pUpsertSet, zOld);
          }
          renameColumnIdlistNames(&sParse, &sCtx, pStep->pIdList, zOld);
          renameColumnElistNames(&sParse, &sCtx, pStep->pExprList, zOld);
        }
      }
    }


    /* Find tokens to edit in UPDATE OF clause */
    if( sParse.pTriggerTab==pTab ){
      renameColumnIdlistNames(&sParse, &sCtx,sParse.pNewTrigger->pColumns,zOld);
    }

    /* Find tokens to edit in various expressions and selects */
    renameWalkTrigger(&sWalker, sParse.pNewTrigger);
  }

  assert( rc==SQLITE_OK );
  rc = renameEditSql(context, &sCtx, zSql, zNew, bQuote);

renameColumnFunc_done:
  if( rc!=SQLITE_OK ){
    if( sParse.zErrMsg ){
      renameColumnParseError(context, 0, argv[1], argv[2], &sParse);
    }else{
      sqlite3_result_error_code(context, rc);
    }
  }

  renameParseCleanup(&sParse);
  renameTokenFree(db, sCtx.pList);
#ifndef SQLITE_OMIT_AUTHORIZATION
  db->xAuth = xAuth;
#endif
  sqlite3BtreeLeaveAll(db);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdx, %r13
movq %rdi, 0x28(%rsp)
movq (%rdi), %rax
movq 0x28(%rax), %rax
movq %rax, 0x30(%rsp)
movq (%rdx), %rdi
movl $0x1, %esi
callq 0x281c96
movq %rax, %rbx
movq 0x18(%r13), %rdi
movl $0x1, %esi
callq 0x281c96
movq %rax, %r14
movq 0x20(%r13), %rdi
movl $0x1, %esi
callq 0x281c96
movq %rax, %rbp
movq 0x28(%r13), %rdi
callq 0x281c1d
movq %rax, %r15
movq 0x30(%r13), %rdi
movl $0x1, %esi
callq 0x281c96
movq %rax, %r12
movq 0x38(%r13), %rdi
callq 0x281c1d
movq %rax, 0x90(%rsp)
movq 0x40(%r13), %rdi
callq 0x281c1d
movq %rbx, 0x48(%rsp)
testq %rbx, %rbx
sete %dl
testq %rbp, %rbp
sete %cl
orb %dl, %cl
movq %r12, 0x98(%rsp)
testq %r12, %r12
movq %r14, %r12
movq 0x30(%rsp), %r14
sete %sil
testl %r15d, %r15d
sets %dl
orb %sil, %dl
orb %cl, %dl
jne 0x2f5bd3
movq %rax, %rbx
movq 0x1c8(%r14), %rax
movq %rax, 0x88(%rsp)
movslq 0x28(%r14), %rax
testq %rax, %rax
jle 0x2f557c
movq 0x20(%r14), %rcx
shlq $0x5, %rax
xorl %edx, %edx
movq 0x8(%rcx,%rdx), %rsi
testq %rsi, %rsi
je 0x2f5573
movq (%rsi), %rdi
movq 0x8(%rsi), %rsi
movq %rdi, 0x8(%rsi)
addq $0x20, %rdx
cmpq %rdx, %rax
jne 0x2f555e
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x28ad59
testq %rax, %rax
je 0x2f5bd3
movswl 0x46(%rax), %ecx
cmpl %ecx, %r15d
jge 0x2f5bd3
movq %rbx, %r8
movq %r13, 0x80(%rsp)
movq 0x8(%rax), %rcx
movq %rax, 0x38(%rsp)
movl %r15d, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
shlq $0x5, %rbx
movq %r14, %rdx
movq (%rcx,%rbx), %r13
xorps %xmm0, %xmm0
movq %rsp, %r14
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
movswl 0x44(%rax), %eax
cmpl %eax, %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovnel %r15d, %eax
movl %eax, 0xc(%r14)
movq $0x0, 0x1c8(%rdx)
leaq 0xa0(%rsp), %rdi
movq %r12, %rsi
movq 0x48(%rsp), %rcx
callq 0x2f641b
movl %eax, %esi
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x70(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0xed3(%rip), %rax       # 0x2f6506
movq %rax, 0x58(%rsp)
leaq 0xf7d(%rip), %rax       # 0x2f65bc
movq %rax, 0x60(%rsp)
movq 0x38(%rsp), %rax
movq %r14, 0x78(%rsp)
movq %rax, 0x10(%r14)
testl %esi, %esi
jne 0x2f5b56
movq 0x1e8(%rsp), %rcx
testq %rcx, %rcx
je 0x2f56c8
movq %rbx, %r9
movq 0x18(%rcx), %rbx
testq %rbx, %rbx
je 0x2f570a
andb $-0x21, 0x6(%rbx)
leaq 0xa0(%rsp), %rdi
movl $0x0, 0x18(%rdi)
xorl %r14d, %r14d
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2d0563
movq 0x30(%rsp), %rax
cmpb $0x0, 0x61(%rax)
movl $0x7, %esi
jne 0x2f56ae
movl 0xb8(%rsp), %esi
testl %esi, %esi
jne 0x2f5b2d
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x2ca2ea
jmp 0x2f5b28
movq %rax, %r14
movq 0x1f0(%rsp), %rax
testq %rax, %rax
je 0x2f5754
movq 0x50(%rax), %rsi
leaq 0x50(%rsp), %rdi
callq 0x2ca44f
movq 0x1f0(%rsp), %rax
movq 0x48(%rax), %rsi
testq %rsi, %rsi
je 0x2f5b32
leaq 0x50(%rsp), %rdi
callq 0x2ca211
jmp 0x2f5b32
movq %r15, 0x38(%rsp)
movq (%rcx), %rax
testq %rax, %rax
je 0x2f583f
xorl %edx, %edx
leaq 0xe533c(%rip), %rsi     # 0x3daa60
movzbl (%rbp,%rdx), %edi
movzbl (%rax,%rdx), %r8d
cmpb %r8b, %dil
sete %r12b
jne 0x2f5741
testq %rdi, %rdi
jne 0x2f574f
jmp 0x2f5842
movb (%rdi,%rsi), %dil
cmpb (%r8,%rsi), %dil
jne 0x2f5842
incq %rdx
jmp 0x2f5724
leaq 0xa0(%rsp), %rdi
callq 0x2f65d4
movl %eax, %esi
testl %eax, %eax
jne 0x2f5b56
movl %esi, 0x44(%rsp)
movq 0x1f8(%rsp), %rax
movq 0x38(%rax), %rbp
testq %rbp, %rbp
movq %r14, %rbx
je 0x2f57f4
movq %r12, %r15
leaq 0xa0(%rsp), %r14
movq %rsp, %r12
movq 0x18(%rbp), %rdx
testq %rdx, %rdx
je 0x2f57eb
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rcx
callq 0x284c10
cmpq %rbx, %rax
jne 0x2f57eb
movq 0x40(%rbp), %rax
testq %rax, %rax
je 0x2f57c7
movq 0x10(%rax), %rdx
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rcx
callq 0x2f686f
movq 0x38(%rbp), %rdx
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rcx
callq 0x2f692b
movq 0x30(%rbp), %rdx
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rcx
callq 0x2f686f
movq 0x50(%rbp), %rbp
testq %rbp, %rbp
jne 0x2f5791
cmpq %rbx, 0x148(%rsp)
jne 0x2f581c
leaq 0xa0(%rsp), %rdi
movq 0x158(%rdi), %rax
movq 0x20(%rax), %rdx
movq %rsp, %rsi
movq %r13, %rcx
callq 0x2f692b
movq 0x1f8(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x2f69e3
movl 0x44(%rsp), %esi
testl %esi, %esi
jne 0x2f5b56
jmp 0x2f5b32
xorl %r12d, %r12d
movq %rcx, 0x10(%rsp)
testb %r12b, %r12b
je 0x2f5957
leaq 0x240(%rsp), %rax
movq (%rax), %rdx
testq %rdx, %rdx
je 0x2f589e
movq 0x8(%rcx), %rcx
movq (%rcx,%r9), %rsi
cmpq %rsi, (%rdx)
je 0x2f5884
movq %rdx, %rcx
movq 0x18(%rdx), %rdx
testq %rdx, %rdx
je 0x2f589e
cmpq %rsi, (%rdx)
jne 0x2f586d
addq $0x18, %rcx
jmp 0x2f5887
movq %rax, %rcx
movq 0x18(%rdx), %rsi
movq %rsi, (%rcx)
movq (%rsp), %rcx
movq %rcx, 0x18(%rdx)
movq %rdx, (%rsp)
incl 0x8(%rsp)
cmpl $0x0, 0xc(%rsp)
jns 0x2f58ef
movq 0x240(%rsp), %rcx
testq %rcx, %rcx
je 0x2f58ef
movq 0x1e8(%rsp), %rdx
addq $0x44, %rdx
cmpq %rdx, (%rcx)
je 0x2f58d8
movq %rcx, %rax
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
je 0x2f58ef
cmpq %rdx, (%rcx)
jne 0x2f58c3
addq $0x18, %rax
movq 0x18(%rcx), %rdx
movq %rdx, (%rax)
movq (%rsp), %rax
movq %rax, 0x18(%rcx)
movq %rcx, (%rsp)
incl 0x8(%rsp)
movq 0x1e8(%rsp), %rax
movq 0x30(%rax), %rsi
leaq 0x50(%rsp), %rdi
callq 0x2ca44f
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %r14
testq %r14, %r14
je 0x2f5930
leaq 0x50(%rsp), %rbx
movq 0x50(%r14), %rsi
movq %rbx, %rdi
callq 0x2ca44f
movq 0x28(%r14), %r14
testq %r14, %r14
jne 0x2f591b
movq 0x1f0(%rsp), %r14
testq %r14, %r14
je 0x2f5957
leaq 0x50(%rsp), %rbx
movq 0x50(%r14), %rsi
movq %rbx, %rdi
callq 0x2ca44f
movq 0x28(%r14), %r14
testq %r14, %r14
jne 0x2f5942
movq 0x1e8(%rsp), %rax
cmpw $0x0, 0x46(%rax)
jle 0x2f59a1
movl $0x8, %ebx
xorl %r14d, %r14d
leaq 0x50(%rsp), %r15
movq 0x8(%rax), %rax
movq (%rax,%rbx), %rsi
testq %rsi, %rsi
je 0x2f5988
movq %r15, %rdi
callq 0x2ca211
incq %r14
movq 0x1e8(%rsp), %rax
movswq 0x46(%rax), %rcx
addq $0x20, %rbx
cmpq %rcx, %r14
jl 0x2f5973
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x2f5b28
movl 0x8(%rsp), %edx
movq (%rsp), %rdi
leaq 0xe50a3(%rip), %rsi     # 0x3daa60
movslq 0x28(%rax), %r8
testq %r8, %r8
jle 0x2f5b1b
leaq 0x40(%rax), %r9
xorl %r10d, %r10d
testb %r12b, %r12b
je 0x2f5a3a
movq %r10, %rbx
shlq $0x4, %rbx
movq 0x38(%rsp), %rcx
cmpl %ecx, (%r9,%rbx)
setne %cl
movq 0x240(%rsp), %r11
testq %r11, %r11
sete %r14b
orb %cl, %r14b
jne 0x2f5a3a
addq %r9, %rbx
leaq 0x240(%rsp), %r14
cmpq %rbx, (%r11)
je 0x2f5a22
movq %r11, %r14
movq 0x18(%r11), %r11
testq %r11, %r11
je 0x2f5a3a
cmpq %rbx, (%r11)
jne 0x2f5a0d
addq $0x18, %r14
movq 0x18(%r11), %rcx
movq %rcx, (%r14)
movq %rdi, 0x18(%r11)
movq %r11, (%rsp)
incl %edx
movl %edx, 0x8(%rsp)
movq %r11, %rdi
movq 0x10(%rax), %r11
testq %r11, %r11
je 0x2f5a6e
xorl %ebx, %ebx
movzbl (%r11,%rbx), %ecx
movzbl (%rbp,%rbx), %r14d
cmpb %r14b, %cl
jne 0x2f5a5c
testq %rcx, %rcx
jne 0x2f5a69
jmp 0x2f5a77
movb (%rcx,%rsi), %cl
cmpb (%r14,%rsi), %cl
jne 0x2f5b0f
incq %rbx
jmp 0x2f5a45
testq %rbp, %rbp
jne 0x2f5b0f
movq %r10, %rcx
shlq $0x4, %rcx
movq 0x8(%r9,%rcx), %r11
movq %r11, %rcx
orq %r13, %rcx
setne %r14b
testq %r11, %r11
je 0x2f5ac2
testq %r13, %r13
je 0x2f5ac2
xorl %ebx, %ebx
movzbl (%r11,%rbx), %ecx
movzbl (%r13,%rbx), %r15d
cmpb %r15b, %cl
setne %r14b
je 0x2f5ab8
movb (%rcx,%rsi), %cl
cmpb (%r15,%rsi), %cl
je 0x2f5abd
jmp 0x2f5ac2
testq %rcx, %rcx
je 0x2f5ac2
incq %rbx
jmp 0x2f5a99
movq 0x240(%rsp), %rbx
testq %rbx, %rbx
sete %cl
orb %r14b, %cl
jne 0x2f5b0f
leaq 0x240(%rsp), %r14
cmpq %r11, (%rbx)
je 0x2f5af7
movq %rbx, %r14
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
je 0x2f5b0f
cmpq %r11, (%rbx)
jne 0x2f5ae2
addq $0x18, %r14
movq 0x18(%rbx), %rcx
movq %rcx, (%r14)
movq %rdi, 0x18(%rbx)
movq %rbx, (%rsp)
incl %edx
movl %edx, 0x8(%rsp)
movq %rbx, %rdi
incq %r10
cmpq %r8, %r10
jne 0x2f59d1
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x2f59bd
xorl %esi, %esi
movb $0x1, %r14b
testb %r14b, %r14b
je 0x2f5b56
movq %rsp, %rsi
movq 0x28(%rsp), %rdi
movq 0x48(%rsp), %rdx
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %r8
callq 0x2f6a7f
movl %eax, %esi
testl %esi, %esi
movq 0x30(%rsp), %r14
je 0x2f5b9a
cmpq $0x0, 0xa8(%rsp)
je 0x2f5b90
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
leaq 0xa0(%rsp), %r8
movq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x2f6cd0
jmp 0x2f5b9a
movq 0x28(%rsp), %rdi
callq 0x2823f0
leaq 0xa0(%rsp), %rdi
callq 0x2f6d62
movq (%rsp), %rsi
testq %rsi, %rsi
je 0x2f5bc4
movq 0x18(%rsi), %rbx
movq %r14, %rdi
callq 0x28c3e7
movq %rbx, %rsi
testq %rbx, %rbx
jne 0x2f5bb0
movq 0x88(%rsp), %rax
movq %rax, 0x1c8(%r14)
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq