// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: renameTableFunc
static void renameTableFunc(
  sqlite3_context *context,
  int NotUsed,
  sqlite3_value **argv
){
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zDb = (const char*)sqlite3_value_text(argv[0]);
  const char *zInput = (const char*)sqlite3_value_text(argv[3]);
  const char *zOld = (const char*)sqlite3_value_text(argv[4]);
  const char *zNew = (const char*)sqlite3_value_text(argv[5]);
  int bTemp = sqlite3_value_int(argv[6]);
  UNUSED_PARAMETER(NotUsed);

  if( zInput && zOld && zNew ){
    Parse sParse;
    int rc;
    int bQuote = 1;
    RenameCtx sCtx;
    Walker sWalker;

#ifndef SQLITE_OMIT_AUTHORIZATION
    sqlite3_xauth xAuth = db->xAuth;
    db->xAuth = 0;
#endif

    sqlite3BtreeEnterAll(db);

    memset(&sCtx, 0, sizeof(RenameCtx));
    sCtx.pTab = sqlite3FindTable(db, zOld, zDb);
    memset(&sWalker, 0, sizeof(Walker));
    sWalker.pParse = &sParse;
    sWalker.xExprCallback = renameTableExprCb;
    sWalker.xSelectCallback = renameTableSelectCb;
    sWalker.u.pRename = &sCtx;

    rc = renameParseSql(&sParse, zDb, db, zInput, bTemp);

    if( rc==SQLITE_OK ){
      int isLegacy = (db->flags & SQLITE_LegacyAlter);
      if( sParse.pNewTable ){
        Table *pTab = sParse.pNewTable;

        if( pTab->pSelect ){
          if( isLegacy==0 ){
            Select *pSelect = pTab->pSelect;
            NameContext sNC;
            memset(&sNC, 0, sizeof(sNC));
            sNC.pParse = &sParse;

            assert( pSelect->selFlags & SF_View );
            pSelect->selFlags &= ~SF_View;
            sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);
            if( sParse.nErr ){
              rc = sParse.rc;
            }else{
              sqlite3WalkSelect(&sWalker, pTab->pSelect);
            }
          }
        }else{
          /* Modify any FK definitions to point to the new table. */
#ifndef SQLITE_OMIT_FOREIGN_KEY
          if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){
            FKey *pFKey;
            for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
              if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
                renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
              }
            }
          }
#endif

          /* If this is the table being altered, fix any table refs in CHECK
          ** expressions. Also update the name that appears right after the
          ** "CREATE [VIRTUAL] TABLE" bit. */
          if( sqlite3_stricmp(zOld, pTab->zName)==0 ){
            sCtx.pTab = pTab;
            if( isLegacy==0 ){
              sqlite3WalkExprList(&sWalker, pTab->pCheck);
            }
            renameTokenFind(&sParse, &sCtx, pTab->zName);
          }
        }
      }

      else if( sParse.pNewIndex ){
        renameTokenFind(&sParse, &sCtx, sParse.pNewIndex->zName);
        if( isLegacy==0 ){
          sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
        }
      }

#ifndef SQLITE_OMIT_TRIGGER
      else{
        Trigger *pTrigger = sParse.pNewTrigger;
        TriggerStep *pStep;
        if( 0==sqlite3_stricmp(sParse.pNewTrigger->table, zOld)
            && sCtx.pTab->pSchema==pTrigger->pTabSchema
          ){
          renameTokenFind(&sParse, &sCtx, sParse.pNewTrigger->table);
        }

        if( isLegacy==0 ){
          rc = renameResolveTrigger(&sParse);
          if( rc==SQLITE_OK ){
            renameWalkTrigger(&sWalker, pTrigger);
            for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){
              if( pStep->zTarget && 0==sqlite3_stricmp(pStep->zTarget, zOld) ){
                renameTokenFind(&sParse, &sCtx, pStep->zTarget);
              }
            }
          }
        }
      }
#endif
    }

    if( rc==SQLITE_OK ){
      rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
    }
    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);
    sqlite3BtreeLeaveAll(db);
#ifndef SQLITE_OMIT_AUTHORIZATION
    db->xAuth = xAuth;
#endif
  }

  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rdx, %r14
