// File: /workspace/github_c_makefile_star2_O2/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, -0x38(%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 %ecx, %ecx
pushq $0x2
popq %r13
leaq 0x2f0bb(%rip), %r12     # 0x6a8e0
leaq 0x2f084(%rip), %r14     # 0x6a8b0
xorl %eax, %eax
cmpq $0x3, %rcx
je 0x3b894
movq -0x70(%rbp,%rcx,8), %r15
testq %r15, %r15
je 0x3b894
movq %rcx, -0x58(%rbp)
movl %eax, -0x2c(%rbp)
movl 0x8(%r15), %ebx
cmpq $0x17, %r13
je 0x3b88e
movzbl -0x1(%r13,%r12), %eax
cmpl %eax, %ebx
jne 0x3b870
movq (%r15), %rdi
movzbl -0x2(%r13,%r12), %esi
addq %r14, %rsi
movl %ebx, %edx
callq 0x8f45
testl %eax, %eax
je 0x3b876
addq $0x3, %r13
jmp 0x3b849
movzbl (%r13,%r12), %ecx
movl -0x2c(%rbp), %eax
orl %ecx, %eax
movq -0x58(%rbp), %rcx
incq %rcx
pushq $0x2
popq %r13
jmp 0x3b82e
movl -0x2c(%rbp), %eax
orl $0x40, %eax
movl %eax, %ecx
notl %ecx
testb $0x21, %cl
setne %dl
testb $0x40, %al
sete %cl
testb %cl, %dl
je 0x3b8cf
testb $0x20, %al
sete %dl
movl %eax, %ecx
andl $0x18, %ecx
cmpl $0x8, %ecx
sete %cl
orb %dl, %cl
jne 0x3b905
leaq 0x32453(%rip), %rsi     # 0x6dd15
movq -0x38(%rbp), %rdi
xorl %eax, %eax
callq 0x104d6
jmp 0x3b902
movq -0x50(%rbp), %r9
testq %r9, %r9
leaq 0x31a96(%rip), %rax     # 0x6d373
leaq 0x31a8e(%rip), %r8      # 0x6d372
cmoveq %rax, %r8
leaq 0x323fa(%rip), %rsi     # 0x6dce9
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
xorl %eax, %eax
callq 0x104d6
pushq $0x1
popq %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq