// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: isLikeOrGlob
static int isLikeOrGlob(
  Parse *pParse,    /* Parsing and code generating context */
  Expr *pExpr,      /* Test this expression */
  Expr **ppPrefix,  /* Pointer to TK_STRING expression with pattern prefix */
  int *pisComplete, /* True if the only wildcard is % in the last character */
  int *pnoCase      /* True if uppercase is equivalent to lowercase */
){
  const char *z = 0;         /* String on RHS of LIKE operator */
  Expr *pRight, *pLeft;      /* Right and left size of LIKE operator */
  ExprList *pList;           /* List of operands to the LIKE operator */
  int c;                     /* One character in z[] */
  int cnt;                   /* Number of non-wildcard prefix characters */
  char wc[3];                /* Wildcard characters */
  sqlite3 *db = pParse->db;  /* Database connection */
  sqlite3_value *pVal = 0;
  int op;                    /* Opcode of pRight */

  if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){
    return 0;
  }
#ifdef SQLITE_EBCDIC
  if( *pnoCase ) return 0;
#endif
  pList = pExpr->x.pList;
  pLeft = pList->a[1].pExpr;
  if( pLeft->op!=TK_COLUMN 
   || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT 
   || IsVirtual(pLeft->pTab)
  ){
    /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
    ** be the name of an indexed column with TEXT affinity. */
    return 0;
  }
  assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */

  pRight = pList->a[0].pExpr;
  op = pRight->op;
  if( op==TK_REGISTER ){
    op = pRight->op2;
  }
  if( op==TK_VARIABLE ){
    Vdbe *pReprepare = pParse->pReprepare;
    int iCol = pRight->iColumn;
    pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE);
    if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
      z = (char *)sqlite3_value_text(pVal);
    }
    sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
    assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
  }else if( op==TK_STRING ){
    z = pRight->u.zToken;
  }
  if( z ){
    cnt = 0;
    while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
      cnt++;
    }
    if( cnt!=0 && 255!=(u8)z[cnt-1] ){
      Expr *pPrefix;
      *pisComplete = c==wc[0] && z[cnt+1]==0;
      pPrefix = sqlite3Expr(db, TK_STRING, z);
      if( pPrefix ) pPrefix->u.zToken[cnt] = 0;
      *ppPrefix = pPrefix;
      if( op==TK_VARIABLE ){
        Vdbe *v = pParse->pVdbe;
        sqlite3VdbeSetVarmask(v, pRight->iColumn);
        if( *pisComplete && pRight->u.zToken[1] ){
          /* If the rhs of the LIKE expression is a variable, and the current
          ** value of the variable means there is no need to invoke the LIKE
          ** function, then no OP_Variable will be added to the program.
          ** This causes problems for the sqlite3_bind_parameter_name()
          ** API. To workaround them, add a dummy OP_Variable here.
          */ 
          int r1 = sqlite3GetTempReg(pParse);
          sqlite3ExprCodeTarget(pParse, pRight, r1);
          sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v)-1, 0);
          sqlite3ReleaseTempReg(pParse, r1);
        }
      }
    }else{
      z = 0;
    }
  }

  sqlite3ValueFree(pVal);
  return (z!=0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x68(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0x5b(%rbp), %rcx
callq 0x77040
cmpl $0x0, %eax
jne 0x76c80
movl $0x0, -0x4(%rbp)
jmp 0x76f8a
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x98, %eax
jne 0x76ccf
movq -0x48(%rbp), %rdi
callq 0x658e0
movsbl %al, %eax
cmpl $0x61, %eax
jne 0x76ccf
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rax
movzbl 0x46(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x76cdb
movl $0x0, -0x4(%rbp)
jmp 0x76f8a
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x74(%rbp)
cmpl $0x84, -0x74(%rbp)
jne 0x76d08
movq -0x40(%rbp), %rax
movzbl 0x37(%rax), %eax
movl %eax, -0x74(%rbp)
cmpl $0x85, -0x74(%rbp)
jne 0x76d7d
movq -0x10(%rbp), %rax
movq 0x220(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rax
movswl 0x30(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x80(%rbp), %rdi
movl -0x84(%rbp), %esi
movl $0x62, %edx
callq 0x77130
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x76d68
movq -0x70(%rbp), %rdi
callq 0x10770
cmpl $0x3, %eax
jne 0x76d68
movq -0x70(%rbp), %rdi
callq 0x10350
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x84(%rbp), %esi
callq 0x771e0
jmp 0x76d91
cmpl $0x5e, -0x74(%rbp)
jne 0x76d8f
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x76d91
cmpq $0x0, -0x38(%rbp)
je 0x76f71
movl $0x0, -0x58(%rbp)
movq -0x38(%rbp), %rax
movslq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
movl %ecx, -0x54(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x9d(%rbp)
je 0x76df7
movl -0x54(%rbp), %ecx
movsbl -0x5b(%rbp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x9d(%rbp)
je 0x76df7
movl -0x54(%rbp), %ecx
movsbl -0x5a(%rbp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x9d(%rbp)
je 0x76df7
movl -0x54(%rbp), %eax
movsbl -0x59(%rbp), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x9d(%rbp)
movb -0x9d(%rbp), %al
testb $0x1, %al
jne 0x76e03
jmp 0x76e0e
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x76da3
cmpl $0x0, -0x58(%rbp)
je 0x76f67
movq -0x38(%rbp), %rax
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %ecx
movl $0xff, %eax
cmpl %ecx, %eax
je 0x76f67
movl -0x54(%rbp), %ecx
movsbl -0x5b(%rbp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x9e(%rbp)
jne 0x76e66
movq -0x38(%rbp), %rax
movl -0x58(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x9e(%rbp)
movb -0x9e(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rdx
movl $0x5e, %esi
callq 0x548b0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x76ead
movq -0x90(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x58(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x90(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x85, -0x74(%rbp)
jne 0x76f65
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
movq -0x40(%rbp), %rax
movswl 0x30(%rax), %esi
callq 0x771e0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x76f63
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0x76f63
movq -0x10(%rbp), %rdi
callq 0x66a70
movl %eax, -0x9c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x9c(%rbp), %edx
callq 0x687c0
movq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x98(%rbp), %rdi
callq 0x5e520
movq -0xa8(%rbp), %rdi
movl %eax, %esi
subl $0x1, %esi
xorl %edx, %edx
callq 0x13b80
movq -0x10(%rbp), %rdi
movl -0x9c(%rbp), %esi
callq 0x66ac0
jmp 0x76f65
jmp 0x76f6f
movq $0x0, -0x38(%rbp)
jmp 0x76f71
movq -0x70(%rbp), %rdi
callq 0x17020
cmpq $0x0, -0x38(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)