// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rax
movq %rax, (%rsp)
leaq 0x8(%rsi), %rdx
xorl %esi, %esi
callq 0x2c84c3
testq %rax, %rax
je 0x2bbd47
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x2e9ec3
testl %eax, %eax
jne 0x2bbd47
movq 0x18(%r12), %rax
testq %rax, %rax
sete %dl
movl 0x54(%r12), %ecx
testl %ecx, %ecx
sete %sil
testb %dl, %sil
je 0x2bbce8
movq 0x70(%r12), %rcx
movq (%rsp), %rax
movq 0x20(%rax), %rax
testq %rcx, %rcx
je 0x2bbd1a
leaq 0x18(%rax), %rdx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
incl %ebp
leaq 0x20(%rdx), %rsi
cmpq %rcx, (%rdx)
movq %rsi, %rdx
jne 0x2bbcd8
jmp 0x2bbd1f
testq %rax, %rax
leaq 0x11d19c(%rip), %rsi    # 0x3d8e8e
cmoveq %rax, %rsi
testl %ecx, %ecx
leaq 0x11e11d(%rip), %rdx    # 0x3d9e1c
cmoveq %rsi, %rdx
movq (%r12), %rcx
leaq 0x11e11c(%rip), %rsi    # 0x3d9e2a
movq %r15, %rdi
xorl %eax, %eax
callq 0x27b48d
jmp 0x2bbd47
movl $0xffff8000, %ebp       # imm = 0xFFFF8000
movslq %ebp, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rdx
movq (%r12), %rcx
movq %r15, %rdi
movl $0x1a, %esi
movq %rdx, 0x10(%rsp)
xorl %r8d, %r8d
callq 0x2c37ba
testl %eax, %eax
je 0x2bbd61
movq (%rsp), %rdi
movq %r14, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2a63cf
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x2b1f02
testq %rax, %rax
je 0x2bbd47
movq %rax, %r13
movswl 0x46(%r12), %eax
testl %eax, %eax
jle 0x2bbdce
movq 0x8(%r12), %rcx
movl %eax, %edx
xorl %r11d, %r11d
leaq 0x115550(%rip), %rsi    # 0x3d12e0
movq %r11, %rdi
shlq $0x5, %rdi
movq (%rcx,%rdi), %rdi
xorl %r8d, %r8d
movzbl (%rdi,%r8), %r9d
movzbl (%r13,%r8), %r10d
cmpb %r10b, %r9b
jne 0x2bbdb5
testq %r9, %r9
jne 0x2bbdbf
jmp 0x2bbdd1
movb (%r9,%rsi), %r9b
cmpb (%r10,%rsi), %r9b
jne 0x2bbdc4
incq %r8
jmp 0x2bbd9e
incq %r11
cmpq %rdx, %r11
jne 0x2bbd90
jmp 0x2bbdd6
xorl %r11d, %r11d
cmpl %eax, %r11d
jne 0x2bbdf2
leaq 0x119b8b(%rip), %rsi    # 0x3d5968
xorl %r12d, %r12d
movq %r15, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x27b48d
jmp 0x2bbed0
movq %r11, 0x8(%rsp)
movq 0xa0(%r15), %rax
testq %rax, %rax
cmoveq %r15, %rax
movb $0x1, 0x21(%rax)
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0x2b1f02
testq %rax, %rax
je 0x2bbecd
movq %rax, %r10
movq (%rbx), %rax
movzbl (%rax), %eax
leaq 0x115612(%rip), %rcx    # 0x3d1440
movzbl (%rax,%rcx), %eax
andl $-0x80, %eax
movq %rax, %rbx
movq %rax, 0x18(%rsp)
movq (%r12), %r8
xorl %eax, %eax
cmpl $0x1, %ebp
sete %al
movq %rax, %r11
movq %rax, 0x20(%rsp)
leaq 0x11de67(%rip), %rsi    # 0x3d9cbf
movq %r15, %rdi
movq 0x10(%rsp), %rcx
movq %rcx, %rdx
movq 0x8(%rsp), %r9
xorl %eax, %eax
pushq %r8
pushq %r11
pushq %rbx
movq %r10, %rbx
pushq %r10
callq 0x2c461b
addq $0x20, %rsp
movq (%r12), %rcx
movq %rbx, %r12
subq $0x8, %rsp
leaq 0x11df0a(%rip), %rsi    # 0x3d9d99
movq %r15, %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rdx
movq 0x10(%rsp), %r8
movq %r12, %r9
xorl %eax, %eax
pushq 0x20(%rsp)
callq 0x2c461b
addq $0x10, %rsp
movq %r15, %rdi
movl %ebp, %esi
callq 0x2e9f54
movq %r15, %rdi
movq %rbx, %rsi
movq 0x20(%rsp), %rdx
callq 0x2e9fc5
jmp 0x2bbed0
xorl %r12d, %r12d
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2a63cf
movq %rbx, %rdi
movq %r13, %rsi
callq 0x282904
testq %r12, %r12
je 0x2bbf08
movq %rbx, %rdi
movq %r12, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x282904
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq