// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rdi, %r15
movq (%rdi), %rax
movq 0x10(%rdi), %r14
movq %rax, 0x28(%rsp)
testb $0x2, 0xb6(%rax)
jne 0x2cd397
movswq 0x46(%r12), %rax
testq %rax, %rax
jle 0x2cd391
movq 0x8(%r12), %rcx
shlq $0x5, %rax
xorl %edx, %edx
testb $0x1, 0x1c(%rcx,%rdx)
je 0x2cd388
movb $0x2, 0x18(%rcx,%rdx)
addq $0x20, %rdx
cmpq %rdx, %rax
jne 0x2cd37c
orb $0x8, 0x41(%r12)
movl 0xc0(%r15), %eax
testl %eax, %eax
je 0x2cd3d7
jns 0x2cd3ad
movl 0x90(%r14), %eax
decl %eax
movq (%r14), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x2cd3bf
leaq 0x1fcacb(%rip), %rax    # 0x4c9e88
jmp 0x2cd3d0
cltq
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x88(%r14), %rax
movl $0x2, 0xc(%rax)
movswq 0x44(%r12), %rax
testq %rax, %rax
movq %r12, 0x38(%rsp)
js 0x2cd411
movq 0x8(%r12), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rdi
movq %rdi, 0x48(%rsp)
testq %rdi, %rdi
je 0x2cd4a1
callq 0x172f0
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jmp 0x2cd4a3
movq 0x10(%r12), %r15
testq %r15, %r15
je 0x2cd42f
movzwl 0x63(%r15), %eax
andl $0x3, %eax
cmpw $0x2, %ax
je 0x2cd42f
movq 0x28(%r15), %r15
jmp 0x2cd416
movw $0x1, %bp
cmpw $0x2, 0x5e(%r15)
jb 0x2cd497
movl $0x1, %ebp
movl $0x1, %r12d
movq %r15, %rdi
movl %ebp, %esi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x2cdf67
testl %eax, %eax
je 0x2cd461
decw 0x60(%r15)
jmp 0x2cd48a
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)
incq %r12
movzwl 0x5e(%r15), %eax
cmpq %rax, %r12
jb 0x2cd446
movw %bp, 0x5e(%r15)
jmp 0x2cd568
xorl %eax, %eax
leaq 0x48(%rsp), %rdx
movl %eax, 0x8(%rdx)
xorl %ebx, %ebx
movq 0x28(%rsp), %rdi
movl $0x3b, %esi
xorl %ecx, %ecx
callq 0x2bb38d
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2bb1a3
testq %rax, %rax
je 0x2cd560
cmpb $0x2, 0x11c(%r15)
jb 0x2cd506
movq 0x1a0(%r15), %rcx
testq %rcx, %rcx
je 0x2cd506
leaq 0x44(%r12), %rsi
movq 0x8(%rax), %rdx
cmpq %rsi, (%rcx)
je 0x2cd503
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
jne 0x2cd4f3
jmp 0x2cd506
movq %rdx, (%rcx)
movb 0x11a(%r15), %cl
movb %cl, 0x18(%rax)
movw $0xffff, 0x44(%r12)     # imm = 0xFFFF
movzbl 0x4e(%r12), %r9d
xorl %ebx, %ebx
movl %ebx, 0x18(%rsp)
movl %ebx, 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 0x2b7555
movq 0x28(%rsp), %rax
cmpb $0x0, 0x61(%rax)
jne 0x2cd560
cmpl $0x0, 0x30(%r15)
je 0x2cd81e
xorl %ebx, %ebx
testb %bl, %bl
je 0x2cd80f
movzwl 0x63(%r15), %eax
movl %eax, %ecx
orl $0x20, %ecx
movw %cx, 0x63(%r15)
movq 0x28(%rsp), %rcx
testb $0x2, 0xb6(%rcx)
jne 0x2cd58d
orl $0x28, %eax
movw %ax, 0x63(%r15)
movzwl 0x5e(%r15), %ebp
movw %bp, 0x60(%r15)
testq %r14, %r14
movq 0x38(%rsp), %rdx
je 0x2cd5da
movl 0x58(%r15), %eax
testl %eax, %eax
je 0x2cd5da
jns 0x2cd5b4
movl 0x90(%r14), %eax
decl %eax
movq (%r14), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x2cd5c6
leaq 0x1fc8c4(%rip), %rax    # 0x4c9e88
jmp 0x2cd5d7
cltq
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x88(%r14), %rax
movb $0xb, (%rax)
movl 0x38(%rdx), %eax
movl %eax, 0x58(%r15)
movq 0x10(%rdx), %r12
testq %r12, %r12
je 0x2cd71f
movl %ebp, %r14d
movq %rbp, 0x30(%rsp)
movq %r14, 0x40(%rsp)
movzwl 0x63(%r12), %eax
andl $0x3, %eax
movl $0xa, %ecx
cmpw $0x2, %ax
je 0x2cd704
testl %ebp, %ebp
je 0x2cd647
movzwl 0x5e(%r12), %r13d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq 0x30(%rsp), %rbx
movq %r12, %rdi
movl %r13d, %esi
movq %r15, %rdx
movl %r14d, %ecx
callq 0x2cdf67
xorl $0x1, %eax
addl %eax, %ebp
incl %r14d
cmpl %r14d, %ebx
jne 0x2cd627
jmp 0x2cd649
xorl %ebp, %ebp
movzwl 0x5e(%r12), %eax
testl %ebp, %ebp
movq 0x40(%rsp), %r14
je 0x2cd6ed
movzwl %ax, %eax
addl %eax, %ebp
movq 0x28(%rsp), %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x2cdff0
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
jne 0x2cd6ff
movq 0x30(%rsp), %rbp
testw %bp, %bp
je 0x2cd704
movzwl 0x5e(%r12), %ebx
xorl %r13d, %r13d
movzwl 0x5e(%r12), %esi
movq %r12, %rdi
movq %r15, %rdx
movl %r13d, %ecx
callq 0x2cdf67
testl %eax, %eax
jne 0x2cd6e1
movq 0x8(%r15), %rax
movzwl (%rax,%r13,2), %eax
movq 0x8(%r12), %rcx
movslq %ebx, %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 0x2cd6df
orb $0x2, 0x64(%r12)
incl %ebx
incq %r13
cmpq %r13, %r14
jne 0x2cd690
xorl %ecx, %ecx
jmp 0x2cd704
movw %ax, 0x60(%r12)
movq 0x30(%rsp), %rbp
movl $0xa, %ecx
jmp 0x2cd704
movq 0x30(%rsp), %rbp
cmpl $0xa, %ecx
je 0x2cd711
testl %ecx, %ecx
jne 0x2cd80f
movq 0x28(%r12), %r12
testq %r12, %r12
jne 0x2cd5fb
movq 0x38(%rsp), %r11
movswq 0x46(%r11), %rax
testq %rax, %rax
jle 0x2cd782
movq 0x8(%r15), %rcx
xorl %esi, %esi
xorl %edx, %edx
movq %rcx, %rdi
movl %ebp, %r9d
testl %r9d, %r9d
jle 0x2cd75d
movl %r9d, %r8d
leal -0x1(%r8), %r9d
movswq (%rdi), %r10
addq $0x2, %rdi
movl %r10d, %r10d
cmpq %r10, %rsi
jne 0x2cd73c
testl %r8d, %r8d
jg 0x2cd778
movq 0x8(%r11), %rdi
movq %rsi, %r8
shlq $0x5, %r8
movb 0x1c(%rdi,%r8), %dil
andb $0x20, %dil
cmpb $0x1, %dil
adcl $0x0, %edx
incq %rsi
cmpq %rax, %rsi
jne 0x2cd736
jmp 0x2cd784
xorl %edx, %edx
addl %ebp, %edx
movq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x2cdff0
testl %eax, %eax
jne 0x2cd80f
movq 0x38(%rsp), %r10
cmpw $0x0, 0x46(%r10)
jle 0x2cd807
xorl %eax, %eax
leaq 0x10db33(%rip), %rcx    # 0x3db2e0
movq 0x8(%r15), %rdx
movq %rdx, %rsi
movl %ebp, %r8d
testl %r8d, %r8d
jle 0x2cd7d7
movl %r8d, %edi
leal -0x1(%rdi), %r8d
movswq (%rsi), %r9
addq $0x2, %rsi
movl %r9d, %r9d
cmpq %r9, %rax
jne 0x2cd7b7
testl %edi, %edi
jg 0x2cd7fa
movq 0x8(%r10), %rsi
movq %rax, %rdi
shlq $0x5, %rdi
testb $0x20, 0x1c(%rsi,%rdi)
jne 0x2cd7fa
movslq %ebp, %rbp
movw %ax, (%rdx,%rbp,2)
movq 0x40(%r15), %rdx
movq %rcx, (%rdx,%rbp,8)
incl %ebp
incq %rax
movswq 0x46(%r10), %rdx
cmpq %rdx, %rax
jl 0x2cd7ad
movq %r15, %rdi
callq 0x2ce08d
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r12), %r15
movb $0x1, %bl
testq %r15, %r15
je 0x2cd560
movzwl 0x63(%r15), %eax
andl $0x3, %eax
cmpw $0x2, %ax
je 0x2cd560
movq 0x28(%r15), %r15
jmp 0x2cd825