// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: patternCompare
static int patternCompare(
  const u8 *zPattern,              /* The glob pattern */
  const u8 *zString,               /* The string to compare against the glob */
  const struct compareInfo *pInfo, /* Information about how to do the compare */
  u32 matchOther                   /* The escape char (LIKE) or '[' (GLOB) */
){
  u32 c, c2;                       /* Next pattern and input string chars */
  u32 matchOne = pInfo->matchOne;  /* "?" or "_" */
  u32 matchAll = pInfo->matchAll;  /* "*" or "%" */
  u8 noCase = pInfo->noCase;       /* True if uppercase==lowercase */
  const u8 *zEscaped = 0;          /* One past the last escaped input char */

  while( (c = Utf8Read(zPattern))!=0 ){
    if( c==matchAll ){  /* Match "*" */
      /* Skip over multiple "*" characters in the pattern.  If there
      ** are also "?" characters, skip those as well, but consume a
      ** single character of the input string for each "?" skipped */
      while( (c=Utf8Read(zPattern)) == matchAll || c == matchOne ){
        if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){
          return SQLITE_NOWILDCARDMATCH;
        }
      }
      if( c==0 ){
        return SQLITE_MATCH;   /* "*" at the end of the pattern matches */
      }else if( c==matchOther ){
        if( pInfo->matchSet==0 ){
          c = sqlite3Utf8Read(&zPattern);
          if( c==0 ) return SQLITE_NOWILDCARDMATCH;
        }else{
          /* "[...]" immediately follows the "*".  We have to do a slow
          ** recursive search in this case, but it is an unusual case. */
          assert( matchOther<0x80 );  /* '[' is a single-byte character */
          while( *zString ){
            int bMatch = patternCompare(&zPattern[-1],zString,pInfo,matchOther);
            if( bMatch!=SQLITE_NOMATCH ) return bMatch;
            SQLITE_SKIP_UTF8(zString);
          }
          return SQLITE_NOWILDCARDMATCH;
        }
      }

      /* At this point variable c contains the first character of the
      ** pattern string past the "*".  Search in the input string for the
      ** first matching character and recursively continue the match from
      ** that point.
      **
      ** For a case-insensitive search, set variable cx to be the same as
      ** c but in the other case and search the input string for either
      ** c or cx.
      */
      if( c<=0x80 ){
        char zStop[3];
        int bMatch;
        if( noCase ){
          zStop[0] = sqlite3Toupper(c);
          zStop[1] = sqlite3Tolower(c);
          zStop[2] = 0;
        }else{
          zStop[0] = c;
          zStop[1] = 0;
        }
        while(1){
          zString += strcspn((const char*)zString, zStop);
          if( zString[0]==0 ) break;
          zString++;
          bMatch = patternCompare(zPattern,zString,pInfo,matchOther);
          if( bMatch!=SQLITE_NOMATCH ) return bMatch;
        }
      }else{
        int bMatch;
        while( (c2 = Utf8Read(zString))!=0 ){
          if( c2!=c ) continue;
          bMatch = patternCompare(zPattern,zString,pInfo,matchOther);
          if( bMatch!=SQLITE_NOMATCH ) return bMatch;
        }
      }
      return SQLITE_NOWILDCARDMATCH;
    }
    if( c==matchOther ){
      if( pInfo->matchSet==0 ){
        c = sqlite3Utf8Read(&zPattern);
        if( c==0 ) return SQLITE_NOMATCH;
        zEscaped = zPattern;
      }else{
        u32 prior_c = 0;
        int seen = 0;
        int invert = 0;
        c = sqlite3Utf8Read(&zString);
        if( c==0 ) return SQLITE_NOMATCH;
        c2 = sqlite3Utf8Read(&zPattern);
        if( c2=='^' ){
          invert = 1;
          c2 = sqlite3Utf8Read(&zPattern);
        }
        if( c2==']' ){
          if( c==']' ) seen = 1;
          c2 = sqlite3Utf8Read(&zPattern);
        }
        while( c2 && c2!=']' ){
          if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){
            c2 = sqlite3Utf8Read(&zPattern);
            if( c>=prior_c && c<=c2 ) seen = 1;
            prior_c = 0;
          }else{
            if( c==c2 ){
              seen = 1;
            }
            prior_c = c2;
          }
          c2 = sqlite3Utf8Read(&zPattern);
        }
        if( c2==0 || (seen ^ invert)==0 ){
          return SQLITE_NOMATCH;
        }
        continue;
      }
    }
    c2 = Utf8Read(zString);
    if( c==c2 ) continue;
    if( noCase  && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){
      continue;
    }
    if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;
    return SQLITE_NOMATCH;
  }
  return *zString==0 ? SQLITE_MATCH : SQLITE_NOMATCH;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, 0x2c(%rsp)
leaq 0x10(%rsp), %rax
movq %rdi, (%rax)
leaq 0x20(%rsp), %rax
movq %rsi, (%rax)
movzbl 0x1(%rdx), %ebx
movzbl (%rdx), %r14d
movq %rdx, 0x30(%rsp)
movb 0x3(%rdx), %al
movb %al, 0xf(%rsp)
movq $0x0, 0x40(%rsp)
movl %r14d, 0x3c(%rsp)
movq 0x10(%rsp), %rax
movsbl (%rax), %r13d
testl %r13d, %r13d
js 0x285b49
incq %rax
movq %rax, 0x10(%rsp)
jmp 0x285b56
leaq 0x10(%rsp), %rdi
callq 0x2b3087
movl %eax, %r13d
testl %r13d, %r13d
je 0x285d01
cmpl %r14d, %r13d
je 0x285d14
cmpl 0x2c(%rsp), %r13d
jne 0x285bfe
movq 0x30(%rsp), %rax
cmpb $0x0, 0x2(%rax)
je 0x285bdf
leaq 0x20(%rsp), %rdi
callq 0x2b3087
movl $0x1, %ebp
testl %eax, %eax
je 0x285f27
movl %eax, %r13d
movl %ebx, %r15d
leaq 0x10(%rsp), %rdi
callq 0x2b3087
xorl %r12d, %r12d
movl $0x0, %r14d
cmpl $0x5e, %eax
jne 0x285bc3
leaq 0x10(%rsp), %rdi
callq 0x2b3087
movl $0x1, %r14d
movl $0x0, %ebx
cmpl $0x5d, %eax
jne 0x285c93
xorl %ebx, %ebx
cmpl $0x5d, %r13d
sete %bl
jmp 0x285c84
leaq 0x10(%rsp), %rdi
callq 0x2b3087
testl %eax, %eax
je 0x285eb9
movl %eax, %r13d
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x20(%rsp), %rcx
movsbl (%rcx), %eax
testl %eax, %eax
js 0x285c14
incq %rcx
movq %rcx, 0x20(%rsp)
jmp 0x285c1e
leaq 0x20(%rsp), %rdi
callq 0x2b3087
cmpl %eax, %r13d
je 0x285b31
cmpb $0x0, 0xf(%rsp)
je 0x285c59
movl %eax, %ecx
orl %r13d, %ecx
cmpl $0x7f, %ecx
ja 0x285c59
movl %r13d, %ecx
movl $0xff, %esi
andl %esi, %ecx
movl %eax, %edx
andl %esi, %edx
leaq 0x154e13(%rip), %rsi    # 0x3daa60
movb (%rdx,%rsi), %dl
cmpb %dl, (%rcx,%rsi)
je 0x285b31
cmpl %ebx, %r13d
jne 0x285eb9
movl $0x1, %ebp
testl %eax, %eax
je 0x285f27
movq 0x40(%rsp), %rax
cmpq %rax, 0x10(%rsp)
jne 0x285b31
jmp 0x285f27
xorl %eax, %eax
movl %eax, %r12d
leaq 0x10(%rsp), %rdi
callq 0x2b3087
cmpl $0x2d, %eax
je 0x285cbc
cmpl $0x5d, %eax
je 0x285ca6
testl %eax, %eax
jne 0x285cf4
jmp 0x285f27
cmpl %r14d, %ebx
movl %r15d, %ebx
movl 0x3c(%rsp), %r14d
jne 0x285b31
jmp 0x285f27
movq 0x10(%rsp), %rcx
movb (%rcx), %cl
cmpb $0x5d, %cl
je 0x285cf4
testb %cl, %cl
sete %cl
testl %r12d, %r12d
sete %dl
orb %cl, %dl
jne 0x285cf4
leaq 0x10(%rsp), %rdi
callq 0x2b3087
cmpl %eax, %r13d
movl $0x1, %eax
cmoval %ebx, %eax
cmpl %r12d, %r13d
cmovael %eax, %ebx
jmp 0x285c84
cmpl %eax, %r13d
movl $0x1, %ecx
cmovel %ecx, %ebx
jmp 0x285c86
movq 0x20(%rsp), %rax
xorl %ebp, %ebp
cmpb $0x0, (%rax)
setne %bpl
jmp 0x285f27
leaq 0x20(%rsp), %rbp
leaq 0x10(%rsp), %r13
movq 0x10(%rsp), %rax
movsbl (%rax), %r15d
testl %r15d, %r15d
js 0x285d36
incq %rax
movq %rax, 0x10(%rsp)
jmp 0x285d41
movq %r13, %rdi
callq 0x2b3087
movl %eax, %r15d
cmpl %r14d, %r15d
sete %al
cmpl %ebx, %r15d
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x285d6f
cmpl %ebx, %r15d
jne 0x285d1e
movq %rbp, %rdi
callq 0x2b3087
testl %eax, %eax
jne 0x285d1e
movl $0x2, %ebp
jmp 0x285f27
testl %r15d, %r15d
je 0x285de6
cmpl 0x2c(%rsp), %r15d
jne 0x285e02
movq 0x30(%rsp), %rax
cmpb $0x0, 0x2(%rax)
je 0x285ded
movq 0x20(%rsp), %r15
movq 0x10(%rsp), %r12
decq %r12
movl $0x1, %ebp
movb (%r15), %bl
testb %bl, %bl
je 0x285ead
movq %r12, %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rdx
movl 0x2c(%rsp), %ecx
callq 0x285aed
cmpl $0x1, %eax
jne 0x285dd5
cmpb $-0x40, %bl
jb 0x285dd9
movb 0x1(%r15), %cl
incq %r15
andb $-0x40, %cl
negb %cl
jo 0x285dc5
jmp 0x285ddc
movl %eax, %ebp
jmp 0x285ddc
incq %r15
cmpl $0x1, %eax
je 0x285d9c
jmp 0x285eb2
xorl %ebp, %ebp
jmp 0x285f27
leaq 0x10(%rsp), %rdi
callq 0x2b3087
movl %eax, %r15d
testl %eax, %eax
je 0x285d65
cmpl $0x81, %r15d
jae 0x285e48
cmpb $0x0, 0xf(%rsp)
je 0x285ec0
movl %r15d, %eax
leaq 0x154da0(%rip), %rcx    # 0x3dabc0
movb (%rax,%rcx), %cl
notb %cl
orb $-0x21, %cl
andb %cl, %r15b
movb %r15b, 0x1d(%rsp)
leaq 0x154c29(%rip), %rcx    # 0x3daa60
movb (%rax,%rcx), %al
movb %al, 0x1e(%rsp)
leaq 0x1f(%rsp), %rax
jmp 0x285eca
movq 0x10(%rsp), %r12
leaq 0x20(%rsp), %rbx
movq 0x20(%rsp), %rax
movsbl (%rax), %r13d
testl %r13d, %r13d
js 0x285e6a
incq %rax
movq %rax, 0x20(%rsp)
jmp 0x285e75
movq %rbx, %rdi
callq 0x2b3087
movl %eax, %r13d
testl %r13d, %r13d
je 0x285e9e
cmpl %r15d, %r13d
jne 0x285e52
movq 0x20(%rsp), %rsi
movq %r12, %rdi
movq 0x30(%rsp), %rdx
movl 0x2c(%rsp), %ecx
callq 0x285aed
cmpl $0x1, %eax
je 0x285e52
movl %eax, %ebp
jmp 0x285ea3
movl $0x1, %ebp
testl %r13d, %r13d
jne 0x285f27
jmp 0x285d65
movl $0x2, %ebp
movq %r15, 0x20(%rsp)
jmp 0x285f27
movl $0x1, %ebp
jmp 0x285f27
movb %r15b, 0x1d(%rsp)
leaq 0x1e(%rsp), %rax
movb $0x0, (%rax)
movq 0x20(%rsp), %r15
movq 0x10(%rsp), %r12
leaq 0x1d(%rsp), %r13
movq %r15, %rbp
movq %r15, %rdi
movq %r13, %rsi
callq 0x170a0
addq %rax, %r15
movb (%rbp,%rax), %bl
testb %bl, %bl
je 0x285f15
incq %r15
movq %r12, %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rdx
movl 0x2c(%rsp), %ecx
callq 0x285aed
cmpl $0x1, %eax
je 0x285edc
movl %eax, %ebp
jmp 0x285f1a
movl $0x1, %ebp
movq %r15, 0x20(%rsp)
testb %bl, %bl
je 0x285d65
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq