// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/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 esc                          /* The escape character */
){
  u32 c, c2;
  int invert;
  int seen;
  u8 matchOne = pInfo->matchOne;
  u8 matchAll = pInfo->matchAll;
  u8 matchSet = pInfo->matchSet;
  u8 noCase = pInfo->noCase; 
  int prevEscape = 0;     /* True if the previous character was 'escape' */

  while( (c = sqlite3Utf8Read(&zPattern))!=0 ){
    if( c==matchAll && !prevEscape ){
      while( (c=sqlite3Utf8Read(&zPattern)) == matchAll
               || c == matchOne ){
        if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){
          return 0;
        }
      }
      if( c==0 ){
        return 1;
      }else if( c==esc ){
        c = sqlite3Utf8Read(&zPattern);
        if( c==0 ){
          return 0;
        }
      }else if( c==matchSet ){
        assert( esc==0 );         /* This is GLOB, not LIKE */
        assert( matchSet<0x80 );  /* '[' is a single-byte character */
        while( *zString && patternCompare(&zPattern[-1],zString,pInfo,esc)==0 ){
          SQLITE_SKIP_UTF8(zString);
        }
        return *zString!=0;
      }
      while( (c2 = sqlite3Utf8Read(&zString))!=0 ){
        if( noCase ){
          GlogUpperToLower(c2);
          GlogUpperToLower(c);
          while( c2 != 0 && c2 != c ){
            c2 = sqlite3Utf8Read(&zString);
            GlogUpperToLower(c2);
          }
        }else{
          while( c2 != 0 && c2 != c ){
            c2 = sqlite3Utf8Read(&zString);
          }
        }
        if( c2==0 ) return 0;
        if( patternCompare(zPattern,zString,pInfo,esc) ) return 1;
      }
      return 0;
    }else if( c==matchOne && !prevEscape ){
      if( sqlite3Utf8Read(&zString)==0 ){
        return 0;
      }
    }else if( c==matchSet ){
      u32 prior_c = 0;
      assert( esc==0 );    /* This only occurs for GLOB, not LIKE */
      seen = 0;
      invert = 0;
      c = sqlite3Utf8Read(&zString);
      if( c==0 ) return 0;
      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 0;
      }
    }else if( esc==c && !prevEscape ){
      prevEscape = 1;
    }else{
      c2 = sqlite3Utf8Read(&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 $0x38, %rsp
movl %ecx, %r14d
movq %rsi, %r15
leaq -0x38(%rbp), %rax
movq %rdi, (%rax)
movq %rsi, -0x40(%rbp)
movzbl 0x1(%rdx), %ecx
movl %ecx, -0x44(%rbp)
movzbl (%rdx), %ecx
movl %ecx, -0x48(%rbp)
movzbl 0x2(%rdx), %r12d
movq %rdx, -0x58(%rbp)
movb 0x3(%rdx), %cl
movb %cl, -0x29(%rbp)
movq %rax, %rdi
callq 0x36fc5
testl %eax, %eax
je 0x12745
movl %eax, %r13d
xorl %ebx, %ebx
movl -0x44(%rbp), %r15d
movl %r14d, -0x50(%rbp)
movl %r12d, -0x4c(%rbp)
movl %r13d, %eax
xorl -0x48(%rbp), %eax
orl %ebx, %eax
je 0x126c1
movl %r13d, %eax
xorl %r15d, %eax
orl %ebx, %eax
je 0x125bd
cmpl %r12d, %r13d
jne 0x125d5
leaq -0x40(%rbp), %rdi
callq 0x36fc5
xorl %r15d, %r15d
testl %eax, %eax
je 0x12859
movl %eax, %r13d
leaq -0x38(%rbp), %rdi
callq 0x36fc5
cmpl $0x5e, %eax
jne 0x1259e
leaq -0x38(%rbp), %rdi
callq 0x36fc5
movl $0x1, %r15d
xorl %r14d, %r14d
movl $0x0, %r12d
cmpl $0x5d, %eax
jne 0x12634
xorl %r14d, %r14d
cmpl $0x5d, %r13d
sete %r14b
jmp 0x12626
leaq -0x40(%rbp), %rdi
callq 0x36fc5
xorl %ebx, %ebx
testl %eax, %eax
jne 0x1265c
jmp 0x1285b
movl %r13d, %eax
xorl %r14d, %eax
orl %ebx, %eax
movl $0x1, %ebx
je 0x1265c
leaq -0x40(%rbp), %rdi
callq 0x36fc5
cmpb $0x0, -0x29(%rbp)
je 0x1261a
cmpl $0x7f, %r13d
ja 0x12608
movl %r13d, %ecx
leaq 0x63aad(%rip), %rdx     # 0x760b0
movzbl (%rcx,%rdx), %r13d
cmpl $0x7f, %eax
ja 0x1261a
movl %eax, %eax
leaq 0x63a9a(%rip), %rcx     # 0x760b0
movzbl (%rax,%rcx), %eax
xorl %ebx, %ebx
cmpl %eax, %r13d
je 0x1265c
jmp 0x1285b
xorl %eax, %eax
movl %eax, %r12d
leaq -0x38(%rbp), %rdi
callq 0x36fc5
cmpl $0x2d, %eax
je 0x12675
cmpl $0x5d, %eax
je 0x12647
testl %eax, %eax
jne 0x126b0
jmp 0x12859
cmpl %r15d, %r14d
movl -0x50(%rbp), %r14d
movl -0x4c(%rbp), %r12d
movl -0x44(%rbp), %r15d
je 0x12859
leaq -0x38(%rbp), %rdi
callq 0x36fc5
movl %eax, %r13d
testl %eax, %eax
jne 0x1254d
jmp 0x12741
movq -0x38(%rbp), %rcx
movb (%rcx), %cl
cmpb $0x5d, %cl
je 0x126b0
testb %cl, %cl
sete %cl
testl %r12d, %r12d
sete %dl
orb %cl, %dl
jne 0x126b0
leaq -0x38(%rbp), %rdi
callq 0x36fc5
cmpl %eax, %r13d
movl $0x1, %eax
cmoval %r14d, %eax
cmpl %r12d, %r13d
cmovael %eax, %r14d
jmp 0x12626
cmpl %eax, %r13d
movl $0x1, %ecx
cmovel %ecx, %r14d
jmp 0x12628
leaq -0x38(%rbp), %rdi
callq 0x36fc5
movl %r15d, %edx
movl %eax, %r15d
cmpl -0x48(%rbp), %eax
sete %cl
cmpl %edx, %eax
sete %al
orb %al, %cl
testb $0x1, %cl
je 0x1271c
leaq -0x40(%rbp), %rbx
leaq -0x38(%rbp), %r13
testb $0x1, %al
je 0x126fe
movq %rbx, %rdi
callq 0x36fc5
testl %eax, %eax
je 0x12859
movq %r13, %rdi
callq 0x36fc5
movl %eax, %r15d
cmpl -0x48(%rbp), %eax
sete %cl
cmpl -0x44(%rbp), %eax
sete %al
orb %al, %cl
testb $0x1, %cl
jne 0x126ea
movb $0x1, %bl
testl %r15d, %r15d
je 0x127b1
cmpl %r14d, %r15d
jne 0x12751
leaq -0x38(%rbp), %rdi
callq 0x36fc5
movl %eax, %r15d
testl %eax, %eax
jne 0x127b8
jmp 0x12859
movq -0x40(%rbp), %r15
cmpb $0x0, (%r15)
sete %bl
jmp 0x1285b
cmpl %r12d, %r15d
jne 0x127b8
movl %r14d, %r13d
movq -0x40(%rbp), %r15
movb (%r15), %r14b
testb %r14b, %r14b
je 0x12859
movq -0x38(%rbp), %r12
decq %r12
movq %r12, %rdi
movq %r15, %rsi
movq -0x58(%rbp), %rdx
movl %r13d, %ecx
callq 0x124ee
testl %eax, %eax
setne %bl
jne 0x127b1
cmpb $-0x40, %r14b
jb 0x127a1
movb 0x1(%r15), %r14b
incq %r15
movl %r14d, %eax
andb $-0x40, %al
negb %al
jo 0x1278f
jmp 0x127a7
incq %r15
movb (%r15), %r14b
testb %r14b, %r14b
jne 0x12770
jmp 0x1285b
movb $0x1, %bl
jmp 0x1285b
movq -0x38(%rbp), %r12
leaq -0x40(%rbp), %r13
movq %r13, %rdi
callq 0x36fc5
testl %eax, %eax
je 0x12859
cmpb $0x0, -0x29(%rbp)
je 0x12822
cmpl $0x7f, %eax
ja 0x127e8
movl %eax, %eax
leaq 0x638cc(%rip), %rcx     # 0x760b0
movzbl (%rax,%rcx), %eax
cmpl $0x7f, %r15d
ja 0x127fd
movl %r15d, %ecx
leaq 0x638b8(%rip), %rdx     # 0x760b0
movzbl (%rcx,%rdx), %r15d
testl %eax, %eax
je 0x12838
cmpl %r15d, %eax
je 0x12838
movq %r13, %rdi
callq 0x36fc5
cmpl $0x7f, %eax
ja 0x127fd
movl %eax, %eax
leaq 0x63894(%rip), %rcx     # 0x760b0
movzbl (%rax,%rcx), %eax
jmp 0x127fd
cmpl %r15d, %eax
je 0x1283c
movq %r13, %rdi
callq 0x36fc5
testl %eax, %eax
je 0x12838
cmpl %r15d, %eax
jne 0x12827
testl %eax, %eax
je 0x12859
movq -0x40(%rbp), %rsi
movq %r12, %rdi
movq -0x58(%rbp), %rdx
movl %r14d, %ecx
callq 0x124ee
testl %eax, %eax
je 0x127c0
jmp 0x1285b
xorl %ebx, %ebx
movzbl %bl, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq