// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: patternCompare
static int patternCompare(
  const u8 *zPattern,              /* The glob pattern */
  const u8 *zString,               /* The string to compare against the glob */
  const int esc,                    /* The escape character */
  int noCase
){
  int c, c2;
  int invert;
  int seen;
  u8 matchOne = '?';
  u8 matchAll = '*';
  u8 matchSet = '[';
  int prevEscape = 0;     /* True if the previous character was 'escape' */

  if( !zPattern || !zString ) return 0;
  while( (c = jx9Utf8Read(zPattern, 0, &zPattern))!=0 ){
    if( !prevEscape && c==matchAll ){
      while( (c= jx9Utf8Read(zPattern, 0, &zPattern)) == matchAll
               || c == matchOne ){
        if( c==matchOne && jx9Utf8Read(zString, 0, &zString)==0 ){
          return 0;
        }
      }
      if( c==0 ){
        return 1;
      }else if( c==esc ){
        c = jx9Utf8Read(zPattern, 0, &zPattern);
        if( c==0 ){
          return 0;
        }
      }else if( c==matchSet ){
	  if( (esc==0) || (matchSet<0x80) ) return 0;
	  while( *zString && patternCompare(&zPattern[-1], zString, esc, noCase)==0 ){
          SQLITE_SKIP_UTF8(zString);
        }
        return *zString!=0;
      }
      while( (c2 = jx9Utf8Read(zString, 0, &zString))!=0 ){
        if( noCase ){
          GlogUpperToLower(c2);
          GlogUpperToLower(c);
          while( c2 != 0 && c2 != c ){
            c2 = jx9Utf8Read(zString, 0, &zString);
            GlogUpperToLower(c2);
          }
        }else{
          while( c2 != 0 && c2 != c ){
            c2 = jx9Utf8Read(zString, 0, &zString);
          }
        }
        if( c2==0 ) return 0;
		if( patternCompare(zPattern, zString, esc, noCase) ) return 1;
      }
      return 0;
    }else if( !prevEscape && c==matchOne ){
      if( jx9Utf8Read(zString, 0, &zString)==0 ){
        return 0;
      }
    }else if( c==matchSet ){
      int prior_c = 0;
      if( esc == 0 ) return 0;
      seen = 0;
      invert = 0;
      c = jx9Utf8Read(zString, 0, &zString);
      if( c==0 ) return 0;
      c2 = jx9Utf8Read(zPattern, 0, &zPattern);
      if( c2=='^' ){
        invert = 1;
        c2 = jx9Utf8Read(zPattern, 0, &zPattern);
      }
      if( c2==']' ){
        if( c==']' ) seen = 1;
        c2 = jx9Utf8Read(zPattern, 0, &zPattern);
      }
      while( c2 && c2!=']' ){
        if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){
          c2 = jx9Utf8Read(zPattern, 0, &zPattern);
          if( c>=prior_c && c<=c2 ) seen = 1;
          prior_c = 0;
        }else{
          if( c==c2 ){
            seen = 1;
          }
          prior_c = c2;
        }
        c2 = jx9Utf8Read(zPattern, 0, &zPattern);
      }
      if( c2==0 || (seen ^ invert)==0 ){
        return 0;
      }
    }else if( esc==c && !prevEscape ){
      prevEscape = 1;
    }else{
      c2 = jx9Utf8Read(zString, 0, &zString);
      if( noCase ){
        GlogUpperToLower(c);
        GlogUpperToLower(c2);
      }
      if( c!=c2 ){
        return 0;
      }
      prevEscape = 0;
    }
  }
  return *zString==0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, -0x40(%rbp)
