// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdx, %r13
movl %esi, -0x2c(%rbp)
movq %rdi, %r15
leaq 0x8(%rdi), %r12
movq 0x8(%rdi), %r14
movq (%rdx), %rdi
movl $0x1, %esi
callq 0xee49
movq %rax, -0x40(%rbp)
movq 0x8(%r13), %rdi
movl $0x1, %esi
callq 0xee49
movq %rax, %rbx
movq (%r13), %rdi
movl $0x1, %esi
callq 0xed28
cmpl 0x88(%r14), %eax
jle 0x61122
movl $0x1, 0x5c(%r15)
movb $0x1, 0x61(%r15)
leaq 0x1b3a5(%rip), %rsi     # 0x7c4a0
movq %r12, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
movq $-0x1, %r8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xeff4
movq %r12, -0x38(%rbp)
xorl %ecx, %ecx
cmpl $0x3, -0x2c(%rbp)
movq -0x40(%rbp), %r14
jne 0x611c9
movq 0x10(%r13), %rdi
movl $0x1, %esi
callq 0xee49
movq %rax, -0x48(%rbp)
testq %rax, %rax
je 0x611c1
movb (%rax), %dl
testb %dl, %dl
sete %cl
cmpq $-0x1, %rax
sete %sil
orb %cl, %sil
movq -0x38(%rbp), %rdi
jne 0x61197
xorl %esi, %esi
movl %esi, %ecx
cmpb $-0x40, %dl
jb 0x6117d
movb 0x1(%rax), %dl
incq %rax
andb $-0x40, %dl
negb %dl
jo 0x6116e
jmp 0x61180
incq %rax
cmpq $-0x1, %rax
je 0x6118f
leal 0x1(%rcx), %esi
movb (%rax), %dl
testb %dl, %dl
jne 0x61167
testl %ecx, %ecx
je 0x61219
movl $0x1, 0x5c(%r15)
movb $0x1, 0x61(%r15)
leaq 0x1b316(%rip), %rsi     # 0x7c4c1
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
movq $-0x1, %r8
callq 0xeff4
xorl %eax, %eax
xorl %ecx, %ecx
testb %al, %al
je 0x6120a
testq %rbx, %rbx
setne %al
testq %r14, %r14
setne %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x6120a
movq (%r15), %rax
movq 0x8(%rax), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x123f0
movslq %eax, %r14
movq -0x38(%rbp), %rdi
callq 0xec23
movq %r14, 0x20(%r15)
movw $0x4, 0x2c(%r15)
movb $0x1, 0x2e(%r15)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x368be
movl %eax, %ecx
movb $0x1, %al
jmp 0x611c5