// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3AlterBeginAddColumn
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
  Table *pNew;
  Table *pTab;
  int iDb;
  int i;
  int nAlloc;
  sqlite3 *db = pParse->db;

  /* Look up the table being altered. */
  assert( pParse->pNewTable==0 );
  assert( sqlite3BtreeHoldsAllMutexes(db) );
  if( db->mallocFailed ) goto exit_begin_add_column;
  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);
  if( !pTab ) goto exit_begin_add_column;

#ifndef SQLITE_OMIT_VIRTUALTABLE
  if( IsVirtual(pTab) ){
    sqlite3ErrorMsg(pParse, "virtual tables may not be altered");
    goto exit_begin_add_column;
  }
#endif

  /* Make sure this is not an attempt to ALTER a view. */
  if( pTab->pSelect ){
    sqlite3ErrorMsg(pParse, "Cannot add a column to a view");
    goto exit_begin_add_column;
  }
  if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
    goto exit_begin_add_column;
  }

  sqlite3MayAbort(pParse);
  assert( pTab->addColOffset>0 );
  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);

  /* Put a copy of the Table struct in Parse.pNewTable for the
  ** sqlite3AddColumn() function and friends to modify.  But modify
  ** the name by adding an "sqlite_altertab_" prefix.  By adding this
  ** prefix, we insure that the name will not collide with an existing
  ** table because user table are not allowed to have the "sqlite_"
  ** prefix on their name.
  */
  pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));
  if( !pNew ) goto exit_begin_add_column;
  pParse->pNewTable = pNew;
  pNew->nTabRef = 1;
  pNew->nCol = pTab->nCol;
  assert( pNew->nCol>0 );
  nAlloc = (((pNew->nCol-1)/8)*8)+8;
  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
  pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);
  pNew->zName = sqlite3MPrintf(db, "sqlite_altertab_%s", pTab->zName);
  if( !pNew->aCol || !pNew->zName ){
    assert( db->mallocFailed );
    goto exit_begin_add_column;
  }
  memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);
  for(i=0; i<pNew->nCol; i++){
    Column *pCol = &pNew->aCol[i];
    pCol->zName = sqlite3DbStrDup(db, pCol->zName);
    pCol->hName = sqlite3StrIHash(pCol->zName);
    pCol->zColl = 0;
    pCol->pDflt = 0;
  }
  pNew->pSchema = db->aDb[iDb].pSchema;
  pNew->addColOffset = pTab->addColOffset;
  pNew->nTabRef = 1;

exit_begin_add_column:
  sqlite3SrcListDelete(db, pSrc);
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpb $0x0, 0x61(%rax)
je 0x428aba
jmp 0x428ced
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
xorl %esi, %esi
callq 0x43a500
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x428add
jmp 0x428ced
movq -0x20(%rbp), %rax
cmpl $0x0, 0x54(%rax)
je 0x428afe
movq -0x8(%rbp), %rdi
leaq 0x186614(%rip), %rsi    # 0x5af106
movb $0x0, %al
callq 0x3cb660
jmp 0x428ced
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x428b20
movq -0x8(%rbp), %rdi
leaq 0x186614(%rip), %rsi    # 0x5af128
movb $0x0, %al
callq 0x3cb660
jmp 0x428ced
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x465850
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x428b3a
jmp 0x428ced
movq -0x8(%rbp), %rdi
callq 0x42e470
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x70(%rax), %rsi
callq 0x3cb770
movl %eax, -0x24(%rbp)
movq -0x38(%rbp), %rdi
movl $0x80, %esi
callq 0x3c9520
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x428b75
jmp 0x428ced
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x148(%rax)
movq -0x18(%rbp), %rax
movl $0x1, 0x3c(%rax)
movq -0x20(%rbp), %rax
movw 0x46(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x46(%rax)
movq -0x18(%rbp), %rax
movswl 0x46(%rax), %eax
subl $0x1, %eax
movl $0x8, %ecx
cltd
idivl %ecx
shll $0x3, %eax
addl $0x8, %eax
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
shlq $0x5, %rsi
callq 0x3c9520
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rdx
leaq 0x18655d(%rip), %rsi    # 0x5af146
movb $0x0, %al
callq 0x3cb7d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x428c0f
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x428c14
jmp 0x428ced
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movswq 0x46(%rax), %rdx
shlq $0x5, %rdx
callq 0x19610
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jge 0x428cb5
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rax
movq (%rax), %rsi
callq 0x3c91a0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0x437e20
movb %al, %cl
movq -0x40(%rbp), %rax
movb %cl, 0x1b(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x8(%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x428c3d
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x20(%rbp), %rax
movl 0x50(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x18(%rbp), %rax
movl $0x1, 0x3c(%rax)
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x40c9d0
addq $0x40, %rsp
popq %rbp
retq