// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movl %ecx, 0x24(%rsp)
movq %rsi, %r14
movq %rdi, %r9
movq 0x240(%rdi), %r15
testq %r15, %r15
je 0x3bf33
cmpb $0x0, 0x212(%r9)
jne 0x3bf33
movb 0x48(%r15), %al
testb $0x4, %al
jne 0x3be50
movl %r8d, %r10d
movl %edx, %r11d
orb $0x4, %al
movb %al, 0x23(%rsp)
movb %al, 0x48(%r15)
testq %r14, %r14
je 0x3be6c
movslq (%r14), %rcx
movq %rcx, 0x38(%rsp)
testq %rcx, %rcx
jle 0x3bf15
movl %r10d, 0x28(%rsp)
movl %r11d, 0x2c(%rsp)
movq %r9, 0x40(%rsp)
movswl 0x42(%r15), %r9d
xorl %r10d, %r10d
leaq 0x3263b(%rip), %r11     # 0x6e3d0
xorl %edi, %edi
movq %r14, 0x30(%rsp)
testw %r9w, %r9w
jle 0x3be12
movq 0x8(%r14), %rdx
movq %r10, %rsi
shlq $0x5, %rsi
movq 0x8(%rdx,%rsi), %r14
movq %r15, %rax
movq 0x8(%r15), %r12
movb (%r14), %dl
incq %r14
xorl %esi, %esi
leaq (%rsi,%rsi,2), %rbp
shlq $0x4, %rbp
movq (%r12,%rbp), %r15
testb %dl, %dl
je 0x3bdf5
movq %r14, %r13
movl %edx, %ebx
movzbl %bl, %ebx
movb (%rbx,%r11), %r8b
movzbl (%r15), %ecx
cmpb (%rcx,%r11), %r8b
jne 0x3bdf7
incq %r15
movb (%r13), %bl
incq %r13
testb %bl, %bl
jne 0x3bdd6
xorl %ebx, %ebx
movb (%rbx,%r11), %cl
movzbl (%r15), %r8d
cmpb (%r8,%r11), %cl
je 0x3be16
incq %rsi
cmpq %r9, %rsi
jne 0x3bdc1
movl %r9d, %esi
jmp 0x3be21
xorl %esi, %esi
jmp 0x3be29
orb $0x1, 0x2b(%r12,%rbp)
movq 0x18(%r12,%rbp), %rdi
movq 0x30(%rsp), %r14
movq %rax, %r15
incq %r10
cmpq 0x38(%rsp), %r10
jne 0x3bd9c
cmpl $0x1, 0x38(%rsp)
sete %dl
movq 0x40(%rsp), %r9
movl 0x2c(%rsp), %r11d
movl 0x28(%rsp), %r10d
jmp 0x3be8c
movq (%r15), %rdx
leaq 0x375d9(%rip), %rsi     # 0x73433
movq %r9, %rdi
xorl %eax, %eax
movq %r9, %rbx
callq 0x11db0
jmp 0x3bf30
movswq 0x42(%r15), %rsi
decq %rsi
movq 0x8(%r15), %rdx
leaq (%rsi,%rsi,2), %rdi
shlq $0x4, %rdi
orb $0x1, 0x2b(%rdx,%rdi)
movq 0x18(%rdx,%rdi), %rdi
movb $0x1, %dl
testb %dl, %dl
je 0x3bf15
testq %rdi, %rdi
je 0x3bf15
movl %r10d, %ebp
movb (%rdi), %r10b
testb %r10b, %r10b
je 0x3bee0
movl %r11d, %eax
movq %r9, %rbx
incq %rdi
leaq 0x37435(%rip), %rdx     # 0x732e9
leaq 0x32515(%rip), %r9      # 0x6e3d0
xorl %r8d, %r8d
movzbl %r10b, %r10d
movb (%r10,%r9), %cl
movzbl (%rdx), %r11d
cmpb (%r11,%r9), %cl
jne 0x3beec
incq %rdx
movb (%rdi), %r10b
incq %rdi
testb %r10b, %r10b
jne 0x3bebe
jmp 0x3beef
leaq 0x37402(%rip), %rdx     # 0x732e9
xorl %r8d, %r8d
jmp 0x3bef5
movq %r10, %r8
movq %rbx, %r9
movl %eax, %r11d
leaq 0x324d4(%rip), %rcx     # 0x6e3d0
movzbl (%r8,%rcx), %edi
movzbl (%rdx), %edx
movzbl (%rdx,%rcx), %ecx
subl %ecx, %edi
movl %ebp, %r10d
orl %ebp, %edi
je 0x3bff3
cmpl $0x0, 0x24(%rsp)
je 0x3bf4c
leaq 0x37539(%rip), %rsi     # 0x7345c
movq %r9, %rdi
xorl %eax, %eax
movq %r9, %rbx
callq 0x11db0
movq %rbx, %r9
movq (%r9), %rdi
movq %r14, %rsi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x35c6f
movq 0x10(%r9), %r12
testq %r12, %r12
je 0x3bf81
movq %r12, %rdi
movl $0x97, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r9, %rbx
movl %r11d, %ebp
movl %r10d, %r15d
callq 0x487d8
movl %r15d, %r10d
movl %ebp, %r11d
movq %rbx, %r9
movl %eax, 0x1f4(%rbx)
movl %r10d, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movl $0x0, 0x18(%rsp)
movq %r9, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
movq %r9, %rbx
movl %r11d, %r9d
callq 0x3c02d
movq %rbx, %r9
movl $0x0, %r14d
testq %rax, %rax
je 0x3bf33
movb 0x63(%rax), %cl
andb $-0x4, %cl
orb $0x2, %cl
movb %cl, 0x63(%rax)
testq %r12, %r12
je 0x3c025
movslq 0x1f4(%r9), %rax
testq %rax, %rax
js 0x3c025
movl 0x34(%r12), %ecx
cmpl %eax, %ecx
jbe 0x3c025
movq 0x8(%r12), %rdx
leaq (%rax,%rax,2), %rax
movl %ecx, 0x8(%rdx,%rax,8)
jmp 0x3c025
movl 0x24(%rsp), %eax
shlb $0x3, %al
movb 0x23(%rsp), %cl
orb %al, %cl
movw %si, 0x40(%r15)
movb %r11b, 0x49(%r15)
movb %cl, 0x48(%r15)
testq %r14, %r14
je 0x3c025
movq 0x8(%r14), %rax
movb 0x18(%rax), %al
movb %al, 0x210(%r9)
jmp 0x3bf33
xorl %r14d, %r14d
jmp 0x3bf33