// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3AlterRenameColumn
SQLITE_PRIVATE void sqlite3AlterRenameColumn(
  Parse *pParse,                  /* Parsing context */
  SrcList *pSrc,                  /* Table being altered.  pSrc->nSrc==1 */
  Token *pOld,                    /* Name of column being changed */
  Token *pNew                     /* New column name */
){
  sqlite3 *db = pParse->db;       /* Database connection */
  Table *pTab;                    /* Table being updated */
  int iCol;                       /* Index of column being renamed */
  char *zOld = 0;                 /* Old column name */
  char *zNew = 0;                 /* New column name */
  const char *zDb;                /* Name of schema containing the table */
  int iSchema;                    /* Index of the schema */
  int bQuote;                     /* True to quote the new name */

  /* Locate the table to be altered */
  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);
  if( !pTab ) goto exit_rename_column;

  /* Cannot alter a system table */
  if( SQLITE_OK!=isAlterableTable(pParse, pTab) ) goto exit_rename_column;
  if( SQLITE_OK!=isRealTable(pParse, pTab) ) goto exit_rename_column;

  /* Which schema holds the table to be altered */
  iSchema = sqlite3SchemaToIndex(db, pTab->pSchema);
  assert( iSchema>=0 );
  zDb = db->aDb[iSchema].zDbSName;

#ifndef SQLITE_OMIT_AUTHORIZATION
  /* Invoke the authorization callback. */
  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){
    goto exit_rename_column;
  }
#endif

  /* Make sure the old name really is a column name in the table to be
  ** altered.  Set iCol to be the index of the column being renamed */
  zOld = sqlite3NameFromToken(db, pOld);
  if( !zOld ) goto exit_rename_column;
  for(iCol=0; iCol<pTab->nCol; iCol++){
    if( 0==sqlite3StrICmp(pTab->aCol[iCol].zName, zOld) ) break;
  }
  if( iCol==pTab->nCol ){
    sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zOld);
    goto exit_rename_column;
  }

  /* Do the rename operation using a recursive UPDATE statement that
  ** uses the sqlite_rename_column() SQL function to compute the new
  ** CREATE statement text for the sqlite_schema table.
  */
  sqlite3MayAbort(pParse);
  zNew = sqlite3NameFromToken(db, pNew);
  if( !zNew ) goto exit_rename_column;
  assert( pNew->n>0 );
  bQuote = sqlite3Isquote(pNew->z[0]);
  sqlite3NestedParse(pParse,
      "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET "
      "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, %d) "
      "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' "
      " AND (type != 'index' OR tbl_name = %Q)"
      " AND sql NOT LIKE 'create virtual%%'",
      zDb,
      zDb, pTab->zName, iCol, zNew, bQuote, iSchema==1,
      pTab->zName
  );

  sqlite3NestedParse(pParse,
      "UPDATE temp." DFLT_SCHEMA_TABLE " SET "
      "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, 1) "
      "WHERE type IN ('trigger', 'view')",
      zDb, pTab->zName, iCol, zNew, bQuote
  );

  /* Drop and reload the database schema. */
  renameReloadSchema(pParse, iSchema);
  renameTestSchema(pParse, zDb, iSchema==1);

 exit_rename_column:
  sqlite3SrcListDelete(db, pSrc);
  sqlite3DbFree(db, zOld);
  sqlite3DbFree(db, zNew);
  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %rbp
movq %rdx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rbx
leaq 0x8(%rsi), %rdx
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x2d1ce5
testq %rax, %rax
movq %r14, 0x20(%rsp)
je 0x2c54c4
movq %rax, %r13
movq %r15, %rdi
movq %rax, %rsi
callq 0x2f31a4
testl %eax, %eax
je 0x2c5445
xorl %r12d, %r12d
jmp 0x2c54c4
movq 0x18(%r13), %rax
testq %rax, %rax
sete %dl
movl 0x54(%r13), %ecx
testl %ecx, %ecx
sete %sil
testb %dl, %sil
je 0x2c5491
movq 0x70(%r13), %rax
testq %rax, %rax
movq %rbp, (%rsp)
je 0x2c5510
movq 0x20(%rbx), %rcx
addq $0x18, %rcx
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
incl %r14d
leaq 0x20(%rcx), %rdx
cmpq %rax, (%rcx)
movq %rdx, %rcx
jne 0x2c547d
jmp 0x2c5516
testq %rax, %rax
leaq 0x11d148(%rip), %rsi    # 0x3e25e3
cmoveq %rax, %rsi
testl %ecx, %ecx
leaq 0x11e0c9(%rip), %rdx    # 0x3e3571
cmoveq %rsi, %rdx
movq (%r13), %rcx
leaq 0x11e0c8(%rip), %rsi    # 0x3e357f
xorl %r12d, %r12d
movq %r15, %rdi
xorl %eax, %eax
callq 0x284eb8
xorl %ebp, %ebp
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x2affb4
testq %rbp, %rbp
je 0x2c54e3
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x28c3e7
testq %r12, %r12
je 0x2c5501
movq %rbx, %rdi
movq %r12, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x28c3e7
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffff8000, %r14d      # imm = 0xFFFF8000
movq 0x20(%rbx), %rax
movslq %r14d, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rdx
movq (%r13), %rcx
xorl %r12d, %r12d
movq %r15, %rdi
movl $0x1a, %esi
movq %rdx, 0x10(%rsp)
xorl %r8d, %r8d
callq 0x2cceea
movl $0x0, %ebp
testl %eax, %eax
jne 0x2c54c6
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x2bb67d
xorl %r12d, %r12d
testq %rax, %rax
je 0x2c54c4
movq %rax, %rbp
movswl 0x46(%r13), %eax
testl %eax, %eax
jle 0x2c55c7
movq 0x8(%r13), %rcx
movl %eax, %edx
xorl %r12d, %r12d
leaq 0x1154dd(%rip), %rsi    # 0x3daa60
movq %r12, %rdi
shlq $0x5, %rdi
movq (%rcx,%rdi), %rdi
xorl %r8d, %r8d
movzbl (%rdi,%r8), %r9d
movzbl (%rbp,%r8), %r10d
cmpb %r10b, %r9b
jne 0x2c55a8
testq %r9, %r9
jne 0x2c55b2
jmp 0x2c55b7
movb (%r9,%rsi), %r11b
cmpb (%r10,%rsi), %r11b
jne 0x2c55b7
incq %r8
jmp 0x2c5591
cmpb %r10b, %r9b
je 0x2c55c7
incq %r12
cmpq %rdx, %r12
jne 0x2c5583
movl %eax, %r12d
cmpl %eax, %r12d
jne 0x2c55e8
leaq 0x119ae9(%rip), %rsi    # 0x3df0bc
xorl %r12d, %r12d
movq %r15, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x284eb8
jmp 0x2c54c6
movq 0xa0(%r15), %rax
testq %rax, %rax
cmoveq %r15, %rax
movb $0x1, 0x21(%rax)
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x2bb67d
testq %rax, %rax
je 0x2c56c5
movq %rax, %r10
movq (%rsp), %rax
movq (%rax), %rax
movzbl (%rax), %eax
leaq 0x11559d(%rip), %rcx    # 0x3dabc0
movzbl (%rax,%rcx), %eax
andl $-0x80, %eax
movq %rax, 0x8(%rsp)
movq (%r13), %r8
xorl %eax, %eax
cmpl $0x1, %r14d
sete %al
movq %rax, %r11
movq %rax, (%rsp)
leaq 0x11ddca(%rip), %rsi    # 0x3e3414
movq %r15, %rdi
movq 0x10(%rsp), %rcx
movq %rcx, %rdx
movl %r12d, %r9d
xorl %eax, %eax
pushq %r8
pushq %r11
pushq 0x18(%rsp)
pushq %r10
movq %r10, 0x38(%rsp)
callq 0x2cdd65
addq $0x20, %rsp
movq (%r13), %rcx
subq $0x8, %rsp
leaq 0x11de6d(%rip), %rsi    # 0x3e34ee
movq %r15, %rdi
movq 0x18(%rsp), %r13
movq %r13, %rdx
movl %r12d, %r8d
movq 0x20(%rsp), %r12
movq %r12, %r9
xorl %eax, %eax
pushq 0x10(%rsp)
callq 0x2cdd65
addq $0x10, %rsp
movq %r15, %rdi
movl %r14d, %esi
callq 0x2f320e
movq %r15, %rdi
movq %r13, %rsi
movq (%rsp), %rdx
callq 0x2f327f
jmp 0x2c54c6
xorl %r12d, %r12d
jmp 0x2c54c6