// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3AddPrimaryKey
SQLITE_PRIVATE void sqlite3AddPrimaryKey(
  Parse *pParse,    /* Parsing context */
  ExprList *pList,  /* List of field names to be indexed */
  int onError,      /* What to do with a uniqueness conflict */
  int autoInc,      /* True if the AUTOINCREMENT keyword is present */
  int sortOrder     /* SQLITE_SO_ASC or SQLITE_SO_DESC */
){
  Table *pTab = pParse->pNewTable;
  Column *pCol = 0;
  int iCol = -1, i;
  int nTerm;
  if( pTab==0 ) goto primary_key_exit;
  if( pTab->tabFlags & TF_HasPrimaryKey ){
    sqlite3ErrorMsg(pParse,
      "table \"%s\" has more than one primary key", pTab->zName);
    goto primary_key_exit;
  }
  pTab->tabFlags |= TF_HasPrimaryKey;
  if( pList==0 ){
    iCol = pTab->nCol - 1;
    pCol = &pTab->aCol[iCol];
    makeColumnPartOfPrimaryKey(pParse, pCol);
    nTerm = 1;
  }else{
    nTerm = pList->nExpr;
    for(i=0; i<nTerm; i++){
      Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
      assert( pCExpr!=0 );
      sqlite3StringToId(pCExpr);
      if( pCExpr->op==TK_ID ){
        const char *zCName = pCExpr->u.zToken;
        for(iCol=0; iCol<pTab->nCol; iCol++){
          if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){
            pCol = &pTab->aCol[iCol];
            makeColumnPartOfPrimaryKey(pParse, pCol);
            break;
          }
        }
      }
    }
  }
  if( nTerm==1
   && pCol
   && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
   && sortOrder!=SQLITE_SO_DESC
  ){
    if( IN_RENAME_OBJECT && pList ){
      Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[0].pExpr);
      sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pCExpr);
    }
    pTab->iPKey = iCol;
    pTab->keyConf = (u8)onError;
    assert( autoInc==0 || autoInc==1 );
    pTab->tabFlags |= autoInc*TF_Autoincrement;
    if( pList ) pParse->iPkSortOrder = pList->a[0].sortFlags;
    (void)sqlite3HasExplicitNulls(pParse, pList);
  }else if( autoInc ){
#ifndef SQLITE_OMIT_AUTOINCREMENT
    sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
       "INTEGER PRIMARY KEY");
#endif
  }else{
    sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
                           0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY);
    pList = 0;
  }

primary_key_exit:
  sqlite3ExprListDelete(pParse->db, pList);
  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, 0x30(%rsp)
movq %rdi, %rbx
movq 0x148(%rdi), %r15
testq %r15, %r15
je 0x254cd4
movl %r8d, 0x48(%rsp)
movl %ecx, 0x4c(%rsp)
movl %edx, 0x44(%rsp)
movl 0x40(%r15), %eax
testb $0x4, %al
jne 0x254bbe
movq %rbx, 0x38(%rsp)
orl $0x4, %eax
movl %eax, 0x40(%r15)
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x254be1
movl (%rax), %ecx
testl %ecx, %ecx
movl $0x0, %r14d
movl %ecx, 0x5c(%rsp)
cmovgl %ecx, %r14d
leaq 0x8(%rax), %r12
pushq $-0x1
popq %rbx
xorl %ebp, %ebp
movq $0x0, 0x50(%rsp)
movq %r14, 0x68(%rsp)
movq %r12, 0x60(%rsp)
cmpq %r14, %rbp
je 0x254bd7
imulq $0x18, %rbp, %rax
movq (%r12,%rax), %rdi
callq 0x267c67
movq %rax, %r13
movq %rax, %rdi
callq 0x26f8c3
cmpb $0x3b, (%r13)
jne 0x254bb6
movq %rbp, 0x70(%rsp)
movzwl 0x46(%r15), %eax
testw %ax, %ax
movl $0x0, %ecx
cmovlel %ecx, %eax
movq 0x8(%r13), %rbp
movzwl %ax, %ebx
xorl %r14d, %r14d
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0x254ba7
movq 0x8(%r15), %r13
movq (%r13,%r14), %rsi
movq %rbp, %rdi
callq 0x221779
testl %eax, %eax
je 0x254b8f
incq %r12
addq $0x20, %r14
jmp 0x254b6c
addq %r14, %r13
movq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x26f8a3
movl %r12d, %ebx
movq %r13, 0x50(%rsp)
movq 0x68(%rsp), %r14
movq 0x60(%rsp), %r12
movq 0x70(%rsp), %rbp
incq %rbp
jmp 0x254b22
movq (%r15), %rdx
leaq 0x1239ce(%rip), %rsi    # 0x378596
movq %rbx, %rdi
xorl %eax, %eax
callq 0x226dce
jmp 0x254cd4
cmpl $0x1, 0x5c(%rsp)
sete %al
jmp 0x254c05
movswq 0x46(%r15), %rbx
decq %rbx
movq %rbx, %rsi
shlq $0x5, %rsi
addq 0x8(%r15), %rsi
movq 0x38(%rsp), %rdi
movq %rsi, 0x50(%rsp)
callq 0x26f8a3
movb $0x1, %al
testb %al, %al
je 0x254cb7
cmpq $0x0, 0x50(%rsp)
je 0x254cb7
leaq 0x115950(%rip), %rsi    # 0x36a570
movq 0x50(%rsp), %rdi
callq 0x22c117
leaq 0x1211c9(%rip), %rsi    # 0x375dfa
movq %rax, %rdi
callq 0x221779
cmpl $0x1, 0x48(%rsp)
je 0x254cb7
testl %eax, %eax
jne 0x254cb7
cmpq $0x0, 0x30(%rsp)
je 0x254c79
movq 0x38(%rsp), %rax
cmpb $0x2, 0x11c(%rax)
jb 0x254c79
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x267c67
leaq 0x44(%r15), %rsi
movq 0x38(%rsp), %rdi
movq %rax, %rdx
callq 0x26ae3e
movl 0x4c(%rsp), %eax
shll $0x3, %eax
orl %eax, 0x40(%r15)
movw %bx, 0x44(%r15)
movl 0x44(%rsp), %eax
movb %al, 0x4e(%r15)
movq 0x30(%rsp), %r14
testq %r14, %r14
movq 0x38(%rsp), %rbx
je 0x254caa
movb 0x18(%r14), %al
movb %al, 0x11a(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x26f8dd
jmp 0x254cd9
cmpl $0x0, 0x4c(%rsp)
je 0x254cf2
leaq 0x1238fa(%rip), %rsi    # 0x3785bf
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x226dce
movq 0x30(%rsp), %r14
movq (%rbx), %rdi
movq %r14, %rsi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x24b63f
movl 0x48(%rsp), %eax
movl %eax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
andl $0x0, 0x18(%rsp)
movl $0x2, 0x20(%rsp)
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x30(%rsp), %r8
movl 0x44(%rsp), %r9d
callq 0x254d30
xorl %r14d, %r14d
jmp 0x254cd9