// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %rbx
subq $0x78, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x8, %rdx
xorl %esi, %esi
callq 0x43a500
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x428d57
jmp 0x428f5d
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x465850
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x428d71
jmp 0x428f5d
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4659f0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x428d8b
jmp 0x428f5d
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x70(%rax), %rsi
callq 0x3cb770
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x5c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movl $0x1a, %esi
xorl %eax, %eax
movl %eax, %r8d
callq 0x4338b0
cmpl $0x0, %eax
je 0x428de1
jmp 0x428f5d
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x41db70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x428dfe
jmp 0x428f5d
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x38(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jge 0x428e4a
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x3c3e60
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x428e3d
jmp 0x428e4a
jmp 0x428e3f
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x428e05
movl -0x3c(%rbp), %eax
movq -0x38(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jne 0x428e74
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq 0x181f7f(%rip), %rsi    # 0x5aade7
movb $0x0, %al
callq 0x3cb660
jmp 0x428f5d
movq -0x10(%rbp), %rdi
callq 0x42e470
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x41db70
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x428e9a
jmp 0x428f5d
movq -0x28(%rbp), %rax
movq (%rax), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0x17dd23(%rip), %rax    # 0x5a6bd0
movzbl (%rax,%rcx), %eax
andl $0x80, %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq -0x38(%rbp), %rax
movq (%rax), %r8
movl -0x3c(%rbp), %r9d
movq -0x50(%rbp), %rbx
movl -0x60(%rbp), %r11d
cmpl $0x1, -0x5c(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %r10d
movq -0x38(%rbp), %rax
movq (%rax), %rax
leaq 0x186266(%rip), %rsi    # 0x5af159
movq %rbx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x434d60
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movl -0x3c(%rbp), %r8d
movq -0x50(%rbp), %r9
movl -0x60(%rbp), %eax
leaq 0x186305(%rip), %rsi    # 0x5af233
movl %eax, (%rsp)
movb $0x0, %al
callq 0x434d60
movq -0x10(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x4658e0
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
cmpl $0x1, -0x5c(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %edx
callq 0x465950
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x40c9d0
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3c00a0
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x3c00a0
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax,%rax)