// File: /workspace/github_c_makefile_star2_O3/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, -0x3c(%rbp)
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %dl
orb %al, %dl
jne 0x643bc
movq %rsi, %r12
movl %ecx, -0x40(%rbp)
xorl %r14d, %r14d
leaq -0x30(%rbp), %rdx
xorl %esi, %esi
callq 0x5157c
testl %eax, %eax
je 0x6437b
movl %eax, %ebx
leaq -0x38(%rbp), %r12
leaq -0x30(%rbp), %r13
movl %ebx, %eax
xorl $0x2a, %eax
orl %r14d, %eax
je 0x6433d
movl %ebx, %eax
xorl $0x3f, %eax
orl %r14d, %eax
je 0x6420e
cmpl $0x5b, %ebx
jne 0x64232
cmpl $0x0, -0x3c(%rbp)
je 0x643bc
movq -0x38(%rbp), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
movq %r12, %rdx
callq 0x5157c
testl %eax, %eax
je 0x643bf
movl %eax, %ebx
movq -0x30(%rbp), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
movq %r13, %rdx
callq 0x5157c
movl %eax, %r15d
movl $0x0, -0x48(%rbp)
cmpl $0x5e, %eax
jne 0x641ec
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x5157c
movl %eax, %r15d
movl $0x1, -0x48(%rbp)
movl $0x0, %r13d
cmpl $0x5d, %r15d
jne 0x642a6
xorl %r12d, %r12d
cmpl $0x5d, %ebx
sete %r12b
xorl %r15d, %r15d
jmp 0x64291
movq -0x38(%rbp), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
movq %r12, %rdx
callq 0x5157c
movl $0x0, %r15d
testl %eax, %eax
jne 0x642ce
jmp 0x643bf
movl %ebx, %eax
xorl -0x3c(%rbp), %eax
orl %eax, %r14d
movl $0x1, %r14d
je 0x642ce
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x5157c
cmpl $0x0, -0x40(%rbp)
je 0x6427f
cmpl $0x7f, %ebx
jg 0x6426d
movslq %ebx, %rcx
leaq 0xef67(%rip), %rdx      # 0x731d0
movzbl (%rcx,%rdx), %ebx
cmpl $0x7f, %eax
jg 0x6427f
cltq
leaq 0xef55(%rip), %rcx      # 0x731d0
movzbl (%rax,%rcx), %eax
xorl %r14d, %r14d
movl $0x0, %r15d
cmpl %eax, %ebx
je 0x642ce
jmp 0x643bf
movl %r15d, %r13d
movq -0x30(%rbp), %rdi
xorl %esi, %esi
leaq -0x30(%rbp), %rdx
callq 0x5157c
movl %eax, %r15d
cmpl $0x2d, %r15d
je 0x642eb
cmpl $0x5d, %r15d
je 0x642bc
testl %r15d, %r15d
jne 0x6432c
jmp 0x643bf
cmpl -0x48(%rbp), %r12d
leaq -0x38(%rbp), %r12
leaq -0x30(%rbp), %r13
je 0x643bc
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x5157c
movl %eax, %ebx
testl %eax, %eax
jne 0x6416a
jmp 0x64377
movq -0x30(%rbp), %rdi
movb (%rdi), %al
cmpb $0x5d, %al
je 0x6432c
testb %al, %al
sete %al
testl %r13d, %r13d
setle %cl
orb %al, %cl
jne 0x6432c
xorl %r15d, %r15d
xorl %esi, %esi
leaq -0x30(%rbp), %rdx
callq 0x5157c
cmpl %eax, %ebx
movl $0x1, %eax
cmovgl %r12d, %eax
cmpl %r13d, %ebx
cmovll %r12d, %eax
movl %eax, %r12d
jmp 0x64291
cmpl %r15d, %ebx
movl $0x1, %eax
cmovel %eax, %r12d
jmp 0x64291
leaq -0x30(%rbp), %rbx
leaq -0x38(%rbp), %r13
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x5157c
cmpl $0x2a, %eax
je 0x64345
movl %eax, %r12d
cmpl $0x3f, %eax
jne 0x64389
movq -0x38(%rbp), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
movq %r13, %rdx
callq 0x5157c
testl %eax, %eax
jne 0x64345
jmp 0x643bf
movq -0x38(%rbp), %r12
xorl %r15d, %r15d
cmpb $0x0, (%r12)
sete %r15b
jmp 0x643bf
testl %r12d, %r12d
jne 0x64396
movl $0x1, %r15d
jmp 0x643bf
cmpl -0x3c(%rbp), %r12d
jne 0x643b6
leaq -0x30(%rbp), %rdx
movq (%rdx), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x5157c
testl %eax, %eax
je 0x643bf
movl %eax, %r12d
jmp 0x643d1
cmpl $0x5b, %r12d
jne 0x643d1
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl -0x40(%rbp), %r14d
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 0x5157c
testl %eax, %eax
je 0x643bf
testl %r14d, %r14d
je 0x64444
cmpl $0x7f, %eax
leaq 0xedc8(%rip), %rbx      # 0x731d0
jg 0x64410
cltq
movzbl (%rax,%rbx), %eax
cmpl $0x7f, %r12d
jg 0x64439
movslq %r12d, %rcx
movzbl (%rcx,%rbx), %r12d
jmp 0x64439
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x5157c
cmpl $0x7f, %eax
jg 0x64439
cltq
movzbl (%rax,%rbx), %eax
testl %eax, %eax
je 0x64460
cmpl %r12d, %eax
jne 0x64420
jmp 0x64460
cmpl %r12d, %eax
je 0x64468
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x5157c
testl %eax, %eax
je 0x64460
cmpl %r12d, %eax
jne 0x64449
testl %eax, %eax
je 0x643bf
movq -0x38(%rbp), %rbx
movq -0x48(%rbp), %rdi
movq %rbx, %rsi
movl -0x3c(%rbp), %edx
movl %r14d, %ecx
callq 0x64114
testl %eax, %eax
je 0x643e8
jmp 0x6438e