// File: /workspace/github_c_makefile_star2_O1/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, 0x28(%rsp)
movq (%rdi), %rax
movq 0x28(%rax), %rbx
movq (%rdx), %rdi
movl $0x1, %esi
callq 0x281c96
movq %rax, %r13
movq 0x18(%r14), %rdi
movl $0x1, %esi
callq 0x281c96
movq %rax, %r15
movq 0x20(%r14), %rdi
movl $0x1, %esi
callq 0x281c96
movq %rax, %rbp
movq 0x28(%r14), %rdi
movl $0x1, %esi
callq 0x281c96
movq %rax, %r12
movq %r14, 0x48(%rsp)
movq 0x30(%r14), %rdi
callq 0x281c1d
movq %rax, %r14
movq %r15, 0x30(%rsp)
testq %r15, %r15
setne %al
testq %rbp, %rbp
setne %cl
andb %al, %cl
movq %r12, 0x40(%rsp)
testq %r12, %r12
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x2f5e64
movq 0x1c8(%rbx), %rax
movq %rax, 0x38(%rsp)
movq $0x0, 0x1c8(%rbx)
movslq 0x28(%rbx), %rax
testq %rax, %rax
jle 0x2f5cc9
movq 0x20(%rbx), %rcx
shlq $0x5, %rax
xorl %edx, %edx
movq 0x8(%rcx,%rdx), %rsi
testq %rsi, %rsi
je 0x2f5cc0
movq (%rsi), %rdi
movq 0x8(%rsi), %rsi
movq %rdi, 0x8(%rsi)
addq $0x20, %rdx
cmpq %rdx, %rax
jne 0x2f5cab
xorps %xmm0, %xmm0
movq %rsp, %r15
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x28ad59
movq %rax, 0x10(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x70(%rsp)
leaq 0x88(%rsp), %r12
movq %r12, 0x50(%rsp)
leaq 0x10e8(%rip), %rax      # 0x2f6df8
movq %rax, 0x58(%rsp)
leaq 0x113c(%rip), %rax      # 0x2f6e58
movq %rax, 0x60(%rsp)
movq %r15, 0x78(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq 0x30(%rsp), %rcx
movl %r14d, %r8d
callq 0x2f641b
testl %eax, %eax
je 0x2f5da6
movl %eax, %r13d
testl %r13d, %r13d
jne 0x2f5d68
movq %rsp, %rsi
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rdx
movq 0x40(%rsp), %rcx
movl $0x1, %r8d
callq 0x2f6a7f
movl %eax, %r13d
testl %r13d, %r13d
je 0x2f5e2e
cmpq $0x0, 0x90(%rsp)
je 0x2f5e21
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
leaq 0x88(%rsp), %r8
movq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x2f6cd0
jmp 0x2f5e2e
movq 0x30(%rbx), %rax
movq 0x1d0(%rsp), %r14
testq %r14, %r14
je 0x2f5e76
movq 0x18(%r14), %rcx
testq %rcx, %rcx
je 0x2f5ec2
xorl %r13d, %r13d
btl $0x1a, %eax
jb 0x2f5d43
xorps %xmm0, %xmm0
leaq 0x230(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movq $0x0, 0x30(%rdx)
movq %r12, (%rdx)
andb $-0x21, 0x6(%rcx)
movq 0x18(%r14), %rsi
movq %r12, %rdi
callq 0x2d0563
cmpl $0x0, 0xb8(%rsp)
je 0x2f6012
movl 0xa0(%rsp), %r13d
jmp 0x2f5d43
movq 0x28(%rsp), %rdi
movl %r13d, %esi
callq 0x2823f0
leaq 0x88(%rsp), %rdi
callq 0x2f6d62
movq (%rsp), %rsi
testq %rsi, %rsi
je 0x2f5e58
movq 0x18(%rsi), %r14
movq %rbx, %rdi
callq 0x28c3e7
movq %r14, %rsi
testq %r14, %r14
jne 0x2f5e44
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
movq 0x1d8(%rsp), %rdx
testq %rdx, %rdx
je 0x2f5fc8
movq 0x228(%rsp), %rcx
testq %rcx, %rcx
je 0x2f609b
movq (%rdx), %rsi
cmpq %rsi, (%rcx)
je 0x2f607c
movq %rcx, %rdx
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
je 0x2f609b
cmpq %rsi, (%rcx)
jne 0x2f5ea4
addq $0x18, %rdx
jmp 0x2f6084
movl %eax, %ecx
shrl $0x1a, %ecx
btl $0xe, %eax
setae %dl
testb %dl, %cl
jne 0x2f5f8a
movq 0x20(%r14), %rcx
testq %rcx, %rcx
je 0x2f5f8a
leaq 0x228(%rsp), %rdx
movl 0x8(%rsp), %esi
movq (%rsp), %r8
leaq 0xe4b66(%rip), %rdi     # 0x3daa60
movq 0x10(%rcx), %r9
testq %r9, %r9
je 0x2f5f31
xorl %r10d, %r10d
movzbl (%r9,%r10), %r12d
movzbl (%rbp,%r10), %r13d
cmpb %r13b, %r12b
setne %r11b
je 0x2f5f27
movb (%r12,%rdi), %r15b
cmpb (%r13,%rdi), %r15b
je 0x2f5f2c
jmp 0x2f5f34
testq %r12, %r12
je 0x2f5f34
incq %r10
jmp 0x2f5f06
movb $0x1, %r11b
movq 0x228(%rsp), %r10
testq %r10, %r10
sete %r15b
orb %r11b, %r15b
jne 0x2f5f7d
movq %rdx, %r11
cmpq %r9, (%r10)
je 0x2f5f65
movq %r10, %r11
movq 0x18(%r10), %r10
testq %r10, %r10
je 0x2f5f7d
cmpq %r9, (%r10)
jne 0x2f5f50
addq $0x18, %r11
movq 0x18(%r10), %r9
movq %r9, (%r11)
movq %r8, 0x18(%r10)
movq %r10, (%rsp)
incl %esi
movl %esi, 0x8(%rsp)
movq %r10, %r8
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
jne 0x2f5efa
movq (%r14), %rcx
testq %rcx, %rcx
je 0x2f5fc0
xorl %edx, %edx
leaq 0xe4ac5(%rip), %rsi     # 0x3daa60
movzbl (%rbp,%rdx), %edi
movzbl (%rcx,%rdx), %r8d
cmpb %r8b, %dil
jne 0x2f5fb1
testq %rdi, %rdi
jne 0x2f5fbb
jmp 0x2f6025
movb (%rdi,%rsi), %dil
cmpb (%r8,%rsi), %dil
jne 0x2f5fc0
incq %rdx
jmp 0x2f5f9b
xorl %r13d, %r13d
jmp 0x2f5d43
movq 0x1e0(%rsp), %r14
movq 0x8(%r14), %rcx
testq %rcx, %rcx
je 0x2f6150
xorl %edx, %edx
leaq 0xe4a7a(%rip), %rsi     # 0x3daa60
movzbl (%rcx,%rdx), %edi
movzbl (%rbp,%rdx), %r8d
cmpb %r8b, %dil
jne 0x2f5fff
testq %rdi, %rdi
jne 0x2f600d
jmp 0x2f60cc
movb (%rdi,%rsi), %dil
cmpb (%r8,%rsi), %dil
jne 0x2f6150
incq %rdx
jmp 0x2f5fe6
movq 0x18(%r14), %rsi
leaq 0x50(%rsp), %rdi
callq 0x2ca2ea
jmp 0x2f5d43
btl $0x1a, %eax
movq %r14, 0x10(%rsp)
jb 0x2f603e
movq 0x30(%r14), %rsi
leaq 0x50(%rsp), %rdi
callq 0x2ca44f
movq 0x228(%rsp), %rax
xorl %r13d, %r13d
testq %rax, %rax
je 0x2f5d43
movq (%r14), %rdx
cmpq %rdx, (%rax)
je 0x2f610d
movq %rax, %rcx
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2f5d43
cmpq %rdx, (%rax)
jne 0x2f605e
addq $0x18, %rcx
jmp 0x2f6115
leaq 0x228(%rsp), %rdx
movq 0x18(%rcx), %rsi
movq %rsi, (%rdx)
movq (%rsp), %rdx
movq %rdx, 0x18(%rcx)
movq %rcx, (%rsp)
incl 0x8(%rsp)
xorl %r13d, %r13d
btl $0x1a, %eax
jb 0x2f5d43
movq 0x1d8(%rsp), %rax
movq 0x48(%rax), %rsi
testq %rsi, %rsi
je 0x2f5d43
leaq 0x50(%rsp), %rdi
callq 0x2ca211
jmp 0x2f5d43
movq 0x10(%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 0x2f6150
cmpq %rcx, (%rdx)
je 0x2f6131
movq %rdx, %rsi
movq 0x18(%rdx), %rdx
testq %rdx, %rdx
je 0x2f6150
cmpq %rcx, (%rdx)
jne 0x2f60f6
addq $0x18, %rsi
jmp 0x2f6139
leaq 0x228(%rsp), %rcx
movq 0x18(%rax), %rdx
movq %rdx, (%rcx)
movq (%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %rax, (%rsp)
incl 0x8(%rsp)
jmp 0x2f5d43
leaq 0x228(%rsp), %rsi
movq 0x18(%rdx), %rcx
movq %rcx, (%rsi)
movq (%rsp), %rcx
movq %rcx, 0x18(%rdx)
movq %rdx, (%rsp)
incl 0x8(%rsp)
xorl %r13d, %r13d
btl $0x1a, %eax
jb 0x2f5d43
leaq 0x88(%rsp), %rdi
callq 0x2f65d4
testl %eax, %eax
jne 0x2f5d40
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x2f69e3
movq 0x38(%r14), %rax
testq %rax, %rax
je 0x2f5d43
leaq 0x228(%rsp), %rcx
movl 0x8(%rsp), %edx
movq (%rsp), %rdi
leaq 0xe48bd(%rip), %rsi     # 0x3daa60
xorl %r13d, %r13d
movq 0x18(%rax), %r8
testq %r8, %r8
je 0x2f6228
xorl %r9d, %r9d
movzbl (%r8,%r9), %r10d
movzbl (%rbp,%r9), %r11d
cmpb %r11b, %r10b
je 0x2f61ce
movb (%r10,%rsi), %r14b
cmpb (%r11,%rsi), %r14b
je 0x2f61d3
jmp 0x2f61d8
testq %r10, %r10
je 0x2f61d8
incq %r9
jmp 0x2f61b2
cmpb %r11b, %r10b
setne %r10b
movq 0x228(%rsp), %r9
testq %r9, %r9
sete %r11b
orb %r10b, %r11b
jne 0x2f6228
movq %rcx, %r10
cmpq %r8, (%r9)
je 0x2f6210
movq %r9, %r10
movq 0x18(%r9), %r9
testq %r9, %r9
je 0x2f6228
cmpq %r8, (%r9)
jne 0x2f61fb
addq $0x18, %r10
movq 0x18(%r9), %r8
movq %r8, (%r10)
movq %rdi, 0x18(%r9)
movq %r9, (%rsp)
incl %edx
movl %edx, 0x8(%rsp)
movq %r9, %rdi
movq 0x50(%rax), %rax
testq %rax, %rax
jne 0x2f61a6
jmp 0x2f5d43