movq %rdi, %r12
movq (%rdi), %rax
movq 0x28(%rax), %rbx
movq (%rdx), %rdi
callq 0x2243e3
movq %rax, 0x50(%rsp)
movq 0x18(%r14), %rdi
callq 0x2243e3
movq %rax, %rbp
movq 0x20(%r14), %rdi
callq 0x2243e3
movq %rax, %r13
movq 0x28(%r14), %rdi
callq 0x2243e3
movq %rax, %r15
movq %r14, 0x48(%rsp)
movq 0x30(%r14), %rdi
callq 0x224451
movq %rax, %r14
testq %rbp, %rbp
setne %al
testq %r13, %r13
setne %cl
andb %al, %cl
movq %r15, 0x40(%rsp)
testq %r15, %r15
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x2879fd
movq %r12, 0x8(%rsp)
movq 0x1c8(%rbx), %rax
movq %rax, 0x38(%rsp)
andq $0x0, 0x1c8(%rbx)
movq %rbx, %rdi
callq 0x21f0e2
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r12
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
movq %rbx, %rdi
movq %r13, %rsi
movq 0x50(%rsp), %r15
movq %r15, %rdx
callq 0x22beb2
movq %rax, 0x10(%r12)
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rsp)
leaq 0x88(%rsp), %rcx
movq %rcx, 0x58(%rsp)
leaq 0xca5(%rip), %rax       # 0x2883bc
movq %rax, 0x60(%rsp)
leaq 0xcc3(%rip), %rax       # 0x2883e6
movq %rax, 0x68(%rsp)
movq %r12, 0x80(%rsp)
movq %rcx, %r12
movq %rcx, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
movl %r14d, %r8d
callq 0x287ba0
testl %eax, %eax
jne 0x28799d
movq %r13, %r15
movq %r12, %rdi
movq 0x30(%rbx), %r12
movq 0x1d0(%rsp), %r14
testq %r14, %r14
movq %rbp, 0x30(%rsp)
je 0x2877c8
movq 0x18(%r14), %rsi
testq %rsi, %rsi
je 0x287814
btl $0x1a, %r12d
jb 0x28797c
xorps %xmm0, %xmm0
leaq 0x230(%rsp), %rdx
movups %xmm0, 0x28(%rdx)
movups %xmm0, 0x18(%rdx)
movups %xmm0, 0x8(%rdx)
movq %rdi, (%rdx)
andb $-0x21, 0x6(%rsi)
callq 0x26d3a5
cmpl $0x0, 0xb8(%rsp)
je 0x28796e
movl 0xa0(%rsp), %eax
testl %eax, %eax
jne 0x28799d
jmp 0x28797c
movq 0x1d8(%rsp), %rax
testq %rax, %rax
je 0x287879
movq (%rax), %rdx
leaq 0x88(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x287cc6
btl $0x1a, %r12d
jb 0x28797c
movq 0x1d8(%rsp), %rax
movq 0x48(%rax), %rsi
leaq 0x58(%rsp), %rdi
callq 0x267f87
jmp 0x28797c
movl %r12d, %eax
shrl $0x1a, %eax
movq %r12, %rbp
btl $0xe, %r12d
setae %cl
testb %cl, %al
je 0x28792e
movq (%r14), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x221763
testl %eax, %eax
jne 0x28797c
btl $0x1a, %ebp
movq %r14, 0x20(%rsp)
jb 0x28785f
movq 0x30(%r14), %rsi
leaq 0x58(%rsp), %rdi
callq 0x268181
movq (%r14), %r12
leaq 0x88(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x287cc6
jmp 0x28797c
movq %r12, %r14
movq 0x1e0(%rsp), %r13
movq 0x8(%r13), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x221763
testl %eax, %eax
jne 0x2878bb
movq 0x20(%rsp), %rax
movq 0x70(%rax), %rax
cmpq 0x30(%r13), %rax
jne 0x2878bb
leaq 0x88(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x287cc6
btl $0x1a, %r14d
jb 0x28797c
leaq 0x88(%rsp), %rdi
callq 0x287cf6
testl %eax, %eax
jne 0x28799d
leaq 0x58(%rsp), %rdi
movq %r13, %rsi
callq 0x288014
addq $0x38, %r13
leaq 0x88(%rsp), %rbp
leaq 0x10(%rsp), %r12
movq (%r13), %r13
testq %r13, %r13
je 0x28797c
movq 0x18(%r13), %r14
testq %r14, %r14
je 0x287928
movq %r14, %rdi
movq %r15, %rsi
callq 0x221779
testl %eax, %eax
jne 0x287928
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x287cc6
addq $0x50, %r13
jmp 0x2878f9
leaq 0x20(%r14), %r12
movq (%r12), %r12
testq %r12, %r12
je 0x28782d
movq 0x10(%r12), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x221763
testl %eax, %eax
jne 0x287968
leaq 0x88(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r13, %rdx
callq 0x287cc6
addq $0x8, %r12
jmp 0x287932
movq 0x18(%r14), %rsi
leaq 0x58(%rsp), %rdi
callq 0x268025
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %r8
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rdx
movq 0x40(%rsp), %rcx
callq 0x28809c
testl %eax, %eax
je 0x2879d7
cmpq $0x0, 0x90(%rsp)
je 0x2879cb
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
leaq 0x88(%rsp), %r8
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x2882a3
jmp 0x2879d7
movq 0x8(%rsp), %rdi
movl %eax, %esi
callq 0x224aee
leaq 0x88(%rsp), %rdi
callq 0x288316
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x288397
movq 0x38(%rsp), %rax
movq %rax, 0x1c8(%rbx)
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq