// File: /workspace/github_c_makefile_star2_O1/skeeto[P]flappy/sqlite3.c
// Function: convertToWithoutRowidTable
static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
  Index *pIdx;
  Index *pPk;
  int nPk;
  int i, j;
  sqlite3 *db = pParse->db;
  Vdbe *v = pParse->pVdbe;

  /* Convert the OP_CreateTable opcode that would normally create the
  ** root-page for the table into a OP_CreateIndex opcode.  The index
  ** created will become the PRIMARY KEY index.
  */
  if( pParse->addrCrTab ){
    assert( v );
    sqlite3VdbeGetOp(v, pParse->addrCrTab)->opcode = OP_CreateIndex;
  }

  /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
  ** table entry.
  */
  if( pParse->addrSkipPK ){
    assert( v );
    sqlite3VdbeGetOp(v, pParse->addrSkipPK)->opcode = OP_Goto;
  }

  /* Locate the PRIMARY KEY index.  Or, if this table was originally
  ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index. 
  */
  if( pTab->iPKey>=0 ){
    ExprList *pList;
    pList = sqlite3ExprListAppend(pParse, 0, 0);
    if( pList==0 ) return;
    pList->a[0].zName = sqlite3DbStrDup(pParse->db,
                                        pTab->aCol[pTab->iPKey].zName);
    pList->a[0].sortOrder = pParse->iPkSortOrder;
    assert( pParse->pNewTable==pTab );
    pPk = sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0);
    if( pPk==0 ) return;
    pPk->autoIndex = 2;
    pTab->iPKey = -1;
  }else{
    pPk = sqlite3PrimaryKeyIndex(pTab);
  }
  pPk->isCovering = 1;
  assert( pPk!=0 );
  nPk = pPk->nKeyCol;

  /* Make sure every column of the PRIMARY KEY is NOT NULL */
  for(i=0; i<nPk; i++){
    pTab->aCol[pPk->aiColumn[i]].notNull = 1;
  }
  pPk->uniqNotNull = 1;

  /* The root page of the PRIMARY KEY is the table root page */
  pPk->tnum = pTab->tnum;

  /* Update the in-memory representation of all UNIQUE indices by converting
  ** the final rowid column into one or more columns of the PRIMARY KEY.
  */
  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
    int n;
    if( pIdx->autoIndex==2 ) continue;
    for(i=n=0; i<nPk; i++){
      if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ) n++;
    }
    if( n==0 ){
      /* This index is a superset of the primary key */
      pIdx->nColumn = pIdx->nKeyCol;
      continue;
    }
    if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return;
    for(i=0, j=pIdx->nKeyCol; i<nPk; i++){
      if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ){
        pIdx->aiColumn[j] = pPk->aiColumn[i];
        pIdx->azColl[j] = pPk->azColl[i];
        j++;
      }
    }
    assert( pIdx->nColumn>=pIdx->nKeyCol+n );
    assert( pIdx->nColumn>=j );
  }

  /* Add all table columns to the PRIMARY KEY index
  */
  if( nPk<pTab->nCol ){
    if( resizeIndexObject(db, pPk, pTab->nCol) ) return;
    for(i=0, j=nPk; i<pTab->nCol; i++){
      if( !hasColumn(pPk->aiColumn, j, i) ){
        assert( j<pPk->nColumn );
        pPk->aiColumn[j] = i;
        pPk->azColl[j] = "BINARY";
        j++;
      }
    }
    assert( pPk->nColumn==j );
    assert( pTab->nCol==j );
  }else{
    pPk->nColumn = pTab->nCol;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r12
movq (%rdi), %rax
movq %rax, 0x30(%rsp)
movq 0x10(%rdi), %rax
movl 0x1f0(%rdi), %ecx
testl %ecx, %ecx
je 0x4cea6
jns 0x4ce82
movl 0x34(%rax), %ecx
decl %ecx
movq (%rax), %rdx
cmpb $0x0, 0x50(%rdx)
je 0x4ce94
leaq 0x3e10e(%rip), %rcx     # 0x8afa0
jmp 0x4cea3
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x8(%rax), %rcx
movb $0x70, (%rcx)
movl 0x1f4(%r12), %ecx
testl %ecx, %ecx
je 0x4cedd
jns 0x4ceb9
movl 0x34(%rax), %ecx
decl %ecx
movq (%rax), %rdx
cmpb $0x0, 0x50(%rdx)
je 0x4cecb
leaq 0x3e0d7(%rip), %rcx     # 0x8afa0
jmp 0x4ceda
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x8(%rax), %rcx
movb $0x10, (%rcx)
cmpw $0x0, 0x40(%rbx)
movq %rbx, 0x28(%rsp)
js 0x4d179
xorl %r15d, %r15d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3ef23
testq %rax, %rax
je 0x4cf7a
movq %rax, %r13
movq (%r12), %rdi
movq 0x8(%rbx), %rax
movswq 0x40(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rsi
callq 0x104cc
movq 0x8(%r13), %rcx
movq %rax, 0x8(%rcx)
movb 0x210(%r12), %al
movb %al, 0x18(%rcx)
movzbl 0x49(%rbx), %r9d
movl %r15d, 0x18(%rsp)
movl %r15d, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r13, %r8
callq 0x3bc21
testq %rax, %rax
je 0x4cf7a
movb 0x63(%rax), %cl
andb $-0x4, %cl
orb $0x2, %cl
movb %cl, 0x63(%rax)
movw $0xffff, 0x40(%rbx)     # imm = 0xFFFF
movb $0x1, %cl
movq %rax, %r15
jmp 0x4cf7c
xorl %ecx, %ecx
testb %cl, %cl
je 0x4d19f
orb $0x20, 0x63(%r15)
movzwl 0x5e(%r15), %r13d
testl %r13d, %r13d
movq 0x28(%rsp), %rdi
je 0x4cfbc
movq 0x8(%rdi), %rax
movq 0x8(%r15), %rcx
xorl %edx, %edx
movswq (%rcx,%rdx,2), %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x4, %rsi
movb $0x1, 0x28(%rax,%rsi)
incq %rdx
cmpq %rdx, %r13
jne 0x4cfa2
orb $0x8, 0x63(%r15)
movl 0x3c(%rdi), %eax
movl %eax, 0x58(%r15)
movq 0x10(%rdi), %r12
testq %r12, %r12
je 0x4d0ef
movl %r13d, %ebp
movb 0x63(%r12), %al
andb $0x3, %al
movl $0x7, %ecx
cmpb $0x2, %al
je 0x4d0d4
testl %r13d, %r13d
je 0x4d03d
movq 0x8(%r12), %rax
movzwl 0x5e(%r12), %r14d
movq 0x8(%r15), %rdi
xorl %r8d, %r8d
xorl %edx, %edx
movzwl (%rdi,%r8,2), %r9d
movq %rax, %r11
movl %r14d, %esi
movl %esi, %r10d
testl %esi, %esi
jle 0x4d028
leal -0x1(%r10), %esi
leaq 0x2(%r11), %rbx
cmpw %r9w, (%r11)
movq %rbx, %r11
jne 0x4d010
xorl %esi, %esi
testl %r10d, %r10d
setle %sil
addl %esi, %edx
incq %r8
cmpq %r13, %r8
jne 0x4d005
jmp 0x4d03f
xorl %edx, %edx
movzwl 0x5e(%r12), %eax
testl %edx, %edx
je 0x4d0ce
movzwl %ax, %eax
addl %eax, %edx
movq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x4d850
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
jne 0x4d0d4
testw %r13w, %r13w
je 0x4d0d4
movzwl 0x5e(%r12), %eax
xorl %ecx, %ecx
movq 0x8(%r12), %rdx
movzwl 0x5e(%r12), %r9d
movq 0x8(%r15), %rsi
movzwl (%rsi,%rcx,2), %esi
movq %rdx, %rdi
testl %r9d, %r9d
jle 0x4d0a9
movl %r9d, %r8d
leal -0x1(%r8), %r9d
leaq 0x2(%rdi), %r10
cmpw %si, (%rdi)
movq %r10, %rdi
jne 0x4d08c
testl %r8d, %r8d
jg 0x4d0c2
cltq
movw %si, (%rdx,%rax,2)
movq 0x40(%r15), %rdx
movq (%rdx,%rcx,8), %rdx
movq 0x40(%r12), %rsi
movq %rdx, (%rsi,%rax,8)
incl %eax
incq %rcx
cmpq %rbp, %rcx
jne 0x4d076
xorl %ecx, %ecx
jmp 0x4d0d4
movw %ax, 0x60(%r12)
cmpl $0x7, %ecx
je 0x4d0e1
testl %ecx, %ecx
jne 0x4d19f
movq 0x28(%r12), %r12
testq %r12, %r12
jne 0x4cfd8
movq 0x28(%rsp), %rax
movzwl 0x42(%rax), %eax
movswl %ax, %edx
cmpl %edx, %r13d
jge 0x4d19a
movq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x4d850
testl %eax, %eax
jne 0x4d19f
movq 0x28(%rsp), %rax
cmpw $0x0, 0x42(%rax)
jle 0x4d19f
xorl %eax, %eax
leaq 0x239b0(%rip), %rcx     # 0x70ade
movq 0x8(%r15), %rdx
movq %rdx, %rsi
movl %r13d, %r8d
testl %r8d, %r8d
jle 0x4d155
movl %r8d, %edi
leal -0x1(%rdi), %r8d
movswl (%rsi), %r9d
addq $0x2, %rsi
cmpl %r9d, %eax
jne 0x4d138
testl %edi, %edi
jg 0x4d168
movslq %r13d, %r13
movw %ax, (%rdx,%r13,2)
movq 0x40(%r15), %rdx
movq %rcx, (%rdx,%r13,8)
incl %r13d
incl %eax
movq 0x28(%rsp), %rdx
movswl 0x42(%rdx), %edx
cmpl %edx, %eax
jl 0x4d12e
jmp 0x4d19f
movq 0x10(%rbx), %r15
testq %r15, %r15
je 0x4cf84
movb 0x63(%r15), %al
andb $0x3, %al
cmpb $0x2, %al
je 0x4cf84
movq 0x28(%r15), %r15
jmp 0x4d17d
movw %ax, 0x60(%r15)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq