// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/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;
  char *zType = 0;
  int iCol = -1, i;
  if( pTab==0 || IN_DECLARE_VTAB ) 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;
    pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY;
  }else{
    for(i=0; i<pList->nExpr; i++){
      for(iCol=0; iCol<pTab->nCol; iCol++){
        if( sqlite3StrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ){
          break;
        }
      }
      if( iCol<pTab->nCol ){
        pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY;
      }
    }
    if( pList->nExpr>1 ) iCol = -1;
  }
  if( iCol>=0 && iCol<pTab->nCol ){
    zType = pTab->aCol[iCol].zType;
  }
  if( zType && sqlite3StrICmp(zType, "INTEGER")==0
        && sortOrder==SQLITE_SO_ASC ){
    pTab->iPKey = iCol;
    pTab->keyConf = (u8)onError;
    assert( autoInc==0 || autoInc==1 );
    pTab->tabFlags |= autoInc*TF_Autoincrement;
  }else if( autoInc ){
#ifndef SQLITE_OMIT_AUTOINCREMENT
    sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
       "INTEGER PRIMARY KEY");
#endif
  }else{
    Index *p;
    p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
                           0, sortOrder, 0);
    if( p ){
      p->autoIndex = 2;
    }
    pList = 0;
  }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r8d, -0x38(%rbp)
movq %rsi, %r15
movq %rdi, %rbx
movq 0x238(%rdi), %rsi
testq %rsi, %rsi
je 0x36c9f
cmpb $0x0, 0x201(%rbx)
jne 0x36c9f
movb 0x46(%rsi), %r14b
testb $0x4, %r14b
jne 0x36bcc
movl %ecx, -0x34(%rbp)
movl %edx, -0x30(%rbp)
movq %rbx, -0x40(%rbp)
orb $0x4, %r14b
movb %r14b, 0x46(%rsi)
testq %r15, %r15
je 0x36bed
movl (%r15), %eax
testl %eax, %eax
movl $0x0, %ecx
movl %eax, -0x44(%rbp)
cmovgl %eax, %ecx
movq %rcx, -0x60(%rbp)
pushq $-0x1
popq %r13
xorl %edi, %edi
movb %r14b, -0x29(%rbp)
movq %r15, -0x50(%rbp)
cmpq -0x60(%rbp), %rdi
je 0x36be5
movzwl 0x42(%rsi), %eax
testw %ax, %ax
movl $0x0, %ecx
cmovlel %ecx, %eax
movzwl %ax, %r13d
movq %rdi, %rax
shlq $0x5, %rax
movq %rax, -0x68(%rbp)
pushq $0x2a
popq %r12
xorl %r14d, %r14d
movq %rdi, -0x58(%rbp)
cmpq %r14, %r13
je 0x36bc0
movq 0x8(%r15), %rax
movq -0x68(%rbp), %rcx
movq 0x8(%rax,%rcx), %rdi
movq %rsi, %rbx
movq 0x8(%rsi), %r15
movq -0x2a(%r15,%r12), %rsi
callq 0xb1bf
testl %eax, %eax
je 0x36bad
incq %r14
addq $0x30, %r12
movq -0x50(%rbp), %r15
movq %rbx, %rsi
movq -0x58(%rbp), %rdi
jmp 0x36b72
orb $0x1, (%r15,%r12)
movl %r14d, %r13d
movq -0x50(%rbp), %r15
movq %rbx, %rsi
movq -0x58(%rbp), %rdi
incq %rdi
movb -0x29(%rbp), %r14b
jmp 0x36b3f
movq (%rsi), %rdx
leaq 0x36823(%rip), %rsi     # 0x6d3f9
movq %rbx, %rdi
xorl %eax, %eax
callq 0x104d6
jmp 0x36c9f
cmpl $0x1, -0x44(%rbp)
jle 0x36c05
jmp 0x36c3c
movswl 0x42(%rsi), %eax
cltq
leal -0x1(%rax), %r13d
movq 0x8(%rsi), %rcx
imulq $0x30, %rax, %rax
orw $0x1, -0x6(%rax,%rcx)
testl %r13d, %r13d
js 0x36c3c
movswl 0x42(%rsi), %eax
cmpl %eax, %r13d
jge 0x36c3c
movq 0x8(%rsi), %rax
movl %r13d, %ecx
imulq $0x30, %rcx, %rcx
movq 0x18(%rax,%rcx), %rdi
testq %rdi, %rdi
je 0x36c3c
movq %rsi, %rbx
leaq 0x3665e(%rip), %rsi     # 0x6d290
callq 0xb1bf
orl -0x38(%rbp), %eax
je 0x36cb8
cmpl $0x0, -0x34(%rbp)
je 0x36c59
leaq 0x367d9(%rip), %rsi     # 0x6d422
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x104d6
jmp 0x36c9f
movl -0x38(%rbp), %eax
movl %eax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
andl $0x0, 0x18(%rsp)
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
movl -0x30(%rbp), %r9d
callq 0x36cd6
movl $0x0, %r15d
testq %rax, %rax
je 0x36c9f
movb 0x57(%rax), %cl
andb $-0x4, %cl
orb $0x2, %cl
movb %cl, 0x57(%rax)
xorl %r15d, %r15d
movq (%rbx), %rdi
movq %r15, %rsi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f527
movw %r13w, 0x40(%rbx)
movl -0x30(%rbp), %eax
movb %al, 0x47(%rbx)
movl -0x34(%rbp), %eax
shlb $0x3, %al
orb %al, %r14b
movb %r14b, 0x46(%rbx)
movq -0x40(%rbp), %rbx
jmp 0x36c9f