// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: convertToWithoutRowidTable
static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
  Index *pIdx;
  Index *pPk;
  int nPk;
  int nExtra;
  int i, j;
  sqlite3 *db = pParse->db;
  Vdbe *v = pParse->pVdbe;

  /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)
  */
  if( !db->init.imposterTable ){
    for(i=0; i<pTab->nCol; i++){
      if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
        pTab->aCol[i].notNull = OE_Abort;
      }
    }
    pTab->tabFlags |= TF_HasNotNull;
  }

  /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY
  ** into BTREE_BLOBKEY.
  */
  if( pParse->addrCrTab ){
    assert( v );
    sqlite3VdbeChangeP3(v, pParse->addrCrTab, BTREE_BLOBKEY);
  }

  /* 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;
    Token ipkToken;
    sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);
    pList = sqlite3ExprListAppend(pParse, 0,
                  sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
    if( pList==0 ) return;
    if( IN_RENAME_OBJECT ){
      sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey);
    }
    pList->a[0].sortFlags = pParse->iPkSortOrder;
    assert( pParse->pNewTable==pTab );
    pTab->iPKey = -1;
    sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
                       SQLITE_IDXTYPE_PRIMARYKEY);
    if( db->mallocFailed || pParse->nErr ) return;
    pPk = sqlite3PrimaryKeyIndex(pTab);
    assert( pPk->nKeyCol==1 );
  }else{
    pPk = sqlite3PrimaryKeyIndex(pTab);
    assert( pPk!=0 );

    /*
    ** Remove all redundant columns from the PRIMARY KEY.  For example, change
    ** "PRIMARY KEY(a,b,a,b,c,b,c,d)" into just "PRIMARY KEY(a,b,c,d)".  Later
    ** code assumes the PRIMARY KEY contains no repeated columns.
    */
    for(i=j=1; i<pPk->nKeyCol; i++){
      if( isDupColumn(pPk, j, pPk, i) ){
        pPk->nColumn--;
      }else{
        testcase( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) );
        pPk->azColl[j] = pPk->azColl[i];
        pPk->aSortOrder[j] = pPk->aSortOrder[i];
        pPk->aiColumn[j++] = pPk->aiColumn[i];
      }
    }
    pPk->nKeyCol = j;
  }
  assert( pPk!=0 );
  pPk->isCovering = 1;
  if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
  nPk = pPk->nColumn = pPk->nKeyCol;

  /* Bypass the creation of the PRIMARY KEY btree and the sqlite_schema
  ** table entry. This is only required if currently generating VDBE
  ** code for a CREATE TABLE (not when parsing one as part of reading
  ** a database schema).  */
  if( v && pPk->tnum>0 ){
    assert( db->init.busy==0 );
    sqlite3VdbeChangeOpcode(v, (int)pPk->tnum, OP_Goto);
  }

  /* 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( IsPrimaryKeyIndex(pIdx) ) continue;
    for(i=n=0; i<nPk; i++){
      if( !isDupColumn(pIdx, pIdx->nKeyCol, pPk, i) ){
        testcase( 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( !isDupColumn(pIdx, pIdx->nKeyCol, pPk, i) ){
        testcase( hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) );
        pIdx->aiColumn[j] = pPk->aiColumn[i];
        pIdx->azColl[j] = pPk->azColl[i];
        if( pPk->aSortOrder[i] ){
          /* See ticket https://www.sqlite.org/src/info/bba7b69f9849b5bf */
          pIdx->bAscKeyBug = 1;
        }
        j++;
      }
    }
    assert( pIdx->nColumn>=pIdx->nKeyCol+n );
    assert( pIdx->nColumn>=j );
  }

  /* Add all table columns to the PRIMARY KEY index
  */
  nExtra = 0;
  for(i=0; i<pTab->nCol; i++){
    if( !hasColumn(pPk->aiColumn, nPk, i)
     && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) nExtra++;
  }
  if( resizeIndexObject(db, pPk, nPk+nExtra) ) return;
  for(i=0, j=nPk; i<pTab->nCol; i++){
    if( !hasColumn(pPk->aiColumn, j, i)
     && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0
    ){
      assert( j<pPk->nColumn );
      pPk->aiColumn[j] = i;
      pPk->azColl[j] = sqlite3StrBINARY;
      j++;
    }
  }
  assert( pPk->nColumn==j );
  assert( pTab->nNVCol<=j );
  recomputeColumnsNotIndexed(pPk);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r13
movq %rdi, %r15
movq (%rdi), %r12
movq 0x10(%rdi), %r14
testb $0x2, 0xb6(%r12)
jne 0x2c3c87
movswq 0x46(%r13), %rax
testq %rax, %rax
jle 0x2c3c82
movq 0x8(%r13), %rcx
shlq $0x5, %rax
xorl %edx, %edx
testb $0x1, 0x1c(%rcx,%rdx)
je 0x2c3c79
movb $0x2, 0x18(%rcx,%rdx)
addq $0x20, %rdx
cmpq %rdx, %rax
jne 0x2c3c6d
orb $0x8, 0x41(%r13)
movl 0xc0(%r15), %eax
testl %eax, %eax
je 0x2c3cc7
jns 0x2c3c9d
movl 0x90(%r14), %eax
decl %eax
movq (%r14), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x2c3caf
leaq 0x1fb1db(%rip), %rax    # 0x4bee88
jmp 0x2c3cc0
cltq
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x88(%r14), %rax
movl $0x2, 0xc(%rax)
movswq 0x44(%r13), %rax
testq %rax, %rax
js 0x2c3cfa
movq 0x8(%r13), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rdi
movq %rdi, 0x48(%rsp)
testq %rdi, %rdi
je 0x2c3df5
callq 0x172f0
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jmp 0x2c3df7
movq 0x10(%r13), %r15
testq %r15, %r15
je 0x2c3d17
movzwl 0x63(%r15), %eax
andl $0x3, %eax
cmpw $0x2, %ax
je 0x2c3d1a
movq 0x28(%r15), %r15
jmp 0x2c3cfe
xorl %r15d, %r15d
movzwl 0x5e(%r15), %ebx
movw $0x1, %bp
cmpw $0x2, %bx
jb 0x2c3d92
movq %r12, 0x30(%rsp)
movl $0x1, %ebp
movl $0x1, %r12d
movq %r15, %rdi
movl %ebp, %esi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x2c47ee
testl %eax, %eax
je 0x2c3d54
decw 0x60(%r15)
jmp 0x2c3d82
movq 0x40(%r15), %rax
movq (%rax,%r12,8), %rcx
movslq %ebp, %rdx
movq %rcx, (%rax,%rdx,8)
movq 0x38(%r15), %rax
movb (%rax,%r12), %cl
movb %cl, (%rax,%rdx)
movq 0x8(%r15), %rax
movzwl (%rax,%r12,2), %ecx
incl %ebp
movw %cx, (%rax,%rdx,2)
movzwl 0x5e(%r15), %ebx
incq %r12
movzwl %bx, %eax
cmpq %rax, %r12
jb 0x2c3d39
movq 0x30(%rsp), %r12
movw %bp, 0x5e(%r15)
movzwl 0x63(%r15), %eax
movl %eax, %ecx
orl $0x20, %ecx
movw %cx, 0x63(%r15)
testb $0x2, 0xb6(%r12)
jne 0x2c3db9
orl $0x28, %eax
movw %ax, 0x63(%r15)
movzwl 0x5e(%r15), %ebx
movw %bx, 0x60(%r15)
testq %r14, %r14
je 0x2c3e75
movl 0x58(%r15), %eax
testl %eax, %eax
je 0x2c3e75
jns 0x2c3de3
movl 0x90(%r14), %eax
decl %eax
movq (%r14), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x2c3e61
leaq 0x1fb095(%rip), %rax    # 0x4bee88
jmp 0x2c3e72
xorl %eax, %eax
leaq 0x48(%rsp), %rdx
movl %eax, 0x8(%rdx)
movq %r12, %rdi
movl $0x3b, %esi
xorl %ecx, %ecx
callq 0x2b1c27
movq (%r15), %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2b1a3f
testq %rax, %rax
je 0x2c40d0
cmpb $0x2, 0x11c(%r15)
jb 0x2c4081
movq 0x1a0(%r15), %rcx
testq %rcx, %rcx
je 0x2c4081
leaq 0x44(%r13), %rsi
movq 0x8(%rax), %rdx
cmpq %rsi, (%rcx)
je 0x2c407e
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
jne 0x2c3e4a
jmp 0x2c4081
cltq
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x88(%r14), %rax
movb $0xb, (%rax)
movq %r12, 0x30(%rsp)
movl 0x38(%r13), %eax
movl %eax, 0x58(%r15)
movq %r13, 0x38(%rsp)
movq 0x10(%r13), %r12
testq %r12, %r12
je 0x2c3f8e
movl %ebx, %r14d
movq %r14, 0x40(%rsp)
movzwl 0x63(%r12), %eax
andl $0x3, %eax
cmpw $0x2, %ax
je 0x2c3f80
testl %ebx, %ebx
je 0x2c3f74
movzwl 0x5e(%r12), %r13d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %r12, %rdi
movl %r13d, %esi
movq %r15, %rdx
movl %r14d, %ecx
callq 0x2c47ee
xorl $0x1, %eax
addl %eax, %ebp
incl %r14d
cmpl %r14d, %ebx
jne 0x2c3ec2
testl %ebp, %ebp
movq 0x40(%rsp), %r14
je 0x2c3f74
movzwl 0x5e(%r12), %eax
addl %eax, %ebp
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x2c4872
testl %eax, %eax
jne 0x2c40d0
testl %ebx, %ebx
je 0x2c3f80
movzwl 0x5e(%r12), %ebp
xorl %r13d, %r13d
movzwl 0x5e(%r12), %esi
movq %r12, %rdi
movq %r15, %rdx
movl %r13d, %ecx
callq 0x2c47ee
testl %eax, %eax
jne 0x2c3f6a
movq 0x8(%r15), %rax
movzwl (%rax,%r13,2), %eax
movq 0x8(%r12), %rcx
movslq %ebp, %rdx
movw %ax, (%rcx,%rdx,2)
movq 0x40(%r15), %rax
movq (%rax,%r13,8), %rax
movq 0x40(%r12), %rcx
movq %rax, (%rcx,%rdx,8)
movq 0x38(%r15), %rax
cmpb $0x0, (%rax,%r13)
je 0x2c3f68
orb $0x2, 0x64(%r12)
incl %ebp
incq %r13
cmpq %r13, %r14
jne 0x2c3f19
jmp 0x2c3f80
movzwl 0x5e(%r12), %eax
movw %ax, 0x60(%r12)
movq 0x28(%r12), %r12
testq %r12, %r12
jne 0x2c3e9c
movq 0x38(%rsp), %r10
movswq 0x46(%r10), %rax
testq %rax, %rax
movq 0x30(%rsp), %rdi
jle 0x2c3fef
movq 0x8(%r15), %rcx
xorl %esi, %esi
xorl %edx, %edx
movq %rcx, %r11
movl %ebx, %r8d
testl %r8d, %r8d
jle 0x2c3fca
decl %r8d
movswq (%r11), %r9
addq $0x2, %r11
movl %r9d, %r9d
cmpq %r9, %rsi
jne 0x2c3fb0
jmp 0x2c3fe5
movq 0x8(%r10), %r9
movq %rsi, %r8
shlq $0x5, %r8
movb 0x1c(%r9,%r8), %r8b
andb $0x20, %r8b
cmpb $0x1, %r8b
adcl $0x0, %edx
incq %rsi
cmpq %rax, %rsi
jne 0x2c3faa
jmp 0x2c3ff1
xorl %edx, %edx
addl %ebx, %edx
movq %r15, %rsi
callq 0x2c4872
testl %eax, %eax
jne 0x2c40d0
movq 0x38(%rsp), %r10
movzwl 0x46(%r10), %edx
testw %dx, %dx
jle 0x2c4074
xorl %eax, %eax
leaq 0x10db45(%rip), %rcx    # 0x3d1b60
movq 0x8(%r15), %rsi
movq %rsi, %rdi
movl %ebx, %r8d
testl %r8d, %r8d
jle 0x2c403f
decl %r8d
movswq (%rdi), %r9
addq $0x2, %rdi
movl %r9d, %r9d
cmpq %r9, %rax
jne 0x2c4025
jmp 0x2c4068
movq 0x8(%r10), %rdi
movq %rax, %r8
shlq $0x5, %r8
testb $0x20, 0x1c(%rdi,%r8)
jne 0x2c4068
movslq %ebx, %rbx
movw %ax, (%rsi,%rbx,2)
movq 0x40(%r15), %rdx
movq %rcx, (%rdx,%rbx,8)
incl %ebx
movzwl 0x46(%r10), %edx
incq %rax
movswq %dx, %rsi
cmpq %rsi, %rax
jl 0x2c401b
movq %r15, %rdi
callq 0x2c490f
jmp 0x2c40d0
movq %rdx, (%rcx)
movb 0x11a(%r15), %cl
movb %cl, 0x18(%rax)
movw $0xffff, 0x44(%r13)     # imm = 0xFFFF
movzbl 0x4e(%r13), %r9d
xorl %ecx, %ecx
movl %ecx, 0x18(%rsp)
movl %ecx, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movl $0x2, 0x20(%rsp)
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rax, %r8
callq 0x2ad938
cmpb $0x0, 0x61(%r12)
jne 0x2c40d0
cmpl $0x0, 0x30(%r15)
je 0x2c40df
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r13), %r15
testq %r15, %r15
je 0x2c4100
movzwl 0x63(%r15), %eax
andl $0x3, %eax
cmpw $0x2, %ax
je 0x2c3d97
movq 0x28(%r15), %r15
jmp 0x2c40e3
xorl %r15d, %r15d
jmp 0x2c3d97