// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq 0x148(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x28(%rbp)
jne 0x4188f7
jmp 0x418b91
movq -0x28(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x418924
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
leaq 0x194cf8(%rip), %rsi    # 0x5ad610
movb $0x0, %al
callq 0x3cb660
jmp 0x418b91
movq -0x28(%rbp), %rax
movl 0x40(%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0x40(%rax)
cmpq $0x0, -0x10(%rbp)
jne 0x418976
movq -0x28(%rbp), %rax
movswl 0x46(%rax), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x43cc70
movl $0x1, -0x3c(%rbp)
jmp 0x418a53
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x418a51
movq -0x10(%rbp), %rax
addq $0x8, %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x42ef20
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x43ccc0
movq -0x48(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x3b, %eax
jne 0x418a41
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jge 0x418a3f
movq -0x50(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3c3e60
cmpl $0x0, %eax
jne 0x418a32
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x43cc70
jmp 0x418a3f
jmp 0x418a34
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4189d9
jmp 0x418a41
jmp 0x418a43
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x418986
jmp 0x418a53
cmpl $0x1, -0x3c(%rbp)
jne 0x418b28
cmpq $0x0, -0x30(%rbp)
je 0x418b28
movq -0x30(%rbp), %rdi
leaq 0x184bb5(%rip), %rsi    # 0x59d628
callq 0x3d3c70
movq %rax, %rdi
leaq 0x1923d7(%rip), %rsi    # 0x5aae59
callq 0x3c3e60
cmpl $0x0, %eax
jne 0x418b28
cmpl $0x1, -0x1c(%rbp)
je 0x418b28
movq -0x8(%rbp), %rax
movzbl 0x11c(%rax), %eax
cmpl $0x2, %eax
jl 0x418ad7
cmpq $0x0, -0x10(%rbp)
je 0x418ad7
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x42ef20
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x44, %rsi
movq -0x58(%rbp), %rdx
callq 0x435010
movl -0x34(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x44(%rax)
movl -0x14(%rbp), %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x4e(%rax)
movl -0x18(%rbp), %ecx
shll $0x3, %ecx
movq -0x28(%rbp), %rax
orl 0x40(%rax), %ecx
movl %ecx, 0x40(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x418b19
movq -0x10(%rbp), %rax
movb 0x18(%rax), %cl
movq -0x8(%rbp), %rax
movb %cl, 0x11a(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x43cd10
jmp 0x418b8f
cmpl $0x0, -0x18(%rbp)
je 0x418b42
movq -0x8(%rbp), %rdi
leaq 0x194b00(%rip), %rsi    # 0x5ad639
movb $0x0, %al
callq 0x3cb660
jmp 0x418b8d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %r8
movl -0x14(%rbp), %r9d
movl -0x1c(%rbp), %eax
xorl %ecx, %ecx
xorl %edx, %edx
movq %rcx, %rsi
movq %rcx, %rdx
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x2, 0x20(%rsp)
callq 0x418bb0
movq $0x0, -0x10(%rbp)
jmp 0x418b8f
jmp 0x418b91
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x40c6a0
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)