// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rdi, (%rsp)
movq (%rdi), %rax
movq 0x28(%rax), %r15
movq (%rdx), %rdi
callq 0x2243e3
movq %rax, %r12
movq 0x18(%rbx), %rdi
callq 0x2243e3
movq %rax, 0x18(%rsp)
movq 0x20(%rbx), %rdi
callq 0x2243e3
movq %rax, %r14
movq 0x28(%rbx), %rdi
callq 0x224451
movq %rax, %r13
movq 0x30(%rbx), %rdi
callq 0x2243e3
movq %rax, %rbp
movq 0x38(%rbx), %rdi
callq 0x224451
movq %rax, 0x50(%rsp)
movq %rbx, 0x60(%rsp)
movq 0x40(%rbx), %rdi
callq 0x224451
movq %rax, %rbx
movq %r12, 0x20(%rsp)
testq %r12, %r12
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
movq %rbp, 0x58(%rsp)
testq %rbp, %rbp
sete %al
testl %r13d, %r13d
sets %dl
orb %al, %dl
orb %cl, %dl
jne 0x28761a
movq 0x1c8(%r15), %r12
movq %r15, %rdi
callq 0x21f0e2
movq %r15, %rdi
movq %r14, %rsi
movq 0x18(%rsp), %rdx
callq 0x22beb2
testq %rax, %rax
je 0x28761a
movq %rax, %rbp
movswl 0x46(%rax), %eax
cmpl %eax, %r13d
jge 0x28761a
movq %r12, 0x10(%rsp)
movq 0x8(%rbp), %rax
movq %r15, %rdx
movl %r13d, %r15d
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
shlq $0x5, %r15
movq (%rax,%r15), %rax
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %r12
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
movswl 0x44(%rbp), %eax
cmpl %eax, %r13d
pushq $-0x1
popq %rax
cmovnel %r13d, %eax
movl %eax, 0xc(%r12)
andq $0x0, 0x1c8(%rdx)
leaq 0xa0(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %rdx, 0x8(%rsp)
movq 0x20(%rsp), %rcx
movl %ebx, %r8d
callq 0x287ba0
xorps %xmm0, %xmm0
movups %xmm0, 0x88(%rsp)
leaq 0xa0(%rsp), %rcx
movq %rcx, 0x70(%rsp)
leaq 0xa38(%rip), %rcx       # 0x287c5e
movq %rcx, 0x78(%rsp)
leaq 0xa7d(%rip), %rcx       # 0x287caf
movq %rcx, 0x80(%rsp)
movq %r12, 0x98(%rsp)
movq %rbp, 0x10(%r12)
testl %eax, %eax
je 0x28725e
movq 0x8(%rsp), %r14
movq (%rsp), %r15
movq 0x10(%rsp), %r12
jmp 0x2875c3
movq 0x18(%rsp), %rbx
movq %r13, 0x68(%rsp)
movq 0x1e8(%rsp), %r13
testq %r13, %r13
je 0x2872b9
movq 0x18(%r13), %rbx
testq %rbx, %rbx
movq 0x10(%rsp), %r12
je 0x2872f9
andb $-0x21, 0x6(%rbx)
leaq 0xa0(%rsp), %rdi
andl $0x0, 0x18(%rdi)
movq %rbx, %rsi
xorl %edx, %edx
callq 0x26d3a5
movq 0x8(%rsp), %r14
cmpb $0x0, 0x61(%r14)
jne 0x2873dd
movl 0xb8(%rsp), %eax
jmp 0x2873e0
movq 0x1f0(%rsp), %rax
testq %rax, %rax
movq 0x10(%rsp), %r12
je 0x2873fe
movq 0x50(%rax), %rsi
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
callq 0x268181
movq 0x1f0(%rsp), %rax
movq 0x48(%rax), %rsi
movq %rbx, %rdi
callq 0x267f87
jmp 0x287595
movq (%r13), %rsi
movq %r14, %rdi
callq 0x221763
movl %eax, %r12d
movq %r13, 0x40(%rsp)
testl %eax, %eax
je 0x2874ac
pushq $0x8
popq %r15
xorl %r13d, %r13d
leaq 0x70(%rsp), %rbx
movq 0x1e8(%rsp), %rbp
movswq 0x46(%rbp), %rax
cmpq %rax, %r13
jge 0x28734c
movq 0x8(%rbp), %rax
movq (%rax,%r15), %rsi
movq %rbx, %rdi
callq 0x267f87
incq %r13
addq $0x20, %r15
jmp 0x287321
addq $0x20, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x287595
leaq 0x40(%rbp), %r15
xorl %r13d, %r13d
movslq 0x28(%rbp), %rax
cmpq %rax, %r13
jge 0x2873d4
testl %r12d, %r12d
jne 0x287391
movq 0x68(%rsp), %rax
cmpl %eax, (%r15)
jne 0x287391
leaq 0xa0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %r15, %rdx
callq 0x287cc6
movq 0x10(%rbp), %rdi
movq %r14, %rsi
callq 0x221763
testl %eax, %eax
jne 0x2873cb
movq 0x8(%r15), %rbx
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x221763
testl %eax, %eax
jne 0x2873cb
leaq 0xa0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0x287cc6
incq %r13
addq $0x10, %r15
jmp 0x287364
addq $0x8, %rbp
jmp 0x287350
pushq $0x7
popq %rax
movq (%rsp), %r15
testl %eax, %eax
jne 0x2875c3
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x268025
jmp 0x287595
leaq 0xa0(%rsp), %rdi
callq 0x287cf6
testl %eax, %eax
movq 0x8(%rsp), %r14
movq (%rsp), %r15
jne 0x2875c3
leaq 0xa0(%rsp), %r14
movq 0x158(%r14), %r13
addq $0x38, %r13
leaq 0x30(%rsp), %rax
movq 0x28(%rsp), %r15
movq %rbx, %r12
movq %rax, %rbx
movq (%r13), %r13
testq %r13, %r13
je 0x287556
movq 0x18(%r13), %rdx
testq %rdx, %rdx
je 0x2874a6
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rcx
callq 0x226b48
cmpq %rbp, %rax
jne 0x2874a6
movq 0x40(%r13), %rax
testq %rax, %rax
je 0x287482
movq 0x10(%rax), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x287f32
movq 0x38(%r13), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x287fac
movq 0x30(%r13), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x287f32
addq $0x50, %r13
jmp 0x28743f
movq 0x8(%r13), %rax
movq (%rax,%r15), %rdx
leaq 0xa0(%rsp), %rdi
leaq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0x287cc6
cmpl $0x0, 0xc(%rbx)
jns 0x2874ec
leaq 0xa0(%rsp), %rdi
movq 0x148(%rdi), %rdx
addq $0x44, %rdx
leaq 0x30(%rsp), %rsi
callq 0x287cc6
movq 0x1e8(%rsp), %rax
movq 0x30(%rax), %rsi
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
callq 0x268181
movq 0x1e8(%rsp), %r15
addq $0x10, %r15
movq (%r15), %r15
testq %r15, %r15
je 0x28752b
movq 0x50(%r15), %rsi
movq %rbx, %rdi
callq 0x268181
addq $0x28, %r15
jmp 0x287511
leaq 0x1f0(%rsp), %r15
leaq 0x70(%rsp), %rbx
movq (%r15), %r15
testq %r15, %r15
je 0x287315
movq 0x50(%r15), %rsi
movq %rbx, %rdi
callq 0x268181
addq $0x28, %r15
jmp 0x287538
movq 0x1f8(%rsp), %rsi
cmpq %rbp, 0x148(%rsp)
jne 0x28758b
movq 0x20(%rsi), %rdx
leaq 0xa0(%rsp), %rbx
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rcx
callq 0x287fac
movq 0x158(%rbx), %rsi
leaq 0x70(%rsp), %rdi
callq 0x288014
leaq 0x30(%rsp), %rsi
movq (%rsp), %r15
movq %r15, %rdi
movq 0x20(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x50(%rsp), %r8
callq 0x28809c
testl %eax, %eax
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r12
je 0x2875f9
cmpq $0x0, 0xa8(%rsp)
je 0x2875ef
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
leaq 0xa0(%rsp), %r8
movq %r15, %rdi
xorl %esi, %esi
callq 0x2882a3
jmp 0x2875f9
movq %r15, %rdi
movl %eax, %esi
callq 0x224aee
leaq 0xa0(%rsp), %rdi
callq 0x288316
movq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x288397
movq %r12, 0x1c8(%r14)
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq