// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq (%rdi), %r14
cmpb $0x0, 0x61(%r14)
jne 0x2bba92
movq %rdi, %r13
leaq 0x8(%rbx), %rdx
xorl %esi, %esi
callq 0x2c84c3
testq %rax, %rax
je 0x2bba92
movq %rax, %r15
cmpl $0x0, 0x54(%rax)
je 0x2bba7a
leaq 0x11e1f4(%rip), %rsi    # 0x3d9c6c
jmp 0x2bba88
cmpq $0x0, 0x18(%r15)
je 0x2bbaab
leaq 0x11e206(%rip), %rsi    # 0x3d9c8e
movq %r13, %rdi
xorl %eax, %eax
callq 0x27b48d
movq %r14, %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2a63cf
movq %r13, %rdi
movq %r15, %rsi
callq 0x2e9ec3
testl %eax, %eax
jne 0x2bba92
movq 0xa0(%r13), %rax
testq %rax, %rax
cmoveq %r13, %rax
movb $0x1, 0x21(%rax)
movq 0x70(%r15), %rax
testq %rax, %rax
je 0x2bbb06
movq 0x20(%r14), %rcx
addq $0x18, %rcx
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
movabsq $0x100000000, %rdx      # imm = 0x100000000
addq %rdx, %rbp
leaq 0x20(%rcx), %rsi
cmpq %rax, (%rcx)
movq %rsi, %rcx
jne 0x2bbaf1
sarq $0x20, %rbp
jmp 0x2bbb0d
movq $-0x8000, %rbp          # imm = 0x8000
movl $0x80, %esi
movq %r14, %rdi
callq 0x279b27
testq %rax, %rax
je 0x2bba92
movq %rax, %r12
movq %rax, 0x148(%r13)
movl $0x1, 0x3c(%rax)
movswl 0x46(%r15), %eax
movw %ax, 0x46(%r12)
leal -0x1(%rax), %ecx
addl $0x6, %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
andl $-0x8, %eax
movslq %eax, %rsi
shlq $0x5, %rsi
addq $0x100, %rsi            # imm = 0x100
movq %r14, %rdi
callq 0x279b27
movq %rax, 0x8(%r12)
movq (%r15), %rdx
leaq 0x11e13a(%rip), %rsi    # 0x3d9cac
movq %r14, %rdi
xorl %eax, %eax
callq 0x27b56a
movq %rax, (%r12)
movq 0x8(%r12), %rdi
testq %rdi, %rdi
sete %cl
testq %rax, %rax
sete %al
orb %cl, %al
jne 0x2bba92
movq %r15, 0x8(%rsp)
movq 0x8(%r15), %rsi
movswq 0x46(%r12), %rdx
shlq $0x5, %rdx
callq 0x17660
cmpw $0x0, 0x46(%r12)
jle 0x2bbc2a
xorl %r13d, %r13d
movq %r12, 0x10(%rsp)
movq 0x8(%r12), %r15
movq %r13, %r12
shlq $0x5, %r12
movq (%r15,%r12), %rsi
movq %r14, %rdi
callq 0x279928
movq %rax, (%r15,%r12)
testq %rax, %rax
je 0x2bbc06
movb (%rax), %dl
testb %dl, %dl
je 0x2bbc06
incq %rax
xorl %ecx, %ecx
leaq 0x1156eb(%rip), %rsi    # 0x3d12e0
movzbl %dl, %edx
addb (%rdx,%rsi), %cl
movb (%rax), %dl
incq %rax
testb %dl, %dl
jne 0x2bbbf5
jmp 0x2bbc08
xorl %ecx, %ecx
addq %r12, %r15
movb %cl, 0x1b(%r15)
incq %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r15)
movq 0x10(%rsp), %r12
movswq 0x46(%r12), %rax
cmpq %rax, %r13
jl 0x2bbbc2
movq 0x20(%r14), %rax
shlq $0x5, %rbp
movq 0x18(%rax,%rbp), %rax
movq %rax, 0x70(%r12)
movq 0x8(%rsp), %rax
movl 0x50(%rax), %eax
movl %eax, 0x50(%r12)
movl $0x1, 0x3c(%r12)
jmp 0x2bba92