// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3c9230
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x3c7880
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x3c7880
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x3c7880
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x3c7880
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3c7a40
movl %eax, -0x44(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x46932d
cmpq $0x0, -0x38(%rbp)
je 0x46932d
cmpq $0x0, -0x40(%rbp)
je 0x46932d
movl $0x1, -0x1f8(%rbp)
movq -0x20(%rbp), %rax
movq 0x1c8(%rax), %rax
movq %rax, -0x250(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, 0x1c8(%rax)
movq -0x20(%rbp), %rdi
callq 0x3bfd40
leaq -0x218(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x19360
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x3d38b0
movq %rax, -0x208(%rbp)
leaq -0x248(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x19360
leaq -0x1f0(%rbp), %rax
movq %rax, -0x248(%rbp)
leaq 0x1342(%rip), %rax      # 0x46a230
movq %rax, -0x240(%rbp)
leaq 0x1394(%rip), %rax      # 0x46a290
movq %rax, -0x238(%rbp)
leaq -0x218(%rbp), %rax
movq %rax, -0x220(%rbp)
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl -0x44(%rbp), %r8d
leaq -0x1f0(%rbp), %rdi
callq 0x469540
movl %eax, -0x1f4(%rbp)
cmpl $0x0, -0x1f4(%rbp)
jne 0x469289
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
andq $0x4000000, %rax        # imm = 0x4000000
movl %eax, -0x254(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0x46911a
movq -0xa8(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0x260(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x469028
cmpl $0x0, -0x254(%rbp)
jne 0x469023
movq -0x260(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x268(%rbp)
leaq -0x2a0(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x19360
leaq -0x1f0(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x268(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0xffdfffff, %ecx       # imm = 0xFFDFFFFF
movl %ecx, 0x4(%rax)
movq -0x260(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x1f0(%rbp), %rdi
leaq -0x2a0(%rbp), %rdx
callq 0x438710
cmpl $0x0, -0x1c0(%rbp)
je 0x46900a
movl -0x1d8(%rbp), %eax
movl %eax, -0x1f4(%rbp)
jmp 0x469021
movq -0x260(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x248(%rbp), %rdi
callq 0x42f7d0
jmp 0x469023
jmp 0x469115
cmpl $0x0, -0x254(%rbp)
je 0x469045
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
andq $0x4000, %rax           # imm = 0x4000
cmpq $0x0, %rax
je 0x4690b0
movq -0x260(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x2a8(%rbp)
cmpq $0x0, -0x2a8(%rbp)
je 0x4690ae
movq -0x2a8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x3c3e00
cmpl $0x0, %eax
jne 0x469098
movq -0x2a8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq -0x1f0(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x469760
jmp 0x46909a
movq -0x2a8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x2a8(%rbp)
jmp 0x469057
jmp 0x4690b0
movq -0x38(%rbp), %rdi
movq -0x260(%rbp), %rax
movq (%rax), %rsi
callq 0x3c3e00
cmpl $0x0, %eax
jne 0x469113
movq -0x260(%rbp), %rax
movq %rax, -0x208(%rbp)
cmpl $0x0, -0x254(%rbp)
jne 0x4690f6
movq -0x260(%rbp), %rax
movq 0x30(%rax), %rsi
leaq -0x248(%rbp), %rdi
callq 0x42f8b0
movq -0x260(%rbp), %rax
movq (%rax), %rdx
leaq -0x1f0(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x469760
jmp 0x469115
jmp 0x469287
cmpq $0x0, -0xa0(%rbp)
je 0x469166
movq -0xa0(%rbp), %rax
movq (%rax), %rdx
leaq -0x1f0(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x469760
cmpl $0x0, -0x254(%rbp)
jne 0x469161
movq -0xa0(%rbp), %rax
movq 0x48(%rax), %rsi
leaq -0x248(%rbp), %rdi
callq 0x42f650
jmp 0x469285
movq -0x98(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x3c3e00
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x4691c6
movq -0x208(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x2b0(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jne 0x4691c6
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rdx
leaq -0x1f0(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x469760
cmpl $0x0, -0x254(%rbp)
jne 0x469283
leaq -0x1f0(%rbp), %rdi
callq 0x4697f0
movl %eax, -0x1f4(%rbp)
cmpl $0x0, -0x1f4(%rbp)
jne 0x469281
movq -0x2b0(%rbp), %rsi
leaq -0x248(%rbp), %rdi
callq 0x469cf0
movq -0x2b0(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x2b8(%rbp)
cmpq $0x0, -0x2b8(%rbp)
je 0x46927f
movq -0x2b8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x469269
movq -0x2b8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x3c3e00
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x469269
movq -0x2b8(%rbp), %rax
movq 0x18(%rax), %rdx
leaq -0x1f0(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x469760
jmp 0x46926b
movq -0x2b8(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x2b8(%rbp)
jmp 0x469217
jmp 0x469281
jmp 0x469283
jmp 0x469285
jmp 0x469287
jmp 0x469289
cmpl $0x0, -0x1f4(%rbp)
jne 0x4692b7
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl -0x1f8(%rbp), %r8d
leaq -0x218(%rbp), %rsi
callq 0x469dd0
movl %eax, -0x1f4(%rbp)
cmpl $0x0, -0x1f4(%rbp)
je 0x4692ff
cmpq $0x0, -0x1e8(%rbp)
je 0x4692ee
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
xorl %esi, %esi
leaq -0x1f0(%rbp), %r8
callq 0x469ff0
jmp 0x4692fd
movq -0x8(%rbp), %rdi
movl -0x1f4(%rbp), %esi
callq 0x3c8a00
jmp 0x4692ff
leaq -0x1f0(%rbp), %rdi
callq 0x46a080
movq -0x20(%rbp), %rdi
movq -0x218(%rbp), %rsi
callq 0x46a150
movq -0x250(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x1c8(%rax)
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
nopw %cs:(%rax,%rax)