// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3AlterBeginAddColumn
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
  Table *pNew;
  Table *pTab;
  Vdbe *v;
  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!=isSystemTable(pParse, pTab->zName) ){
    goto exit_begin_add_column;
  }

  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->nRef = 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 ){
    db->mallocFailed = 1;
    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->zColl = 0;
    pCol->zType = 0;
    pCol->pDflt = 0;
    pCol->zDflt = 0;
  }
  pNew->pSchema = db->aDb[iDb].pSchema;
  pNew->addColOffset = pTab->addColOffset;
  pNew->nRef = 1;

  /* Begin a transaction and increment the schema cookie.  */
  sqlite3BeginWriteOperation(pParse, 0, iDb);
  v = sqlite3GetVdbe(pParse);
  if( !v ) goto exit_begin_add_column;
  sqlite3ChangeCookie(pParse, iDb);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq (%rdi), %r14
cmpb $0x0, 0x50(%r14)
jne 0x455d8
movq %rdi, %r15
leaq 0x8(%rbx), %rdx
xorl %esi, %esi
callq 0x4a2cc
testq %rax, %rax
je 0x455d8
movq %rax, %r12
testb $0x10, 0x46(%rax)
jne 0x455c7
cmpq $0x0, 0x18(%r12)
je 0x455f1
leaq 0x3771a(%rip), %rsi     # 0x7ccdf
jmp 0x455ce
leaq 0x376ef(%rip), %rsi     # 0x7ccbd
movq %r15, %rdi
xorl %eax, %eax
callq 0x11724
movq %r14, %rdi
movq %rbx, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x341f5
movq (%r12), %rsi
movq %r15, %rdi
callq 0x630d4
testl %eax, %eax
jne 0x455d8
movq 0x68(%r12), %rax
testq %rax, %rax
je 0x45634
movl 0x28(%r14), %ecx
testl %ecx, %ecx
jle 0x4563c
movq 0x20(%r14), %rdx
addq $0x18, %rdx
xorl %r13d, %r13d
cmpq %rax, (%rdx)
je 0x4563f
incq %r13
addq $0x20, %rdx
cmpq %r13, %rcx
jne 0x4561e
movl %ecx, %r13d
jmp 0x4563f
movl $0xfff0bdc0, %r13d      # imm = 0xFFF0BDC0
jmp 0x4563f
xorl %r13d, %r13d
movq %r14, %rdi
movl $0x78, %esi
callq 0x115e9
testq %rax, %rax
je 0x455d8
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rax)
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq $0x0, 0x70(%rax)
movq %rax, 0x238(%r15)
movw $0x1, 0x44(%rax)
movswl 0x42(%r12), %edx
movq %rax, -0x38(%rbp)
movw %dx, 0x42(%rax)
leal -0x1(%rdx), %ecx
addl $0x6, %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
shrl $0x3, %edx
leal (%rdx,%rdx,2), %esi
shll $0x7, %esi
addl $0x180, %esi            # imm = 0x180
movq %r14, %rdi
movl %esi, -0x30(%rbp)
callq 0x115e9
testq %rax, %rax
je 0x456d2
movslq -0x30(%rbp), %rdx
movq %rax, %rdi
xorl %esi, %esi
movq %rax, -0x30(%rbp)
callq 0x8200
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rax, 0x8(%rcx)
movq (%r12), %rdx
leaq 0x37618(%rip), %rsi     # 0x7ccfd
movq %r14, %rdi
xorl %eax, %eax
callq 0x117e2
movq -0x38(%rbp), %rdx
movq %rax, (%rdx)
movq 0x8(%rdx), %rdi
testq %rdi, %rdi
sete %cl
testq %rax, %rax
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0x45716
movb $0x1, 0x50(%r14)
jmp 0x455d8
movq %r13, -0x40(%rbp)
movq %rbx, -0x30(%rbp)
movq %r12, -0x48(%rbp)
movq 0x8(%r12), %rsi
movswq 0x42(%rdx), %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdx
callq 0x82f0
movq -0x38(%rbp), %rdx
cmpw $0x0, 0x42(%rdx)
jle 0x45782
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x8(%rdx), %rbx
movq (%rbx,%r13), %rsi
movq %r14, %rdi
callq 0x1010d
movq -0x38(%rbp), %rdx
movq %rax, (%rbx,%r13)
incq %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx,%r13)
movups %xmm0, 0x18(%rbx,%r13)
movswq 0x42(%rdx), %rax
addq $0x30, %r13
cmpq %rax, %r12
jl 0x4574a
movq 0x20(%r14), %rax
movq -0x40(%rbp), %r12
movslq %r12d, %r13
movq %r13, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %rax
movq %rax, 0x68(%rdx)
movq -0x48(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, 0x48(%rdx)
movw $0x1, 0x44(%rdx)
movq 0x1d8(%r15), %rbx
testq %rbx, %rbx
cmoveq %r15, %rbx
movq %r15, %rdi
movl %r13d, %esi
callq 0x45ff7
movl $0x1, %eax
movl %r13d, %ecx
shll %cl, %eax
orl %eax, 0x164(%rbx)
movq %r15, %rdi
callq 0x45b57
testq %rax, %rax
movq -0x30(%rbp), %rbx
je 0x455d8
movq %r15, %rdi
movl %r12d, %esi
callq 0x466e1
jmp 0x455d8