// File: /workspace/github_c_makefile_star2_O2/skeeto[P]flappy/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;
  int nTerm;
  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;
    zType = pTab->aCol[iCol].zType;
    nTerm = 1;
  }else{
    nTerm = pList->nExpr;
    for(i=0; i<nTerm; i++){
      for(iCol=0; iCol<pTab->nCol; iCol++){
        if( sqlite3StrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ){
          pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY;
          zType = pTab->aCol[iCol].zType;
          break;
        }
      }
    }
  }
  if( nTerm==1
   && 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;
    if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;
  }else if( autoInc ){
#ifndef SQLITE_OMIT_AUTOINCREMENT
    sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
       "INTEGER PRIMARY KEY");
#endif
  }else{
    Vdbe *v = pParse->pVdbe;
    Index *p;
    if( v ) pParse->addrSkipPK = sqlite3VdbeAddOp0(v, OP_Noop);
    p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
                           0, sortOrder, 0);
    if( p ){
      p->autoIndex = 2;
      if( v ) sqlite3VdbeJumpHere(v, pParse->addrSkipPK);
    }
    pList = 0;
  }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r8d, 0x38(%rsp)
movl %ecx, 0x3c(%rsp)
movl %edx, 0x34(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movq 0x240(%rdi), %rdx
testq %rdx, %rdx
je 0x3805e
cmpb $0x0, 0x212(%rbx)
jne 0x3805e
movb 0x48(%rdx), %bpl
testb $0x4, %bpl
jne 0x37efc
movq %rbx, 0x40(%rsp)
orb $0x4, %bpl
movb %bpl, 0x48(%rdx)
testq %r14, %r14
je 0x37f1f
movl (%r14), %eax
testl %eax, %eax
movl $0x0, %ecx
movl %eax, 0x54(%rsp)
cmovgl %eax, %ecx
movq %rcx, 0x58(%rsp)
pushq $-0x1
popq %rax
movq %rax, 0x28(%rsp)
xorl %r13d, %r13d
movq $0x0, 0x48(%rsp)
movb %bpl, 0x27(%rsp)
cmpq 0x58(%rsp), %r13
je 0x37f15
movzwl 0x42(%rdx), %eax
testw %ax, %ax
movl $0x0, %ecx
cmovlel %ecx, %eax
movzwl %ax, %eax
movq %rax, 0x28(%rsp)
movq %r13, 0x60(%rsp)
shlq $0x5, %r13
pushq $0x2b
popq %r12
xorl %r15d, %r15d
cmpq %r15, 0x28(%rsp)
je 0x37eea
movq %r14, %rbp
movq 0x8(%r14), %rax
movq 0x8(%rax,%r13), %rdi
movq %rdx, %rbx
movq 0x8(%rdx), %r14
movq -0x2b(%r14,%r12), %rsi
callq 0xb6e4
testl %eax, %eax
je 0x37ed0
incq %r15
addq $0x30, %r12
movq %rbp, %r14
movq %rbx, %rdx
jmp 0x37e99
orb $0x1, (%r14,%r12)
movq -0x13(%r14,%r12), %rax
movq %rax, 0x48(%rsp)
movq %r15, 0x28(%rsp)
movq %rbp, %r14
movq %rbx, %rdx
movq 0x60(%rsp), %r13
incq %r13
movb 0x27(%rsp), %bpl
jmp 0x37e67
movq (%rdx), %rdx
leaq 0x2d4ad(%rip), %rsi     # 0x653b3
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10b53
jmp 0x3805e
cmpl $0x1, 0x54(%rsp)
sete %al
jmp 0x37f45
movswq 0x42(%rdx), %rsi
decq %rsi
movq 0x8(%rdx), %rax
movq %rsi, 0x28(%rsp)
imulq $0x30, %rsi, %rcx
orb $0x1, 0x2b(%rax,%rcx)
movq 0x18(%rax,%rcx), %rax
movq %rax, 0x48(%rsp)
movb $0x1, %al
testb %al, %al
je 0x37f6f
cmpq $0x0, 0x48(%rsp)
je 0x37f6f
leaq 0x2d311(%rip), %rsi     # 0x65269
movq 0x48(%rsp), %rdi
movq %rdx, %rbx
callq 0xb6e4
orl 0x38(%rsp), %eax
je 0x3801f
cmpl $0x0, 0x3c(%rsp)
je 0x37f91
leaq 0x2d45f(%rip), %rsi     # 0x653dc
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10b53
jmp 0x3805e
movq 0x40(%rsp), %rbx
movq 0x10(%rbx), %r12
testq %r12, %r12
je 0x37fb2
movq %r12, %rdi
movl $0x97, %esi
callq 0x43f5b
movl %eax, 0x1f4(%rbx)
movl 0x38(%rsp), %eax
movl %eax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
andl $0x0, 0x18(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
movl 0x34(%rsp), %r9d
callq 0x38077
movl $0x0, %r14d
testq %rax, %rax
je 0x3805e
movb 0x63(%rax), %cl
andb $-0x4, %cl
orb $0x2, %cl
movb %cl, 0x63(%rax)
testq %r12, %r12
je 0x3801a
movslq 0x1f4(%rbx), %rax
testq %rax, %rax
js 0x3801a
movl 0x34(%r12), %ecx
cmpl %eax, %ecx
jbe 0x3801a
movq 0x8(%r12), %rdx
imulq $0x18, %rax, %rax
movl %ecx, 0x8(%rdx,%rax)
xorl %r14d, %r14d
jmp 0x3805e
movl 0x3c(%rsp), %eax
shlb $0x3, %al
orb %al, %bpl
movq 0x28(%rsp), %rax
movw %ax, 0x40(%rbx)
movl 0x34(%rsp), %eax
movb %al, 0x49(%rbx)
movb %bpl, 0x48(%rbx)
testq %r14, %r14
je 0x38056
movq 0x8(%r14), %rax
movb 0x18(%rax), %al
movq 0x40(%rsp), %rbx
movb %al, 0x210(%rbx)
jmp 0x3805e
xorl %r14d, %r14d
movq 0x40(%rsp), %rbx
movq (%rbx), %rdi
movq %r14, %rsi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x304f4