movl %edx, -0x3c(%rbp)
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x55d04
xorl %r14d, %r14d
leaq -0x30(%rbp), %r12
leaq -0x38(%rbp), %r13
xorl %esi, %esi
movq %r12, %rdx
callq 0x46e25
testl %eax, %eax
je 0x55c86
movl %eax, %ebx
xorl $0x2a, %eax
orl %r14d, %eax
je 0x55c96
movl %ebx, %eax
xorl $0x3f, %eax
orl %r14d, %eax
je 0x55b6f
cmpl $0x5b, %ebx
jne 0x55b93
cmpl $0x0, -0x3c(%rbp)
je 0x55d04
movq -0x38(%rbp), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
movq %r13, %rdx
callq 0x46e25
testl %eax, %eax
je 0x55d07
movl %eax, %ebx
movq -0x30(%rbp), %rdi
xorl %r13d, %r13d
xorl %esi, %esi
movq %r12, %rdx
callq 0x46e25
movl %eax, %r15d
movl $0x0, -0x48(%rbp)
cmpl $0x5e, %eax
jne 0x55b4d
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x46e25
movl %eax, %r15d
pushq $0x1
popq %rax
movl %eax, -0x48(%rbp)
movl $0x0, %r12d
cmpl $0x5d, %r15d
jne 0x55c07
xorl %r13d, %r13d
cmpl $0x5d, %ebx
sete %r13b
xorl %r15d, %r15d
jmp 0x55bf2
movq -0x38(%rbp), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
movq %r13, %rdx
callq 0x46e25
movl $0x0, %r15d
testl %eax, %eax
jne 0x55c2f
jmp 0x55d07
movl %ebx, %eax
xorl -0x3c(%rbp), %eax
orl %eax, %r14d
pushq $0x1
popq %rax
movl %eax, %r14d
je 0x55c2f
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x46e25
cmpl $0x0, -0x40(%rbp)
je 0x55be0
cmpl $0x7f, %ebx
jg 0x55bce
movslq %ebx, %rcx
leaq 0xd5e6(%rip), %rdx      # 0x631b0
movzbl (%rcx,%rdx), %ebx
cmpl $0x7f, %eax
jg 0x55be0
cltq
leaq 0xd5d4(%rip), %rcx      # 0x631b0
movzbl (%rax,%rcx), %eax
xorl %r14d, %r14d
movl $0x0, %r15d
cmpl %eax, %ebx
je 0x55c2f
jmp 0x55d07
movl %r15d, %r12d
movq -0x30(%rbp), %rdi
xorl %esi, %esi
leaq -0x30(%rbp), %rdx
callq 0x46e25
movl %eax, %r15d
cmpl $0x2d, %r15d
je 0x55c38
cmpl $0x5d, %r15d
je 0x55c1d
testl %r15d, %r15d
jne 0x55c77
jmp 0x55d07
cmpl -0x48(%rbp), %r13d
leaq -0x30(%rbp), %r12
leaq -0x38(%rbp), %r13
je 0x55d04
movq -0x30(%rbp), %rdi
jmp 0x55aba
movq -0x30(%rbp), %rdi
movb (%rdi), %al
cmpb $0x5d, %al
je 0x55c77
testb %al, %al
sete %al
testl %r12d, %r12d
setle %cl
orb %al, %cl
jne 0x55c77
xorl %r15d, %r15d
xorl %esi, %esi
leaq -0x30(%rbp), %rdx
callq 0x46e25
cmpl %eax, %ebx
pushq $0x1
popq %rax
cmovgl %r13d, %eax
cmpl %r12d, %ebx
cmovll %r13d, %eax
movl %eax, %r13d
jmp 0x55bf2
cmpl %r15d, %ebx
pushq $0x1
popq %rax
cmovel %eax, %r13d
jmp 0x55bf2
movq -0x38(%rbp), %rax
xorl %r15d, %r15d
cmpb $0x0, (%rax)
sete %r15b
jmp 0x55d07
leaq -0x30(%rbp), %rbx
pushq $0x1
popq %r14
leaq -0x38(%rbp), %r13
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x46e25
cmpl $0x2a, %eax
je 0x55ca2
movl %eax, %r12d
cmpl $0x3f, %eax
jne 0x55cd4
movq -0x38(%rbp), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
movq %r13, %rdx
callq 0x46e25
testl %eax, %eax
jne 0x55ca2
jmp 0x55d07
testl %r12d, %r12d
jne 0x55cde
movl %r14d, %r15d
jmp 0x55d07
cmpl -0x3c(%rbp), %r12d
jne 0x55cfe
leaq -0x30(%rbp), %rdx
movq (%rdx), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x46e25
testl %eax, %eax
je 0x55d07
movl %eax, %r12d
jmp 0x55d19
cmpl $0x5b, %r12d
jne 0x55d19
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x38(%rbp), %r13
movq (%r13), %rbx
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x46e25
testl %eax, %eax
je 0x55d07
cmpl $0x0, -0x40(%rbp)
je 0x55d95
cmpl $0x7f, %eax
leaq 0xd463(%rip), %rbx      # 0x631b0
jg 0x55d55
cltq
movzbl (%rax,%rbx), %eax
cmpl $0x7f, %r12d
jg 0x55d63
movslq %r12d, %rcx
movzbl (%rcx,%rbx), %r12d
testl %eax, %eax
je 0x55d9e
cmpl %r12d, %eax
je 0x55d9e
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x46e25
cmpl $0x7f, %eax
jg 0x55d63
cltq
movzbl (%rax,%rbx), %eax
jmp 0x55d63
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x46e25
testl %eax, %eax
je 0x55d9e
cmpl %r12d, %eax
jne 0x55d87
testl %eax, %eax
je 0x55d07
movq -0x38(%rbp), %rbx
movq -0x48(%rbp), %rdi
movq %rbx, %rsi
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
callq 0x55a7c
testl %eax, %eax
je 0x55d2c
jmp 0x55cd9