// File: /workspace/github_c_makefile_star2_O3/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, %r12
movq %rdi, %r15
movq (%rdi), %rax
movq 0x28(%rax), %rbx
movq (%rdx), %rdi
movl $0x1, %esi
callq 0x278305
movq %rax, 0x48(%rsp)
movq 0x18(%r12), %rdi
movl $0x1, %esi
callq 0x278305
movq %rax, %r14
movq 0x20(%r12), %rdi
movl $0x1, %esi
callq 0x278305
movq %rax, %rbp
movq 0x28(%r12), %rdi
movl $0x1, %esi
callq 0x278305
movq %rax, %r13
movq 0x30(%r12), %rdi
callq 0x27828c
movq %r14, 0x50(%rsp)
testq %r14, %r14
setne %dl
testq %rbp, %rbp
setne %cl
andb %dl, %cl
movq %r13, 0x40(%rsp)
testq %r13, %r13
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x2ecf16
movq %rax, %r13
movq 0x1c8(%rbx), %rax
movq %rax, 0x38(%rsp)
movq $0x0, 0x1c8(%rbx)
movslq 0x28(%rbx), %rax
testq %rax, %rax
jle 0x2ec9e0
movq 0x20(%rbx), %rcx
shlq $0x5, %rax
xorl %edx, %edx
movq 0x8(%rcx,%rdx), %rsi
testq %rsi, %rsi
je 0x2ec9d7
movq (%rsi), %rdi
movq 0x8(%rsi), %rsi
movq %rdi, 0x8(%rsi)
addq $0x20, %rdx
cmpq %rdx, %rax
jne 0x2ec9c2
movq %r12, 0x30(%rsp)
movq %r15, 0x8(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movq %rbx, %rdi
movq %rbp, %rsi
movq 0x48(%rsp), %r14
movq %r14, %rdx
callq 0x2811f8
movq %rax, 0x10(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rsp)
leaq 0x88(%rsp), %r12
movq %r12, 0x58(%rsp)
leaq 0x10d4(%rip), %rax      # 0x2edb02
movq %rax, 0x60(%rsp)
leaq 0x1128(%rip), %rax      # 0x2edb62
movq %rax, 0x68(%rsp)
movq %r15, 0x80(%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq 0x50(%rsp), %r15
movq %r15, %rcx
movl %r13d, %r8d
callq 0x2ed106
testl %eax, %eax
je 0x2eca6e
movq 0x8(%rsp), %r13
jmp 0x2ecea9
movq 0x30(%rbx), %rax
movq 0x1d0(%rsp), %r14
testq %r14, %r14
je 0x2ecae3
movq 0x18(%r14), %rsi
testq %rsi, %rsi
je 0x2ecb34
btl $0x1a, %eax
movq 0x8(%rsp), %r13
jb 0x2ece8a
xorps %xmm0, %xmm0
leaq 0x230(%rsp), %rdx
movups %xmm0, 0x28(%rdx)
movups %xmm0, 0x18(%rdx)
movups %xmm0, 0x8(%rdx)
movq %r12, (%rdx)
andb $-0x21, 0x6(%rsi)
movq %r12, %rdi
callq 0x2c6ee7
cmpl $0x0, 0xb8(%rsp)
je 0x2ecc7d
movl 0xa0(%rsp), %eax
testl %eax, %eax
jne 0x2ecea9
jmp 0x2ece8a
movq 0x1d8(%rsp), %rdx
testq %rdx, %rdx
je 0x2ecc2e
movq 0x228(%rsp), %rcx
testq %rcx, %rcx
movq 0x8(%rsp), %r13
je 0x2ecd05
movq (%rdx), %rsi
cmpq %rsi, (%rcx)
je 0x2ecce4
movq %rcx, %rdx
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
je 0x2ecd05
cmpq %rsi, (%rcx)
jne 0x2ecb16
addq $0x18, %rdx
jmp 0x2eccec
movl %eax, %ecx
shrl $0x1a, %ecx
btl $0xe, %eax
setae %dl
testb %dl, %cl
movq 0x8(%rsp), %r13
jne 0x2ecbf0
movq 0x20(%r14), %rcx
testq %rcx, %rcx
je 0x2ecbf0
leaq 0x228(%rsp), %rdx
movl 0x18(%rsp), %esi
movq 0x10(%rsp), %r8
leaq 0xe476e(%rip), %rdi     # 0x3d12e0
movq 0x10(%rcx), %r9
testq %r9, %r9
je 0x2ecbe7
xorl %r10d, %r10d
movzbl (%r9,%r10), %r11d
movzbl (%rbp,%r10), %r12d
cmpb %r12b, %r11b
jne 0x2ecb95
testq %r11, %r11
jne 0x2ecb9f
jmp 0x2ecba4
movb (%r11,%rdi), %r11b
cmpb (%r12,%rdi), %r11b
jne 0x2ecbe7
incq %r10
jmp 0x2ecb7e
movq 0x228(%rsp), %r10
testq %r10, %r10
je 0x2ecbe7
movq %rdx, %r11
cmpq %r9, (%r10)
je 0x2ecbce
movq %r10, %r11
movq 0x18(%r10), %r10
testq %r10, %r10
je 0x2ecbe7
cmpq %r9, (%r10)
jne 0x2ecbb9
addq $0x18, %r11
movq 0x18(%r10), %r9
movq %r9, (%r11)
movq %r8, 0x18(%r10)
movq %r10, 0x10(%rsp)
incl %esi
movl %esi, 0x18(%rsp)
movq %r10, %r8
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
jne 0x2ecb72
movq (%r14), %rcx
testq %rcx, %rcx
je 0x2ece8a
xorl %edx, %edx
leaq 0xe46db(%rip), %rsi     # 0x3d12e0
movzbl (%rbp,%rdx), %edi
movzbl (%rcx,%rdx), %r8d
cmpb %r8b, %dil
jne 0x2ecc1b
testq %rdi, %rdi
jne 0x2ecc29
jmp 0x2ecc90
movb (%rdi,%rsi), %dil
cmpb (%r8,%rsi), %dil
jne 0x2ece8a
incq %rdx
jmp 0x2ecc05
movq 0x1e0(%rsp), %r14
movq 0x8(%r14), %rcx
testq %rcx, %rcx
movq 0x8(%rsp), %r13
je 0x2ecdbb
xorl %edx, %edx
leaq 0xe468f(%rip), %rsi     # 0x3d12e0
movzbl (%rcx,%rdx), %edi
movzbl (%rbp,%rdx), %r8d
cmpb %r8b, %dil
jne 0x2ecc6a
testq %rdi, %rdi
jne 0x2ecc78
jmp 0x2ecd33
movb (%rdi,%rsi), %dil
cmpb (%r8,%rsi), %dil
jne 0x2ecdbb
incq %rdx
jmp 0x2ecc51
movq 0x18(%r14), %rsi
leaq 0x58(%rsp), %rdi
callq 0x2c0b5b
jmp 0x2ece8a
btl $0x1a, %eax
movq %r14, 0x20(%rsp)
jb 0x2eccac
movq 0x30(%r14), %rsi
leaq 0x58(%rsp), %rdi
callq 0x2c0cc0
movq (%r14), %rcx
movq 0x228(%rsp), %rax
testq %rax, %rax
je 0x2ece8a
cmpq %rcx, (%rax)
je 0x2ecd74
movq %rax, %rdx
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2ece8a
cmpq %rcx, (%rax)
jne 0x2eccc6
addq $0x18, %rdx
jmp 0x2ecd7c
leaq 0x228(%rsp), %rdx
movq 0x18(%rcx), %rsi
movq %rsi, (%rdx)
movq 0x10(%rsp), %rdx
movq %rdx, 0x18(%rcx)
movq %rcx, 0x10(%rsp)
incl 0x18(%rsp)
btl $0x1a, %eax
jb 0x2ece8a
movq 0x1d8(%rsp), %rax
movq 0x48(%rax), %rsi
testq %rsi, %rsi
je 0x2ece8a
leaq 0x58(%rsp), %rdi
callq 0x2c0a8c
jmp 0x2ece8a
movq 0x20(%rsp), %rdx
movq 0x70(%rdx), %rdx
cmpq 0x30(%r14), %rdx
setne %sil
movq 0x228(%rsp), %rdx
testq %rdx, %rdx
sete %dil
orb %sil, %dil
jne 0x2ecdbb
cmpq %rcx, (%rdx)
je 0x2ecd9a
movq %rdx, %rsi
movq 0x18(%rdx), %rdx
testq %rdx, %rdx
je 0x2ecdbb
cmpq %rcx, (%rdx)
jne 0x2ecd5d
addq $0x18, %rsi
jmp 0x2ecda2
leaq 0x228(%rsp), %rdx
movq 0x18(%rax), %rcx
movq %rcx, (%rdx)
movq 0x10(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %rax, 0x10(%rsp)
incl 0x18(%rsp)
jmp 0x2ece8a
leaq 0x228(%rsp), %rsi
movq 0x18(%rdx), %rcx
movq %rcx, (%rsi)
movq 0x10(%rsp), %rcx
movq %rcx, 0x18(%rdx)
movq %rdx, 0x10(%rsp)
incl 0x18(%rsp)
btl $0x1a, %eax
jb 0x2ece8a
leaq 0x88(%rsp), %rdi
callq 0x2ed2c3
testl %eax, %eax
jne 0x2ecea9
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x2ed6cf
movq 0x38(%r14), %rax
testq %rax, %rax
je 0x2ece8a
leaq 0x228(%rsp), %rcx
movl 0x18(%rsp), %edx
movq 0x10(%rsp), %rdi
leaq 0xe44d4(%rip), %rsi     # 0x3d12e0
movq 0x18(%rax), %r8
testq %r8, %r8
je 0x2ece81
xorl %r9d, %r9d
movzbl (%r8,%r9), %r10d
movzbl (%rbp,%r9), %r11d
cmpb %r11b, %r10b
jne 0x2ece2f
testq %r10, %r10
jne 0x2ece39
jmp 0x2ece3e
movb (%r10,%rsi), %r10b
cmpb (%r11,%rsi), %r10b
jne 0x2ece81
incq %r9
jmp 0x2ece18
movq 0x228(%rsp), %r9
testq %r9, %r9
je 0x2ece81
movq %rcx, %r10
cmpq %r8, (%r9)
je 0x2ece68
movq %r9, %r10
movq 0x18(%r9), %r9
testq %r9, %r9
je 0x2ece81
cmpq %r8, (%r9)
jne 0x2ece53
addq $0x18, %r10
movq 0x18(%r9), %r8
movq %r8, (%r10)
movq %rdi, 0x18(%r9)
movq %r9, 0x10(%rsp)
incl %edx
movl %edx, 0x18(%rsp)
movq %r9, %rdi
movq 0x50(%rax), %rax
testq %rax, %rax
jne 0x2ece0c
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
movq %r15, %rdx
movq 0x40(%rsp), %rcx
movl $0x1, %r8d
callq 0x2ed76b
testl %eax, %eax
je 0x2ecedf
cmpq $0x0, 0x90(%rsp)
je 0x2eced5
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
leaq 0x88(%rsp), %r8
movq %r13, %rdi
xorl %esi, %esi
callq 0x2ed9da
jmp 0x2ecedf
movq %r13, %rdi
movl %eax, %esi
callq 0x278a51
leaq 0x88(%rsp), %rdi
callq 0x2eda6c
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x2ecf0a
movq 0x18(%rsi), %r14
movq %rbx, %rdi
callq 0x282904
movq %r14, %rsi
testq %r14, %r14
jne 0x2ecef6
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