// File: /workspace/github_c_makefile_star2_O1/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 %r15d, %r15d
movl $0x0, -0x2c(%rbp)
movq -0x70(%rbp,%r15,8), %r12
testq %r12, %r12
je 0x3d8e1
movl 0x8(%r12), %ebx
leaq 0x3b04d(%rip), %r14     # 0x788d2
xorl %r13d, %r13d
movzbl -0x1(%r14), %eax
cmpl %eax, %ebx
jne 0x3d8af
movq (%r12), %rdi
movzbl -0x2(%r14), %esi
leaq 0x3afff(%rip), %rax     # 0x788a0
addq %rax, %rsi
movl %ebx, %edx
callq 0x9454
testl %eax, %eax
je 0x3d8c0
incq %r13
addq $0x3, %r14
cmpq $0x7, %r13
jne 0x3d888
movb $0x1, %al
jmp 0x3d8ce
movzbl (%r14), %eax
orl %eax, -0x2c(%rbp)
cmpq $0x7, %r13
setae %al
testb %al, %al
jne 0x3d8dd
incq %r15
cmpq $0x3, %r15
jne 0x3d86f
jmp 0x3d8e1
orl $0x40, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, %ecx
notl %ecx
testb $0x21, %cl
setne %dl
testb $0x40, %al
sete %cl
testb %cl, %dl
je 0x3d91f
testb $0x20, %al
sete %dl
movl %eax, %ecx
andl $0x18, %ecx
cmpl $0x8, %ecx
sete %cl
orb %dl, %cl
jne 0x3d957
leaq 0x3e3e3(%rip), %rsi     # 0x7bcf5
movq -0x38(%rbp), %rdi
xorl %eax, %eax
callq 0x11724
jmp 0x3d952
movq -0x50(%rbp), %r9
testq %r9, %r9
leaq 0x3da26(%rip), %rax     # 0x7b353
leaq 0x3da1e(%rip), %r8      # 0x7b352
cmoveq %rax, %r8
leaq 0x3e38a(%rip), %rsi     # 0x7bcc9
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
xorl %eax, %eax
callq 0x11724
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq