// File: /workspace/github_c_makefile_star2_O2/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, 0x24(%rsp)
leaq 0x18(%rsp), %r15
movq %rdi, (%r15)
leaq 0x10(%rsp), %rax
movq %rsi, (%rax)
movzbl 0x1(%rdx), %eax
movl %eax, 0x34(%rsp)
movzbl (%rdx), %eax
movl %eax, 0x38(%rsp)
movq %rdx, 0x28(%rsp)
movb 0x3(%rdx), %al
movb %al, 0xf(%rsp)
movq $0x0, 0x40(%rsp)
pushq $0x1
popq %r14
movq 0x18(%rsp), %rax
movsbl (%rax), %r13d
testl %r13d, %r13d
js 0x2279ad
incq %rax
movq %rax, 0x18(%rsp)
jmp 0x2279b8
movq %r15, %rdi
callq 0x24e375
movl %eax, %r13d
testl %r13d, %r13d
je 0x227b3c
cmpl 0x38(%rsp), %r13d
je 0x227b50
cmpl 0x24(%rsp), %r13d
jne 0x227a4e
movq 0x28(%rsp), %rax
cmpb $0x0, 0x2(%rax)
je 0x227a31
leaq 0x10(%rsp), %rdi
callq 0x24e375
testl %eax, %eax
je 0x227d26
movl %eax, %r13d
movq %r15, %rdi
callq 0x24e375
xorl %ebx, %ebx
movl $0x0, %ebp
cmpl $0x5e, %eax
jne 0x227a12
movq %r15, %rdi
callq 0x24e375
movl %r14d, %ebp
movl $0x0, %r12d
cmpl $0x5d, %eax
jne 0x227add
xorl %r12d, %r12d
cmpl $0x5d, %r13d
sete %r12b
jmp 0x227ad1
movq %r15, %rdi
callq 0x24e375
testl %eax, %eax
je 0x227d26
movl %eax, %r13d
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rcx
movsbl (%rcx), %eax
testl %eax, %eax
js 0x227a64
incq %rcx
movq %rcx, 0x10(%rsp)
jmp 0x227a6e
leaq 0x10(%rsp), %rdi
callq 0x24e375
cmpl %eax, %r13d
je 0x227995
cmpb $0x0, 0xf(%rsp)
je 0x227aa9
movl %eax, %ecx
orl %r13d, %ecx
cmpl $0x7f, %ecx
ja 0x227aa9
movl %r13d, %ecx
movl $0xff, %esi
andl %esi, %ecx
movl %eax, %edx
andl %esi, %edx
leaq 0x149c53(%rip), %rsi    # 0x3716f0
movb (%rdx,%rsi), %dl
cmpb %dl, (%rcx,%rsi)
je 0x227995
cmpl 0x34(%rsp), %r13d
jne 0x227d26
testl %eax, %eax
je 0x227d26
movq 0x40(%rsp), %rax
cmpq %rax, 0x18(%rsp)
jne 0x227995
jmp 0x227d26
xorl %eax, %eax
movl %eax, %ebx
movq %r15, %rdi
callq 0x24e375
cmpl $0x2d, %eax
je 0x227afe
cmpl $0x5d, %eax
je 0x227af0
testl %eax, %eax
jne 0x227b33
jmp 0x227d26
cmpl %ebp, %r12d
jne 0x227995
jmp 0x227d26
movq 0x18(%rsp), %rcx
movb (%rcx), %cl
cmpb $0x5d, %cl
je 0x227b33
testb %cl, %cl
sete %cl
testl %ebx, %ebx
sete %dl
orb %cl, %dl
jne 0x227b33
movq %r15, %rdi
callq 0x24e375
cmpl %eax, %r13d
movl %r14d, %eax
cmoval %r12d, %eax
cmpl %ebx, %r13d
cmovael %eax, %r12d
jmp 0x227ad1
cmpl %eax, %r13d
cmovel %r14d, %r12d
jmp 0x227ad3
movq 0x10(%rsp), %rax
xorl %r14d, %r14d
cmpb $0x0, (%rax)
setne %r14b
jmp 0x227d26
leaq 0x10(%rsp), %rbp
pushq $0x2
popq %r14
leaq 0x18(%rsp), %r13
movl 0x34(%rsp), %ebx
movq 0x18(%rsp), %rax
movsbl (%rax), %r15d
testl %r15d, %r15d
js 0x227b7a
incq %rax
movq %rax, 0x18(%rsp)
jmp 0x227b85
movq %r13, %rdi
callq 0x24e375
movl %eax, %r15d
cmpl 0x38(%rsp), %r15d
sete %al
cmpl %ebx, %r15d
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x227bb0
cmpl %ebx, %r15d
jne 0x227b62
movq %rbp, %rdi
callq 0x24e375
testl %eax, %eax
jne 0x227b62
jmp 0x227d26
testl %r15d, %r15d
je 0x227c1d
cmpl 0x24(%rsp), %r15d
jne 0x227c3a
movq 0x28(%rsp), %rax
cmpb $0x0, 0x2(%rax)
je 0x227c25
movl %r14d, %ebp
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %r15
decq %r15
movb (%rax), %bl
testb %bl, %bl
je 0x227ccb
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
movq 0x28(%rsp), %rdx
movl 0x24(%rsp), %ecx
callq 0x22794b
cmpl $0x1, %eax
jne 0x227d1e
leaq 0x1(%r12), %rax
cmpb $-0x40, %bl
jb 0x227bd7
movq %r12, %rax
movb 0x1(%rax), %cl
incq %rax
andb $-0x40, %cl
negb %cl
jo 0x227c0e
jmp 0x227bd7
xorl %r14d, %r14d
jmp 0x227d26
leaq 0x18(%rsp), %rdi
callq 0x24e375
movl %eax, %r15d
testl %eax, %eax
je 0x227d26
cmpl $0x81, %r15d
jae 0x227c77
cmpb $0x0, 0xf(%rsp)
je 0x227cd0
movl %r14d, %ebx
movl %r15d, %eax
leaq 0x149bf5(%rip), %rcx    # 0x371850
movb (%rax,%rcx), %cl
notb %cl
orb $-0x21, %cl
andb %cl, %r15b
leaq 0x149a83(%rip), %rcx    # 0x3716f0
movb (%rax,%rcx), %al
movb $0x0, 0x3f(%rsp)
jmp 0x227cd5
movl %r14d, %ebx
movq 0x18(%rsp), %r12
leaq 0x10(%rsp), %r13
movq 0x10(%rsp), %rcx
movsbl (%rcx), %eax
testl %eax, %eax
js 0x227c9a
incq %rcx
movq %rcx, 0x10(%rsp)
jmp 0x227ca2
movq %r13, %rdi
callq 0x24e375
testl %eax, %eax
je 0x227d23
cmpl %r15d, %eax
jne 0x227c84
movq 0x10(%rsp), %rsi
movq %r12, %rdi
movq 0x28(%rsp), %rdx
movl 0x24(%rsp), %ecx
callq 0x22794b
movl %eax, %r14d
cmpl $0x1, %eax
je 0x227c84
jmp 0x227d26
movl %ebp, %r14d
jmp 0x227d26
movl %r14d, %ebx
xorl %eax, %eax
leaq 0x3d(%rsp), %r12
movb %r15b, (%r12)
movb %al, 0x1(%r12)
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x17090
cmpb $0x0, (%r15,%rax)
je 0x227d23
addq %rax, %r15
incq %r15
movq %r13, %rdi
movq %r15, %rsi
movq 0x28(%rsp), %rdx
movl 0x24(%rsp), %ecx
callq 0x22794b
cmpl $0x1, %eax
je 0x227ced
movl %eax, %r14d
jmp 0x227d26
movl %ebx, %r14d
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq