// File: /workspace/github_c_makefile_star2_O1/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 %edx, %r14d
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %dl
orb %al, %dl
jne 0x65e76
movl %ecx, -0x3c(%rbp)
leaq -0x30(%rbp), %rdx
movq (%rdx), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x52cee
testl %eax, %eax
je 0x65df4
movl %eax, %ebx
leaq -0x38(%rbp), %r13
movl %r14d, -0x4c(%rbp)
movl %ebx, %eax
xorl $0x2a, %eax
orl %r12d, %eax
je 0x65e04
movl %ebx, %eax
xorl $0x3f, %eax
orl %r12d, %eax
je 0x65cc7
cmpl $0x5b, %ebx
jne 0x65ceb
testl %r14d, %r14d
je 0x65e76
movq -0x38(%rbp), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
movq %r13, %rdx
callq 0x52cee
testl %eax, %eax
je 0x65e79
movl %eax, %ebx
movq -0x30(%rbp), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
leaq -0x30(%rbp), %rdx
callq 0x52cee
movl %eax, %r15d
movl $0x0, %eax
cmpl $0x5e, %r15d
jne 0x65ca2
movq -0x30(%rbp), %rdi
xorl %esi, %esi
leaq -0x30(%rbp), %rdx
callq 0x52cee
movl %eax, %r15d
movl $0x1, %eax
movl %eax, -0x48(%rbp)
movl $0x0, %r13d
cmpl $0x5d, %r15d
jne 0x65d5f
xorl %r14d, %r14d
cmpl $0x5d, %ebx
sete %r14b
xorl %r15d, %r15d
jmp 0x65d4a
movq -0x38(%rbp), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
movq %r13, %rdx
callq 0x52cee
movl $0x0, %r15d
testl %eax, %eax
jne 0x65d87
jmp 0x65e79
movl %ebx, %eax
xorl %r14d, %eax
orl %eax, %r12d
movl $0x1, %r12d
je 0x65d87
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x52cee
cmpl $0x0, -0x3c(%rbp)
je 0x65d38
cmpl $0x7f, %ebx
jg 0x65d26
movslq %ebx, %rcx
leaq 0xf49e(%rip), %rdx      # 0x751c0
movzbl (%rcx,%rdx), %ebx
cmpl $0x7f, %eax
jg 0x65d38
cltq
leaq 0xf48c(%rip), %rcx      # 0x751c0
movzbl (%rax,%rcx), %eax
xorl %r12d, %r12d
movl $0x0, %r15d
cmpl %eax, %ebx
je 0x65d87
jmp 0x65e79
movl %r15d, %r13d
movq -0x30(%rbp), %rdi
xorl %esi, %esi
leaq -0x30(%rbp), %rdx
callq 0x52cee
movl %eax, %r15d
cmpl $0x2d, %r15d
je 0x65da2
cmpl $0x5d, %r15d
je 0x65d75
testl %r15d, %r15d
jne 0x65de3
jmp 0x65e79
cmpl -0x48(%rbp), %r14d
movl -0x4c(%rbp), %r14d
leaq -0x38(%rbp), %r13
je 0x65e76
movq -0x30(%rbp), %rdi
xorl %esi, %esi
leaq -0x30(%rbp), %rdx
callq 0x52cee
movl %eax, %ebx
testl %eax, %eax
jne 0x65c22
jmp 0x65df4
movq -0x30(%rbp), %rdi
movb (%rdi), %al
cmpb $0x5d, %al
je 0x65de3
testb %al, %al
sete %al
testl %r13d, %r13d
setle %cl
orb %al, %cl
jne 0x65de3
xorl %r15d, %r15d
xorl %esi, %esi
leaq -0x30(%rbp), %rdx
callq 0x52cee
cmpl %eax, %ebx
movl $0x1, %eax
cmovgl %r14d, %eax
cmpl %r13d, %ebx
cmovll %r14d, %eax
movl %eax, %r14d
jmp 0x65d4a
cmpl %r15d, %ebx
movl $0x1, %eax
cmovel %eax, %r14d
jmp 0x65d4a
movq -0x38(%rbp), %rax
xorl %r15d, %r15d
cmpb $0x0, (%rax)
sete %r15b
jmp 0x65e79
leaq -0x30(%rbp), %rbx
leaq -0x38(%rbp), %r13
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x52cee
cmpl $0x2a, %eax
je 0x65e0c
movl %eax, %r12d
cmpl $0x3f, %eax
jne 0x65e3e
movq -0x38(%rbp), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
movq %r13, %rdx
callq 0x52cee
testl %eax, %eax
jne 0x65e0c
jmp 0x65e79
testl %r12d, %r12d
jne 0x65e4b
movl $0x1, %r15d
jmp 0x65e79
cmpl %r14d, %r12d
jne 0x65e6d
leaq -0x30(%rbp), %rdx
movq (%rdx), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x52cee
testl %eax, %eax
je 0x65e79
movl %eax, %r12d
movl -0x3c(%rbp), %ebx
jmp 0x65e8b
cmpl $0x5b, %r12d
movl -0x3c(%rbp), %ebx
jne 0x65e8b
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
xorl %r15d, %r15d
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x52cee
testl %eax, %eax
je 0x65e79
movl %eax, %ecx
testl %ebx, %ebx
je 0x65f07
movl %ecx, %eax
cmpl $0x7f, %ecx
jg 0x65ec7
movslq %ecx, %rax
leaq 0xf2fd(%rip), %rcx      # 0x751c0
movzbl (%rax,%rcx), %eax
cmpl $0x7f, %r12d
jg 0x65edc
movslq %r12d, %rcx
leaq 0xf2e9(%rip), %rdx      # 0x751c0
movzbl (%rcx,%rdx), %r12d
testl %eax, %eax
je 0x65f28
cmpl %r12d, %eax
je 0x65f28
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x52cee
cmpl $0x7f, %eax
jg 0x65edc
cltq
leaq 0xf2bf(%rip), %rcx      # 0x751c0
movzbl (%rax,%rcx), %eax
jmp 0x65edc
movl $0x1, %eax
cmpl %r12d, %ecx
je 0x65f28
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x52cee
testl %eax, %eax
je 0x65f28
cmpl %r12d, %eax
jne 0x65f11
testl %eax, %eax
je 0x65e79
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdi
movl %r14d, %edx
movl %ebx, %ecx
callq 0x65bcc
testl %eax, %eax
je 0x65e9a
jmp 0x65e43