// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movq %rsi, %r14
movq %rdi, %r13
movq 0x148(%rdi), %r11
testq %r11, %r11
je 0x2ad87c
movl 0x40(%r11), %eax
testb $0x4, %al
jne 0x2ad74a
movl %edx, 0x2c(%rsp)
orl $0x4, %eax
movl %eax, 0x40(%r11)
testq %r14, %r14
movq %r11, 0x38(%rsp)
movl %r8d, 0x30(%rsp)
je 0x2ad763
movslq (%r14), %r15
testq %r15, %r15
jle 0x2ad867
movl %ecx, 0x34(%rsp)
movq %r13, 0x40(%rsp)
movq %r14, 0x48(%rsp)
leaq 0x8(%r14), %rbx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
leaq 0x123c97(%rip), %r13    # 0x3d12e0
xorl %r14d, %r14d
xorl %ebp, %ebp
leaq (%r14,%r14,2), %rax
movq (%rbx,%rax,8), %rax
testq %rax, %rax
je 0x2ad667
testb $0x10, 0x5(%rax)
je 0x2ad669
movq 0x10(%rax), %rax
jmp 0x2ad656
xorl %eax, %eax
movzbl (%rax), %ecx
movq %rax, %rdx
cmpl $0x73, %ecx
je 0x2ad686
cmpl $0x6f, %ecx
jne 0x2ad68b
movq 0x10(%rax), %rdx
cmpb $0x73, (%rdx)
jne 0x2ad72b
movb $0x3b, (%rdx)
movb (%rax), %cl
cmpb $0x3b, %cl
jne 0x2ad72b
movswl 0x46(%r11), %ecx
testl %ecx, %ecx
jle 0x2ad728
movq %rbp, 0x50(%rsp)
movq 0x8(%rax), %rax
movq 0x8(%r11), %rdx
movslq %ecx, %rsi
xorl %r12d, %r12d
movq %r12, %rdi
shlq $0x5, %rdi
leaq (%rdx,%rdi), %rbp
movq (%rdx,%rdi), %rdi
xorl %r8d, %r8d
movzbl (%rax,%r8), %r9d
movzbl (%rdi,%r8), %r10d
cmpb %r10b, %r9b
jne 0x2ad6dc
testq %r9, %r9
jne 0x2ad6e6
jmp 0x2ad6fd
movb (%r9,%r13), %r9b
cmpb (%r10,%r13), %r9b
jne 0x2ad6eb
incq %r8
jmp 0x2ad6c6
incq %r12
cmpq %rsi, %r12
jne 0x2ad6b4
movl %ecx, %r12d
movq 0x50(%rsp), %rbp
jmp 0x2ad72b
movzwl 0x1c(%rbp), %eax
movl %eax, %ecx
orl $0x1, %ecx
movw %cx, 0x1c(%rbp)
testb $0x60, %al
je 0x2ad72b
movq 0x40(%rsp), %rdi
leaq 0x12aabd(%rip), %rsi    # 0x3d81d7
xorl %eax, %eax
callq 0x27b48d
movq 0x38(%rsp), %r11
jmp 0x2ad72b
xorl %r12d, %r12d
incq %r14
cmpq %r15, %r14
jne 0x2ad64e
cmpl $0x1, %r15d
sete %bl
movq 0x48(%rsp), %r14
movq 0x40(%rsp), %r13
jmp 0x2ad7aa
movq (%r11), %rdx
leaq 0x12aa22(%rip), %rsi    # 0x3d8176
movq %r13, %rdi
xorl %eax, %eax
callq 0x27b48d
jmp 0x2ad87c
movl %ecx, 0x34(%rsp)
movswq 0x46(%r11), %r12
decq %r12
movq 0x8(%r11), %rax
movq %r12, %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %rbp
movzwl 0x1c(%rax,%rcx), %edx
movl %edx, %esi
orl $0x1, %esi
movw %si, 0x1c(%rax,%rcx)
movb $0x1, %bl
testb $0x60, %dl
je 0x2ad7aa
leaq 0x12aa3c(%rip), %rsi    # 0x3d81d7
movq %r13, %rdi
xorl %eax, %eax
callq 0x27b48d
movq 0x38(%rsp), %r11
testb %bl, %bl
movl 0x34(%rsp), %ecx
je 0x2ad867
testq %rbp, %rbp
je 0x2ad867
testb $0x4, 0x1c(%rbp)
jne 0x2ad7ce
leaq 0x11c9a4(%rip), %rax    # 0x3ca170
jmp 0x2ad7f1
movq %rbp, %rax
movl %ecx, %ebp
movq %r13, %rbx
movq (%rax), %r13
movq %r13, %rdi
callq 0x172f0
movq 0x38(%rsp), %r11
addq %r13, %rax
incq %rax
movq %rbx, %r13
movl %ebp, %ecx
xorl %r9d, %r9d
leaq 0x1281df(%rip), %rdx    # 0x3d59da
leaq 0x123ade(%rip), %rsi    # 0x3d12e0
movzbl (%rax,%r9), %edi
movzbl (%r9,%rdx), %r8d
cmpb %r8b, %dil
jne 0x2ad818
testq %rdi, %rdi
jne 0x2ad822
jmp 0x2ad827
movb (%rdi,%rsi), %dil
cmpb (%r8,%rsi), %dil
jne 0x2ad867
incq %r9
jmp 0x2ad802
cmpl $0x1, 0x30(%rsp)
je 0x2ad867
cmpb %r8b, %dil
jne 0x2ad867
testq %r14, %r14
je 0x2ad904
cmpb $0x2, 0x11c(%r13)
jb 0x2ad904
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x2ad8df
testb $0x10, 0x5(%rax)
je 0x2ad8e1
movq 0x10(%rax), %rax
jmp 0x2ad84e
testl %ecx, %ecx
je 0x2ad89b
leaq 0x12a92d(%rip), %rsi    # 0x3d819f
movq %r13, %rdi
xorl %eax, %eax
callq 0x27b48d
testq %r14, %r14
je 0x2ad8d0
movq (%r13), %rdi
movq %r14, %rsi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2a65a3
movl 0x30(%rsp), %eax
movl %eax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movl $0x2, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
movl 0x2c(%rsp), %r9d
callq 0x2ad938
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
movq 0x1a0(%r13), %rsi
testq %rsi, %rsi
je 0x2ad904
leaq 0x44(%r11), %rdx
cmpq %rax, (%rsi)
je 0x2ad901
movq 0x18(%rsi), %rsi
testq %rsi, %rsi
jne 0x2ad8f1
jmp 0x2ad904
movq %rdx, (%rsi)
shll $0x3, %ecx
orl %ecx, 0x40(%r11)
movw %r12w, 0x44(%r11)
movl 0x2c(%rsp), %eax
movb %al, 0x4e(%r11)
testq %r14, %r14
je 0x2ad8d0
movb 0x18(%r14), %al
movb %al, 0x11a(%r13)
movq %r13, %rdi
movq %r14, %rsi
callq 0x2c9bfa
jmp 0x2ad881