// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r15
movq (%rdi), %r14
movq 0x10(%rdi), %rax
movl 0x1f0(%rdi), %ecx
testl %ecx, %ecx
je 0x4d587
jns 0x4d563
movl 0x34(%rax), %ecx
decl %ecx
movq (%rax), %rdx
cmpb $0x0, 0x50(%rdx)
je 0x4d575
leaq 0x3ea2d(%rip), %rcx     # 0x8bfa0
jmp 0x4d584
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x8(%rax), %rcx
movb $0x70, (%rcx)
movl 0x1f4(%r15), %ecx
testl %ecx, %ecx
je 0x4d5bd
jns 0x4d599
movl 0x34(%rax), %ecx
decl %ecx
movq (%rax), %rdx
cmpb $0x0, 0x50(%rdx)
je 0x4d5ab
leaq 0x3e9f7(%rip), %rcx     # 0x8bfa0
jmp 0x4d5ba
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x8(%rax), %rcx
movb $0x10, (%rcx)
cmpw $0x0, 0x40(%rbx)
js 0x4d659
xorl %r13d, %r13d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3f731
testq %rax, %rax
je 0x4d82e
movq %rax, %r12
movq (%r15), %rdi
movq 0x8(%rbx), %rax
movswq 0x40(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rsi
callq 0x10656
movq 0x8(%r12), %rcx
movq %rax, 0x8(%rcx)
movb 0x210(%r15), %al
movb %al, 0x18(%rcx)
movzbl 0x49(%rbx), %r9d
movl %r13d, 0x18(%rsp)
movl %r13d, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x3c02d
testq %rax, %rax
je 0x4d82e
movq %rax, %r15
movb 0x63(%rax), %al
andb $-0x4, %al
orb $0x2, %al
movb %al, 0x63(%r15)
movw $0xffff, 0x40(%rbx)     # imm = 0xFFFF
jmp 0x4d675
movq 0x10(%rbx), %r15
testq %r15, %r15
je 0x4d672
movb 0x63(%r15), %al
andb $0x3, %al
cmpb $0x2, %al
je 0x4d675
movq 0x28(%r15), %r15
jmp 0x4d65d
xorl %r15d, %r15d
movb 0x63(%r15), %al
orb $0x20, %al
movb %al, 0x63(%r15)
movzwl 0x5e(%r15), %r13d
testl %r13d, %r13d
je 0x4d6b1
movq 0x8(%rbx), %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 0x4d693
movb 0x63(%r15), %al
orb $0x8, %al
movb %al, 0x63(%r15)
movl 0x3c(%rbx), %eax
movl %eax, 0x58(%r15)
movq 0x10(%rbx), %r12
testq %r12, %r12
je 0x4d7b9
movl %r13d, %ebp
movb 0x63(%r12), %al
andb $0x3, %al
cmpb $0x2, %al
je 0x4d7ab
testq %r13, %r13
je 0x4d79f
movq 0x8(%r12), %rax
movzwl 0x5e(%r12), %ecx
movq 0x8(%r15), %rsi
xorl %edi, %edi
xorl %edx, %edx
movzwl (%rsi,%rdi,2), %r8d
movq %rax, %r9
movl %ecx, %r10d
testl %r10d, %r10d
jle 0x4d71b
decl %r10d
leaq 0x2(%r9), %r11
cmpw %r8w, (%r9)
movq %r11, %r9
jne 0x4d704
jmp 0x4d71d
incl %edx
incq %rdi
cmpq %r13, %rdi
jne 0x4d6f9
testl %edx, %edx
je 0x4d79f
movzwl 0x5e(%r12), %eax
addl %eax, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x4dedd
testl %eax, %eax
jne 0x4d82e
testq %r13, %r13
je 0x4d7ab
movzwl 0x5e(%r12), %eax
xorl %ecx, %ecx
movq 0x8(%r12), %rdx
movzwl 0x5e(%r12), %edi
movq 0x8(%r15), %rsi
movzwl (%rsi,%rcx,2), %esi
movq %rdx, %r8
testl %edi, %edi
jle 0x4d77c
decl %edi
leaq 0x2(%r8), %r9
cmpw %si, (%r8)
movq %r9, %r8
jne 0x4d767
jmp 0x4d795
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 0x4d751
jmp 0x4d7ab
movzwl 0x5e(%r12), %eax
movw %ax, 0x60(%r12)
movq 0x28(%r12), %r12
testq %r12, %r12
jne 0x4d6ce
movzwl 0x42(%rbx), %eax
movswl %ax, %edx
cmpl %edx, %r13d
jge 0x4d829
movq %r14, %rdi
movq %r15, %rsi
callq 0x4dedd
testl %eax, %eax
jne 0x4d82e
movzwl 0x42(%rbx), %edx
testw %dx, %dx
jle 0x4d82e
xorl %eax, %eax
leaq 0x24398(%rip), %rcx     # 0x71b7e
movq 0x8(%r15), %rsi
movq %rsi, %rdi
movl %r13d, %r8d
testl %r8d, %r8d
jle 0x4d807
decl %r8d
movswl (%rdi), %r9d
addq $0x2, %rdi
cmpl %r9d, %eax
jne 0x4d7f0
jmp 0x4d81e
movslq %r13d, %r13
movw %ax, (%rsi,%r13,2)
movq 0x40(%r15), %rdx
movq %rcx, (%rdx,%r13,8)
incl %r13d
movzwl 0x42(%rbx), %edx
incl %eax
movswl %dx, %esi
cmpl %esi, %eax
jl 0x4d7e6
jmp 0x4d82e
movw %ax, 0x60(%r15)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq