// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %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 0x238(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x28(%rbp)
je 0x50a6f
movq -0x8(%rbp), %rax
movzbl 0x201(%rax), %eax
cmpl $0x0, %eax
je 0x50a74
jmp 0x50ca6
movq -0x28(%rbp), %rax
movzbl 0x46(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x50aa2
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
leaq 0x5f43f(%rip), %rsi     # 0xafed5
movb $0x0, %al
callq 0x136f0
jmp 0x50ca6
movq -0x28(%rbp), %rax
movzbl 0x46(%rax), %ecx
orl $0x4, %ecx
movb %cl, 0x46(%rax)
cmpq $0x0, -0x10(%rbp)
jne 0x50ae8
movq -0x28(%rbp), %rax
movswl 0x42(%rax), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movzwl 0x2a(%rax), %ecx
orl $0x1, %ecx
movw %cx, 0x2a(%rax)
jmp 0x50ba9
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x50b97
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
movswl 0x42(%rcx), %ecx
cmpl %ecx, %eax
jge 0x50b5a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0xc970
cmpl $0x0, %eax
jne 0x50b4d
jmp 0x50b5a
jmp 0x50b4f
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x50b05
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
movswl 0x42(%rcx), %ecx
cmpl %ecx, %eax
jge 0x50b87
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movzwl 0x2a(%rax), %ecx
orl $0x1, %ecx
movw %cx, 0x2a(%rax)
jmp 0x50b89
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x50aef
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jle 0x50ba7
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
jmp 0x50ba9
cmpl $0x0, -0x34(%rbp)
jl 0x50bd9
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
movswl 0x42(%rcx), %ecx
cmpl %ecx, %eax
jge 0x50bd9
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x50c2a
movq -0x30(%rbp), %rdi
leaq 0x5f181(%rip), %rsi     # 0xafd6c
callq 0xc970
cmpl $0x0, %eax
jne 0x50c2a
cmpl $0x0, -0x1c(%rbp)
jne 0x50c2a
movl -0x34(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x40(%rax)
movl -0x14(%rbp), %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x47(%rax)
movl -0x18(%rbp), %edx
shll $0x3, %edx
movq -0x28(%rbp), %rax
movzbl 0x46(%rax), %ecx
orl %edx, %ecx
movb %cl, 0x46(%rax)
jmp 0x50ca4
cmpl $0x0, -0x18(%rbp)
je 0x50c44
movq -0x8(%rbp), %rdi
leaq 0x5f2c3(%rip), %rsi     # 0xafefe
movb $0x0, %al
callq 0x136f0
jmp 0x50ca2
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)
callq 0x50cc0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x50c9a
movq -0x40(%rbp), %rax
movb 0x57(%rax), %cl
andb $-0x4, %cl
orb $0x2, %cl
movb %cl, 0x57(%rax)
movq $0x0, -0x10(%rbp)
jmp 0x50ca4
jmp 0x50ca6
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x47460
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)