// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rdi, %r14
movq 0x148(%rdi), %r10
testq %r10, %r10
je 0x2b7528
movl 0x40(%r10), %eax
testb $0x4, %al
jne 0x2b734f
movl %edx, %ebp
orl $0x4, %eax
movl %eax, 0x40(%r10)
testq %r13, %r13
movl %ecx, 0x3c(%rsp)
je 0x2b7368
movl %r8d, 0x2c(%rsp)
movl %ebp, 0x38(%rsp)
movslq (%r13), %rdi
testq %rdi, %rdi
jle 0x2b73bd
movq %r14, 0x50(%rsp)
movq %r13, 0x40(%rsp)
leaq 0x8(%r13), %r15
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
leaq 0x123827(%rip), %r14    # 0x3daa60
xorl %ebx, %ebx
movq $0x0, 0x30(%rsp)
movq %rdi, 0x48(%rsp)
leaq (%rbx,%rbx,2), %rax
movq (%r15,%rax,8), %rcx
testq %rcx, %rcx
je 0x2b7262
testb $0x10, 0x5(%rcx)
je 0x2b7262
movq 0x10(%rcx), %rcx
jmp 0x2b7251
movzbl (%rcx), %edx
movq %rcx, %rax
cmpl $0x73, %edx
je 0x2b727b
cmpl $0x6f, %edx
jne 0x2b727e
movq 0x10(%rcx), %rax
cmpb $0x73, (%rax)
jne 0x2b727e
movb $0x3b, (%rax)
cmpb $0x3b, (%rcx)
jne 0x2b7320
movswl 0x46(%r10), %eax
testl %eax, %eax
jle 0x2b72ea
movq 0x8(%rcx), %rcx
movq %r10, %r13
movq 0x8(%r10), %rdx
movslq %eax, %rsi
xorl %r12d, %r12d
movq %r12, %rdi
shlq $0x5, %rdi
leaq (%rdx,%rdi), %rbp
movq (%rdx,%rdi), %rdi
xorl %r8d, %r8d
movzbl (%rcx,%r8), %r9d
movzbl (%rdi,%r8), %r10d
cmpb %r10b, %r9b
jne 0x2b72c9
testq %r9, %r9
jne 0x2b72d3
jmp 0x2b72d8
movb (%r9,%r14), %r11b
cmpb (%r10,%r14), %r11b
jne 0x2b72d8
incq %r8
jmp 0x2b72b3
cmpb %r10b, %r9b
je 0x2b72ef
incq %r12
cmpq %rsi, %r12
jne 0x2b72a1
movl %eax, %r12d
jmp 0x2b7318
xorl %r12d, %r12d
jmp 0x2b7320
movzwl 0x1c(%rbp), %eax
movl %eax, %ecx
orl $0x1, %ecx
movw %cx, 0x1c(%rbp)
testb $0x60, %al
je 0x2b7313
movq 0x50(%rsp), %rdi
leaq 0x12a620(%rip), %rsi    # 0x3e192c
xorl %eax, %eax
callq 0x284eb8
movq %rbp, 0x30(%rsp)
movq %r13, %r10
movq 0x48(%rsp), %rdi
incq %rbx
cmpq %rdi, %rbx
jne 0x2b7249
cmpl $0x1, %edi
sete %bl
movq 0x50(%rsp), %r14
movq 0x40(%rsp), %r13
movl 0x38(%rsp), %ebp
movl 0x2c(%rsp), %r8d
movq 0x30(%rsp), %r9
jmp 0x2b73d1
movq (%r10), %rdx
leaq 0x12a572(%rip), %rsi    # 0x3e18cb
movq %r14, %rdi
xorl %eax, %eax
callq 0x284eb8
jmp 0x2b7528
movswq 0x46(%r10), %r12
decq %r12
movq 0x8(%r10), %rax
movq %r12, %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %r9
movzwl 0x1c(%rax,%rcx), %edx
movl %edx, %esi
orl $0x1, %esi
movw %si, 0x1c(%rax,%rcx)
movb $0x1, %bl
testb $0x60, %dl
je 0x2b73d1
leaq 0x12a590(%rip), %rsi    # 0x3e192c
movq %r14, %rdi
xorl %eax, %eax
movl %r8d, 0x2c(%rsp)
movq %r9, 0x30(%rsp)
movq %r10, %r15
callq 0x284eb8
movq %r15, %r10
movq 0x30(%rsp), %r9
jmp 0x2b73cc
xorl %ebx, %ebx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %r9d, %r9d
movl 0x38(%rsp), %ebp
movl 0x2c(%rsp), %r8d
testb %bl, %bl
je 0x2b7488
testq %r9, %r9
je 0x2b7488
testb $0x4, 0x1c(%r9)
jne 0x2b73f2
leaq 0x11c4a0(%rip), %rax    # 0x3d3890
jmp 0x2b7419
movq %r13, 0x40(%rsp)
movq (%r9), %r13
movq %r13, %rdi
movl %r8d, %ebx
movq %r10, %r15
callq 0x172f0
movq %r15, %r10
movl %ebx, %r8d
addq %r13, %rax
incq %rax
movq 0x40(%rsp), %r13
xorl %ecx, %ecx
leaq 0x127d0c(%rip), %rdx    # 0x3df12e
leaq 0x123637(%rip), %rsi    # 0x3daa60
movzbl (%rax,%rcx), %edi
movzbl (%rcx,%rdx), %r11d
cmpb %r11b, %dil
jne 0x2b743e
testq %rdi, %rdi
jne 0x2b7448
jmp 0x2b744d
movb (%rdi,%rsi), %r9b
cmpb (%r11,%rsi), %r9b
jne 0x2b744d
incq %rcx
jmp 0x2b7429
cmpl $0x1, %r8d
je 0x2b7488
cmpb %r11b, %dil
jne 0x2b7488
testq %r13, %r13
movl 0x3c(%rsp), %esi
je 0x2b74fd
cmpb $0x2, 0x11c(%r14)
jb 0x2b74fd
movq 0x8(%r13), %rax
testq %rax, %rax
je 0x2b74da
testb $0x10, 0x5(%rax)
je 0x2b74da
movq 0x10(%rax), %rax
jmp 0x2b7477
cmpl $0x0, 0x3c(%rsp)
je 0x2b74a5
leaq 0x12a45e(%rip), %rsi    # 0x3e18f4
movq %r14, %rdi
xorl %eax, %eax
callq 0x284eb8
jmp 0x2b7528
movl %r8d, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movl $0x2, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r13, %r8
movl %ebp, %r9d
callq 0x2b7555
xorl %r13d, %r13d
jmp 0x2b7528
movq 0x1a0(%r14), %rcx
testq %rcx, %rcx
je 0x2b74fd
leaq 0x44(%r10), %rdx
cmpq %rax, (%rcx)
je 0x2b74fa
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
jne 0x2b74ea
jmp 0x2b74fd
movq %rdx, (%rcx)
shll $0x3, %esi
orl %esi, 0x40(%r10)
movw %r12w, 0x44(%r10)
movb %bpl, 0x4e(%r10)
testq %r13, %r13
je 0x2b751d
movb 0x18(%r13), %al
movb %al, 0x11a(%r14)
movq %r14, %rdi
movq %r13, %rsi
callq 0x2d34a4
testq %r13, %r13
je 0x2b7546
movq (%r14), %rdi
movq %r13, %rsi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b0183
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq