// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: likeFunc
static void likeFunc(
  sqlite3_context *context, 
  int argc, 
  sqlite3_value **argv
){
  const unsigned char *zA, *zB;
  u32 escape = 0;
  int nPat;
  sqlite3 *db = sqlite3_context_db_handle(context);

  zB = sqlite3_value_text(argv[0]);
  zA = sqlite3_value_text(argv[1]);

  /* Limit the length of the LIKE or GLOB pattern to avoid problems
  ** of deep recursion and N*N behavior in patternCompare().
  */
  nPat = sqlite3_value_bytes(argv[0]);
  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] );
  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]+1 );
  if( nPat > db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){
    sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1);
    return;
  }
  assert( zB==sqlite3_value_text(argv[0]) );  /* Encoding did not change */

  if( argc==3 ){
    /* The escape character string must consist of a single UTF-8 character.
    ** Otherwise, return an error.
    */
    const unsigned char *zEsc = sqlite3_value_text(argv[2]);
    if( zEsc==0 ) return;
    if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){
      sqlite3_result_error(context, 
          "ESCAPE expression must be a single character", -1);
      return;
    }
    escape = sqlite3Utf8Read(&zEsc);
  }
  if( zA && zB ){
    struct compareInfo *pInfo = sqlite3_user_data(context);
#ifdef SQLITE_TEST
    sqlite3_like_count++;
#endif
    
    sqlite3_result_int(context, patternCompare(zB, zA, pInfo, escape));
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r13
movl %esi, %r15d
movq %rdi, %r14
leaq 0x8(%rdi), %rbx
movq 0x8(%rdi), %r12
movq (%rdx), %rdi
movl $0x1, %esi
callq 0xef29
movq %rax, -0x38(%rbp)
movq 0x8(%r13), %rdi
movl $0x1, %esi
callq 0xef29
movq %rax, -0x30(%rbp)
movq (%r13), %rdi
movl $0x1, %esi
callq 0xee02
cmpl 0x88(%r12), %eax
jle 0x6103c
movl $0x1, 0x5c(%r14)
movb $0x1, 0x61(%r14)
leaq 0x1b48b(%rip), %rsi     # 0x7c4a0
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
movq $-0x1, %r8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf0d7
xorl %ecx, %ecx
cmpl $0x3, %r15d
jne 0x610e3
movq 0x10(%r13), %rdi
movl $0x1, %esi
callq 0xef29
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0x61125
movb (%rax), %cl
testb %cl, %cl
sete %dl
cmpq $-0x1, %rax
sete %sil
orb %dl, %sil
movq %rbx, %rdi
jne 0x610ac
xorl %esi, %esi
movl %esi, %edx
cmpb $-0x40, %cl
jb 0x61096
movb 0x1(%rax), %cl
incq %rax
movl %ecx, %esi
andb $-0x40, %sil
negb %sil
jo 0x61083
jmp 0x6109b
incq %rax
movb (%rax), %cl
testb %cl, %cl
je 0x610a8
leal 0x1(%rdx), %esi
cmpq $-0x1, %rax
jne 0x6107c
testl %edx, %edx
je 0x610d8
movl $0x1, 0x5c(%r14)
movb $0x1, 0x61(%r14)
leaq 0x1b401(%rip), %rsi     # 0x7c4c1
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
movq $-0x1, %r8
callq 0xf0d7
jmp 0x61125
leaq -0x40(%rbp), %rdi
callq 0x36fc5
movl %eax, %ecx
movq -0x30(%rbp), %rsi
testq %rsi, %rsi
setne %al
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
setne %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x61125
movq (%r14), %rax
movq 0x8(%rax), %rdx
callq 0x124ee
movslq %eax, %r15
movq %rbx, %rdi
callq 0xecfd
movq %r15, 0x20(%r14)
movw $0x4, 0x2c(%r14)
movb $0x1, 0x2e(%r14)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq