// File: /workspace/github_c_makefile_star2_O1/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, %r11
movq 0x240(%rdi), %r15
testq %r15, %r15
je 0x3bb2a
cmpb $0x0, 0x212(%r11)
jne 0x3bb2a
movb 0x48(%r15), %al
testb $0x4, %al
jne 0x3ba4e
movl %r8d, %r10d
movl %edx, %r9d
orb $0x4, %al
movb %al, 0x48(%r15)
testq %r14, %r14
movb %al, 0x23(%rsp)
je 0x3ba6a
movslq (%r14), %rcx
movq %rcx, 0x38(%rsp)
testq %rcx, %rcx
jle 0x3ba8c
movl %r10d, 0x28(%rsp)
movl %r9d, 0x2c(%rsp)
movq %r11, 0x40(%rsp)
movswl 0x42(%r15), %r9d
xorl %r10d, %r10d
leaq 0x31a06(%rip), %r11     # 0x6d390
xorl %edi, %edi
movq %r14, 0x30(%rsp)
testw %r9w, %r9w
jle 0x3ba10
movq 0x8(%r14), %rdx
movq %r10, %rsi
shlq $0x5, %rsi
movq 0x8(%rdx,%rsi), %rbx
movq %r15, %rax
movq 0x8(%r15), %r12
movb (%rbx), %r14b
incq %rbx
xorl %esi, %esi
leaq (%rsi,%rsi,2), %rbp
shlq $0x4, %rbp
movq (%r12,%rbp), %r15
testb %r14b, %r14b
je 0x3b9ef
movq %rbx, %r13
movl %r14d, %edx
movzbl %dl, %r8d
movb (%r8,%r11), %r8b
movzbl (%r15), %ecx
cmpb (%rcx,%r11), %r8b
jne 0x3b9f2
incq %r15
movb (%r13), %dl
incq %r13
testb %dl, %dl
jne 0x3b9cd
jmp 0x3b9f2
movl %r14d, %edx
movzbl %dl, %ecx
movb (%rcx,%r11), %cl
movzbl (%r15), %edx
cmpb (%rdx,%r11), %cl
je 0x3ba14
incq %rsi
cmpq %r9, %rsi
jne 0x3b9b6
movl %r9d, %esi
jmp 0x3ba1f
xorl %esi, %esi
jmp 0x3ba27
orb $0x1, 0x2b(%r12,%rbp)
movq 0x18(%r12,%rbp), %rdi
movq 0x30(%rsp), %r14
movq %rax, %r15
incq %r10
cmpq 0x38(%rsp), %r10
jne 0x3b991
cmpl $0x1, 0x38(%rsp)
sete %dl
movq 0x40(%rsp), %r11
movl 0x2c(%rsp), %r9d
movl 0x28(%rsp), %r10d
jmp 0x3ba95
movq (%r15), %rdx
leaq 0x3693b(%rip), %rsi     # 0x72393
movq %r11, %rdi
xorl %eax, %eax
movq %r11, %rbx
callq 0x11c1f
jmp 0x3bb27
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
jmp 0x3ba95
xorl %edx, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edi, %edi
testb %dl, %dl
je 0x3bb0c
testq %rdi, %rdi
je 0x3bb0c
movl %r10d, %ebx
movl %r9d, %eax
movb (%rdi), %r8b
testb %r8b, %r8b
je 0x3badf
incq %rdi
leaq 0x36793(%rip), %rdx     # 0x72249
leaq 0x318d3(%rip), %r9      # 0x6d390
movzbl %r8b, %ecx
movb (%rcx,%r9), %cl
movzbl (%rdx), %r10d
cmpb (%r10,%r9), %cl
jne 0x3bae6
incq %rdx
movb (%rdi), %r8b
incq %rdi
testb %r8b, %r8b
jne 0x3babd
jmp 0x3bae6
leaq 0x36763(%rip), %rdx     # 0x72249
movzbl %r8b, %ecx
leaq 0x3189f(%rip), %rdi     # 0x6d390
movzbl (%rcx,%rdi), %ecx
movzbl (%rdx), %edx
movzbl (%rdx,%rdi), %edx
subl %edx, %ecx
movl %ebx, %r10d
orl %ebx, %ecx
movl %eax, %r9d
je 0x3bbe7
cmpl $0x0, 0x24(%rsp)
je 0x3bb43
leaq 0x368a2(%rip), %rsi     # 0x723bc
movq %r11, %rdi
xorl %eax, %eax
movq %r11, %rbx
callq 0x11c1f
movq %rbx, %r11
movq (%r11), %rdi
movq %r14, %rsi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x357c9
movq 0x10(%r11), %r12
testq %r12, %r12
je 0x3bb78
movq %r12, %rdi
movl $0x97, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r11, %rbx
movl %r9d, %ebp
movl %r10d, %r15d
callq 0x47fb1
movl %r15d, %r10d
movl %ebp, %r9d
movq %rbx, %r11
movl %eax, 0x1f4(%rbx)
movl %r10d, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movl $0x0, 0x18(%rsp)
movq %r11, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
movq %r11, %rbx
callq 0x3bc21
movq %rbx, %r11
movl $0x0, %r14d
testq %rax, %rax
je 0x3bb2a
movb 0x63(%rax), %cl
andb $-0x4, %cl
orb $0x2, %cl
movb %cl, 0x63(%rax)
testq %r12, %r12
je 0x3bc19
movslq 0x1f4(%r11), %rax
testq %rax, %rax
js 0x3bc19
movl 0x34(%r12), %ecx
cmpl %eax, %ecx
jbe 0x3bc19
movq 0x8(%r12), %rdx
leaq (%rax,%rax,2), %rax
movl %ecx, 0x8(%rdx,%rax,8)
jmp 0x3bc19
movl 0x24(%rsp), %eax
shlb $0x3, %al
movb 0x23(%rsp), %cl
orb %al, %cl
movw %si, 0x40(%r15)
movb %r9b, 0x49(%r15)
movb %cl, 0x48(%r15)
testq %r14, %r14
je 0x3bc19
movq 0x8(%r14), %rax
movb 0x18(%rax), %al
movb %al, 0x210(%r11)
jmp 0x3bb2a
xorl %r14d, %r14d
jmp 0x3bb2a