// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3JoinType
SQLITE_PRIVATE int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
  int jointype = 0;
  Token *apAll[3];
  Token *p;
                             /*   0123456789 123456789 123456789 123 */
  static const char zKeyText[] = "naturaleftouterightfullinnercross";
  static const struct {
    u8 i;        /* Beginning of keyword text in zKeyText[] */
    u8 nChar;    /* Length of the keyword in characters */
    u8 code;     /* Join type mask */
  } aKeyword[] = {
    /* natural */ { 0,  7, JT_NATURAL                },
    /* left    */ { 6,  4, JT_LEFT|JT_OUTER          },
    /* outer   */ { 10, 5, JT_OUTER                  },
    /* right   */ { 14, 5, JT_RIGHT|JT_OUTER         },
    /* full    */ { 19, 4, JT_LEFT|JT_RIGHT|JT_OUTER },
    /* inner   */ { 23, 5, JT_INNER                  },
    /* cross   */ { 28, 5, JT_INNER|JT_CROSS         },
  };
  int i, j;
  apAll[0] = pA;
  apAll[1] = pB;
  apAll[2] = pC;
  for(i=0; i<3 && apAll[i]; i++){
    p = apAll[i];
    for(j=0; j<ArraySize(aKeyword); j++){
      if( p->n==aKeyword[j].nChar 
          && sqlite3StrNICmp((char*)p->z, &zKeyText[aKeyword[j].i], p->n)==0 ){
        jointype |= aKeyword[j].code;
        break;
      }
    }
    testcase( j==0 || j==1 || j==2 || j==3 || j==4 || j==5 || j==6 );
    if( j>=ArraySize(aKeyword) ){
      jointype |= JT_ERROR;
      break;
    }
  }
  if(
     (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||
     (jointype & JT_ERROR)!=0
  ){
    const char *zSp = " ";
    assert( pB!=0 );
    if( pC==0 ){ zSp++; }
    sqlite3ErrorMsg(pParse, "unknown or unsupported join type: "
       "%T %T%s%T", pA, pB, zSp, pC);
    jointype = JT_INNER;
  }else if( (jointype & JT_OUTER)!=0 
         && (jointype & (JT_LEFT|JT_RIGHT))!=JT_LEFT ){
    sqlite3ErrorMsg(pParse, 
      "RIGHT and FULL OUTER JOINs are not currently supported");
    jointype = JT_INNER;
  }
  return jointype;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, -0x30(%rbp)
movq %rsi, -0x40(%rbp)
movq %rsi, -0x70(%rbp)
movq %rdx, -0x48(%rbp)
movq %rdx, -0x68(%rbp)
movq %rcx, -0x50(%rbp)
movq %rcx, -0x60(%rbp)
xorl %esi, %esi
leaq 0x3f6dc(%rip), %r10     # 0x7d490
leaq 0x382f5(%rip), %r11     # 0x760b0
xorl %eax, %eax
movq -0x70(%rbp,%rsi,8), %rbx
testq %rbx, %rbx
je 0x3de79
movl 0x8(%rbx), %r14d
leal 0x1(%r14), %ecx
movl %ecx, -0x34(%rbp)
xorl %r12d, %r12d
leaq (%r12,%r12,2), %r13
leaq 0x3ab0c(%rip), %rcx     # 0x788f0
movzbl 0x1(%rcx,%r13), %ecx
cmpl %ecx, %r14d
jne 0x3de51
leaq 0x3aafa(%rip), %rcx     # 0x788f0
addq %rcx, %r13
testl %r14d, %r14d
je 0x3de60
movzbl (%r13), %ecx
movq (%rbx), %r9
xorl %edx, %edx
movl -0x34(%rbp), %r15d
movzbl (%r9,%rdx), %edi
testq %rdi, %rdi
je 0x3de3b
movzbl (%rdi,%r11), %edi
leaq (%rcx,%rdx), %r8
movzbl (%r10,%r8), %r8d
movb (%r8,%r11), %r8b
cmpb %r8b, %dil
jne 0x3de49
decl %r15d
incq %rdx
cmpl $0x1, %r15d
ja 0x3de0c
jmp 0x3de60
addq %rdx, %rcx
movzbl (%r10,%rcx), %ecx
movb (%rcx,%r11), %r8b
xorl %edi, %edi
movzbl %r8b, %ecx
cmpl %ecx, %edi
je 0x3de60
incq %r12
cmpq $0x7, %r12
jne 0x3ddd9
jmp 0x3de76
movzbl 0x2(%r13), %ecx
orl %ecx, %eax
incq %rsi
cmpq $0x3, %rsi
jne 0x3ddbd
jmp 0x3de79
orl $0x40, %eax
movl %eax, %ecx
notl %ecx
testb $0x21, %cl
setne %cl
testb $0x40, %al
sete %dl
testb %dl, %cl
je 0x3deb4
testb $0x20, %al
sete %cl
movl %eax, %edx
andl $0x18, %edx
cmpl $0x8, %edx
sete %dl
orb %cl, %dl
jne 0x3defb
leaq 0x3de4e(%rip), %rsi     # 0x7bcf5
movq -0x30(%rbp), %rdi
xorl %eax, %eax
callq 0x11842
jmp 0x3def6
movq -0x50(%rbp), %r9
leaq 0x3de0a(%rip), %rsi     # 0x7bcc9
testq %r9, %r9
je 0x3ded9
leaq 0x3d487(%rip), %r8      # 0x7b352
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
jmp 0x3deef
leaq 0x3d473(%rip), %r8      # 0x7b353
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x11842
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq