// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpb $0x0, 0x50(%rax)
je 0x5d87a
jmp 0x5dae8
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
xorl %esi, %esi
callq 0x64100
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5d89d
jmp 0x5dae8
movq -0x20(%rbp), %rax
movzbl 0x46(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x5d8c4
movq -0x8(%rbp), %rdi
leaq 0x53f01(%rip), %rsi     # 0xb17b9
movb $0x0, %al
callq 0x136f0
jmp 0x5dae8
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x5d8e6
movq -0x8(%rbp), %rdi
leaq 0x53f01(%rip), %rsi     # 0xb17db
movb $0x0, %al
callq 0x136f0
jmp 0x5dae8
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
callq 0x84980
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x5d903
jmp 0x5dae8
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x68(%rax), %rsi
callq 0x13940
movl %eax, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
movl $0x78, %esi
callq 0x11ca0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x5d935
jmp 0x5dae8
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x238(%rax)
movq -0x18(%rbp), %rax
movw $0x1, 0x44(%rax)
movq -0x20(%rbp), %rax
movw 0x42(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x42(%rax)
movq -0x18(%rbp), %rax
movswl 0x42(%rax), %eax
subl $0x1, %eax
movl $0x8, %ecx
cltd
idivl %ecx
shll $0x3, %eax
addl $0x8, %eax
movl %eax, -0x34(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x34(%rbp), %rax
imulq $0x30, %rax, %rax
movl %eax, %esi
callq 0x11ca0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rdx
leaq 0x53e4f(%rip), %rsi     # 0xb17f9
movb $0x0, %al
callq 0x137f0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x5d9d0
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x5d9dd
movq -0x40(%rbp), %rax
movb $0x1, 0x50(%rax)
jmp 0x5dae8
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movswq 0x42(%rax), %rax
imulq $0x30, %rax, %rdx
callq 0x82f0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x18(%rbp), %rcx
movswl 0x42(%rcx), %ecx
cmpl %ecx, %eax
jge 0x5da81
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rsi
callq 0x11720
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x10(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5da06
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x20(%rbp), %rax
movl 0x48(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x18(%rbp), %rax
movw $0x1, 0x44(%rax)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %edx
xorl %esi, %esi
callq 0x5ec70
movq -0x8(%rbp), %rdi
callq 0x5e000
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x5dadc
jmp 0x5dae8
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x5f4a0
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x475c0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)