// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movq %rsi, %r12
movq %rdi, %r14
movq 0x238(%rdi), %rax
testq %rax, %rax
je 0x3a93d
cmpb $0x0, 0x201(%r14)
jne 0x3a93d
movb 0x46(%rax), %r9b
testb $0x4, %r9b
jne 0x3a811
movl %edx, %r15d
orb $0x4, %r9b
movb %r9b, 0x46(%rax)
testq %r12, %r12
je 0x3a82a
movslq (%r12), %rsi
movq %rsi, -0x40(%rbp)
testq %rsi, %rsi
jle 0x3a8e4
movb %r9b, -0x29(%rbp)
movl %r8d, -0x30(%rbp)
movl %r15d, -0x34(%rbp)
movq %r14, -0x48(%rbp)
movswl 0x42(%rax), %r10d
xorl %r11d, %r11d
leaq 0x3b964(%rip), %r15     # 0x760b0
movl $0x0, %esi
testw %r10w, %r10w
jle 0x3a7e9
movq %r12, %r8
movq 0x8(%r12), %rdx
movq %r11, %rsi
shlq $0x5, %rsi
movq 0x8(%rdx,%rsi), %r13
movq 0x8(%rax), %r12
movb (%r13), %dl
xorl %esi, %esi
leaq (%rsi,%rsi,2), %rdi
shlq $0x4, %rdi
movq (%r12,%rdi), %r9
testb %dl, %dl
je 0x3a7c3
xorl %r14d, %r14d
movl %edx, %edi
movzbl %dil, %edi
movb (%rdi,%r15), %bl
movzbl (%r9,%r14), %edi
movb (%rdi,%r15), %dil
cmpb %dil, %bl
jne 0x3a7bc
movb 0x1(%r13,%r14), %dil
incq %r14
testb %dil, %dil
jne 0x3a78e
movzbl (%r9,%r14), %edi
movb (%rdi,%r15), %dil
xorl %ebx, %ebx
cmpb %dil, %bl
jne 0x3a7c9
jmp 0x3a7d6
cmpb $0x0, (%r9)
je 0x3a7d6
incq %rsi
cmpq %r10, %rsi
jne 0x3a779
movl %r10d, %esi
jmp 0x3a7e6
movl %esi, %edx
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
orb $0x1, 0x2a(%r12,%rdx)
movq %r8, %r12
incq %r11
cmpq -0x40(%rbp), %r11
jne 0x3a74c
cmpl $0x1, -0x40(%rbp)
movq -0x48(%rbp), %r14
movl -0x34(%rbp), %r15d
movl -0x30(%rbp), %r8d
movb -0x29(%rbp), %r9b
je 0x3a846
jmp 0x3a8e4
movq (%rax), %rdx
leaq 0x40bbe(%rip), %rsi     # 0x7b3d9
movq %r14, %rdi
xorl %eax, %eax
callq 0x11842
jmp 0x3a93d
movswl 0x42(%rax), %edx
movslq %edx, %rdx
leal -0x1(%rdx), %esi
movq 0x8(%rax), %rdi
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
orw $0x1, -0x6(%rdx,%rdi)
testl %esi, %esi
js 0x3a8e4
movswl 0x42(%rax), %edx
cmpl %edx, %esi
jge 0x3a8e4
movq 0x8(%rax), %rdx
movl %esi, %edi
leaq (%rdi,%rdi,2), %rdi
shlq $0x4, %rdi
movq 0x18(%rdx,%rdi), %r10
testq %r10, %r10
je 0x3a8e4
movb %r9b, -0x29(%rbp)
movl %r8d, %r13d
movb (%r10), %r11b
testb %r11b, %r11b
je 0x3a8b5
incq %r10
leaq 0x409e5(%rip), %rdx     # 0x7b270
leaq 0x3b81e(%rip), %r9      # 0x760b0
xorl %edi, %edi
movzbl %r11b, %r8d
movb (%r8,%r9), %r11b
movzbl (%rdx), %ebx
cmpb (%rbx,%r9), %r11b
jne 0x3a8c0
incq %rdx
movb (%r10), %r11b
incq %r10
testb %r11b, %r11b
jne 0x3a894
jmp 0x3a8c3
leaq 0x409b4(%rip), %rdx     # 0x7b270
xorl %edi, %edi
jmp 0x3a8c3
movq %r8, %rdi
leaq 0x3b7e6(%rip), %r8      # 0x760b0
movzbl (%rdi,%r8), %edi
movzbl (%rdx), %edx
movzbl (%rdx,%r8), %edx
subl %edx, %edi
movl %r13d, %r8d
orl %r13d, %edi
movb -0x29(%rbp), %dl
je 0x3a956
testl %ecx, %ecx
je 0x3a8fb
leaq 0x40b13(%rip), %rsi     # 0x7b402
movq %r14, %rdi
xorl %eax, %eax
callq 0x11842
jmp 0x3a93d
movl %r8d, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movl $0x0, 0x18(%rsp)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
movl %r15d, %r9d
callq 0x3a968
movl $0x0, %r12d
testq %rax, %rax
je 0x3a93d
movb 0x57(%rax), %cl
andb $-0x4, %cl
orb $0x2, %cl
movb %cl, 0x57(%rax)
xorl %r12d, %r12d
movq (%r14), %rdi
movq %r12, %rsi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3484e
movw %si, 0x40(%rax)
movb %r15b, 0x47(%rax)
shlb $0x3, %cl
orb %cl, %dl
movb %dl, 0x46(%rax)
jmp 0x3a93d