// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movl %ecx, 0x1c(%rsp)
leaq 0x8(%rsp), %rax
movq %rdi, (%rax)
leaq 0x10(%rsp), %rax
movq %rsi, (%rax)
movzbl 0x1(%rdx), %ebx
movzbl (%rdx), %r14d
movq %rdx, 0x20(%rsp)
movb 0x3(%rdx), %al
movb %al, 0x7(%rsp)
movq $0x0, 0x30(%rsp)
movl %r14d, 0x2c(%rsp)
movq 0x8(%rsp), %rax
movsbl (%rax), %r13d
testl %r13d, %r13d
js 0x27c17c
incq %rax
movq %rax, 0x8(%rsp)
jmp 0x27c189
leaq 0x8(%rsp), %rdi
callq 0x2a945f
movl %eax, %r13d
testl %r13d, %r13d
je 0x27c334
cmpl %r14d, %r13d
je 0x27c347
cmpl 0x1c(%rsp), %r13d
jne 0x27c231
movq 0x20(%rsp), %rax
cmpb $0x0, 0x2(%rax)
je 0x27c212
leaq 0x10(%rsp), %rdi
callq 0x2a945f
movl $0x1, %ebp
testl %eax, %eax
je 0x27c51a
movl %eax, %r13d
movl %ebx, %r15d
leaq 0x8(%rsp), %rdi
callq 0x2a945f
xorl %r12d, %r12d
movl $0x0, %r14d
cmpl $0x5e, %eax
jne 0x27c1f6
leaq 0x8(%rsp), %rdi
callq 0x2a945f
movl $0x1, %r14d
movl $0x0, %ebx
cmpl $0x5d, %eax
jne 0x27c2c6
xorl %ebx, %ebx
cmpl $0x5d, %r13d
sete %bl
jmp 0x27c2b7
leaq 0x8(%rsp), %rdi
callq 0x2a945f
testl %eax, %eax
je 0x27c515
movl %eax, %r13d
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x10(%rsp), %rcx
movsbl (%rcx), %eax
testl %eax, %eax
js 0x27c247
incq %rcx
movq %rcx, 0x10(%rsp)
jmp 0x27c251
leaq 0x10(%rsp), %rdi
callq 0x2a945f
cmpl %eax, %r13d
je 0x27c164
cmpb $0x0, 0x7(%rsp)
je 0x27c28c
movl %eax, %ecx
orl %r13d, %ecx
cmpl $0x7f, %ecx
ja 0x27c28c
movl %r13d, %ecx
movl $0xff, %esi
andl %esi, %ecx
movl %eax, %edx
andl %esi, %edx
leaq 0x155060(%rip), %rsi    # 0x3d12e0
movb (%rdx,%rsi), %dl
cmpb %dl, (%rcx,%rsi)
je 0x27c164
movl $0x1, %ebp
cmpl %ebx, %r13d
jne 0x27c51a
testl %eax, %eax
je 0x27c51a
movq 0x30(%rsp), %rax
cmpq %rax, 0x8(%rsp)
jne 0x27c164
jmp 0x27c51a
xorl %eax, %eax
movl %eax, %r12d
leaq 0x8(%rsp), %rdi
callq 0x2a945f
cmpl $0x2d, %eax
je 0x27c2ef
cmpl $0x5d, %eax
je 0x27c2d9
testl %eax, %eax
jne 0x27c327
jmp 0x27c51a
cmpl %r14d, %ebx
movl %r15d, %ebx
movl 0x2c(%rsp), %r14d
jne 0x27c164
jmp 0x27c51a
movq 0x8(%rsp), %rcx
movb (%rcx), %cl
cmpb $0x5d, %cl
je 0x27c327
testb %cl, %cl
sete %cl
testl %r12d, %r12d
sete %dl
orb %cl, %dl
jne 0x27c327
leaq 0x8(%rsp), %rdi
callq 0x2a945f
cmpl %eax, %r13d
movl $0x1, %eax
cmoval %ebx, %eax
cmpl %r12d, %r13d
cmovael %eax, %ebx
jmp 0x27c2b7
cmpl %eax, %r13d
movl $0x1, %ecx
cmovel %ecx, %ebx
jmp 0x27c2b9
movq 0x10(%rsp), %rax
xorl %ebp, %ebp
cmpb $0x0, (%rax)
setne %bpl
jmp 0x27c51a
leaq 0x10(%rsp), %rbp
leaq 0x8(%rsp), %r13
movq 0x8(%rsp), %rax
movsbl (%rax), %r15d
testl %r15d, %r15d
js 0x27c369
incq %rax
movq %rax, 0x8(%rsp)
jmp 0x27c374
movq %r13, %rdi
callq 0x2a945f
movl %eax, %r15d
cmpl %r14d, %r15d
sete %al
cmpl %ebx, %r15d
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x27c3a2
cmpl %ebx, %r15d
jne 0x27c351
movq %rbp, %rdi
callq 0x2a945f
testl %eax, %eax
jne 0x27c351
movl $0x2, %ebp
jmp 0x27c51a
testl %r15d, %r15d
je 0x27c41c
cmpl 0x1c(%rsp), %r15d
jne 0x27c438
movq 0x20(%rsp), %rax
cmpb $0x0, 0x2(%rax)
je 0x27c423
movq 0x10(%rsp), %r15
movb (%r15), %bl
movl $0x2, %ebp
testb %bl, %bl
je 0x27c51a
movq 0x8(%rsp), %r12
decq %r12
movq %r12, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %rdx
movl 0x1c(%rsp), %ecx
callq 0x27c120
cmpl $0x1, %eax
jne 0x27c511
cmpb $-0x40, %bl
jb 0x27c40d
movb 0x1(%r15), %bl
incq %r15
movl %ebx, %eax
andb $-0x40, %al
negb %al
jo 0x27c3fc
jmp 0x27c413
incq %r15
movb (%r15), %bl
testb %bl, %bl
jne 0x27c3da
jmp 0x27c51a
xorl %ebp, %ebp
jmp 0x27c51a
leaq 0x8(%rsp), %rdi
callq 0x2a945f
movl %eax, %r15d
testl %eax, %eax
je 0x27c398
cmpl $0x81, %r15d
jae 0x27c46e
cmpb $0x0, 0x7(%rsp)
je 0x27c4c2
movl %r15d, %eax
leaq 0x154fee(%rip), %rcx    # 0x3d1440
movb (%rax,%rcx), %cl
notb %cl
orb $-0x21, %cl
andb %cl, %r15b
leaq 0x154e7c(%rip), %rcx    # 0x3d12e0
movb (%rax,%rcx), %al
movb $0x0, 0x2b(%rsp)
jmp 0x27c4c4
movq 0x8(%rsp), %r12
leaq 0x10(%rsp), %r13
movq 0x10(%rsp), %rcx
movsbl (%rcx), %eax
testl %eax, %eax
js 0x27c48e
incq %rcx
movq %rcx, 0x10(%rsp)
jmp 0x27c496
movq %r13, %rdi
callq 0x2a945f
testl %eax, %eax
je 0x27c398
cmpl %r15d, %eax
jne 0x27c478
movq 0x10(%rsp), %rsi
movq %r12, %rdi
movq 0x20(%rsp), %rdx
movl 0x1c(%rsp), %ecx
callq 0x27c120
movl %eax, %ebp
cmpl $0x1, %eax
je 0x27c478
jmp 0x27c51a
xorl %eax, %eax
leaq 0x29(%rsp), %r12
movb %r15b, (%r12)
movb %al, 0x1(%r12)
movq 0x10(%rsp), %r15
movq 0x8(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x170a0
cmpb $0x0, (%r15,%rax)
je 0x27c398
addq %rax, %r15
incq %r15
movq %r13, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %rdx
movl 0x1c(%rsp), %ecx
callq 0x27c120
cmpl $0x1, %eax
je 0x27c4dc
movl %eax, %ebp
jmp 0x27c51a
movl $0x1, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq