// File: /workspace/github_c_makefile_star2_O1/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
leaq -0x38(%rbp), %rax
movq %rdi, (%rax)
movq %rsi, -0x40(%rbp)
movzbl 0x1(%rdx), %r15d
movzbl (%rdx), %ecx
movl %ecx, -0x44(%rbp)
movzbl 0x2(%rdx), %r12d
movq %rdx, -0x58(%rbp)
movb 0x3(%rdx), %cl
movb %cl, -0x29(%rbp)
movq %rax, %rdi
callq 0x368be
testl %eax, %eax
je 0x125bb
movl %eax, %r13d
xorl %ebx, %ebx
movl %r14d, -0x50(%rbp)
movl %r12d, -0x4c(%rbp)
movl %r15d, -0x48(%rbp)
movl %r13d, %eax
xorl -0x44(%rbp), %eax
orl %ebx, %eax
je 0x125c7
movl %r13d, %eax
xorl %r15d, %eax
orl %ebx, %eax
je 0x124ba
cmpl %r12d, %r13d
jne 0x124d2
leaq -0x40(%rbp), %rdi
callq 0x368be
xorl %r15d, %r15d
testl %eax, %eax
je 0x12632
movl %eax, %r13d
leaq -0x38(%rbp), %rdi
callq 0x368be
cmpl $0x5e, %eax
jne 0x1249b
leaq -0x38(%rbp), %rdi
callq 0x368be
movl $0x1, %r15d
xorl %r12d, %r12d
movl $0x0, %r14d
cmpl $0x5d, %eax
jne 0x12531
xorl %r12d, %r12d
cmpl $0x5d, %r13d
sete %r12b
jmp 0x12523
leaq -0x40(%rbp), %rdi
callq 0x368be
xorl %ebx, %ebx
testl %eax, %eax
jne 0x12559
jmp 0x12634
movl %r13d, %eax
xorl %r14d, %eax
orl %ebx, %eax
movl $0x1, %ebx
je 0x12559
leaq -0x40(%rbp), %rdi
callq 0x368be
cmpb $0x0, -0x29(%rbp)
je 0x12517
cmpl $0x7f, %r13d
ja 0x12505
movl %r13d, %ecx
leaq 0x63b60(%rip), %rdx     # 0x76060
movzbl (%rcx,%rdx), %r13d
cmpl $0x7f, %eax
ja 0x12517
movl %eax, %eax
leaq 0x63b4d(%rip), %rcx     # 0x76060
movzbl (%rax,%rcx), %eax
xorl %ebx, %ebx
cmpl %eax, %r13d
je 0x12559
jmp 0x12634
xorl %eax, %eax
movl %eax, %r14d
leaq -0x38(%rbp), %rdi
callq 0x368be
cmpl $0x2d, %eax
je 0x1256f
cmpl $0x5d, %eax
je 0x12544
testl %eax, %eax
jne 0x125aa
jmp 0x12632
cmpl %r15d, %r12d
movl -0x50(%rbp), %r14d
movl -0x4c(%rbp), %r12d
movl -0x48(%rbp), %r15d
je 0x12632
leaq -0x38(%rbp), %rdi
callq 0x368be
movl %eax, %r13d
testl %eax, %eax
jne 0x1244a
jmp 0x125bb
movq -0x38(%rbp), %rcx
movb (%rcx), %cl
cmpb $0x5d, %cl
je 0x125aa
testb %cl, %cl
sete %cl
testl %r14d, %r14d
sete %dl
orb %cl, %dl
jne 0x125aa
leaq -0x38(%rbp), %rdi
callq 0x368be
cmpl %eax, %r13d
movl $0x1, %eax
cmoval %r12d, %eax
cmpl %r14d, %r13d
cmovael %eax, %r12d
jmp 0x12523
cmpl %eax, %r13d
movl $0x1, %ecx
cmovel %ecx, %r12d
jmp 0x12525
movq -0x40(%rbp), %rax
cmpb $0x0, (%rax)
sete %bl
jmp 0x12634
leaq -0x38(%rbp), %rdi
callq 0x368be
movl %r15d, %ebx
movl %eax, %r15d
cmpl %ebx, %eax
sete %al
cmpl -0x44(%rbp), %r15d
je 0x125e6
cmpl %ebx, %r15d
jne 0x12616
leaq -0x38(%rbp), %r13
testb $0x1, %al
je 0x125fb
leaq -0x40(%rbp), %rdi
callq 0x368be
testl %eax, %eax
je 0x12632
movq %r13, %rdi
callq 0x368be
movl %eax, %r15d
cmpl %ebx, %eax
sete %al
cmpl -0x44(%rbp), %r15d
je 0x125ea
cmpl %ebx, %r15d
je 0x125ea
movb $0x1, %bl
testl %r15d, %r15d
je 0x12634
cmpl %r14d, %r15d
jne 0x12646
leaq -0x38(%rbp), %rdi
callq 0x368be
movl %eax, %r15d
testl %eax, %eax
jne 0x126a7
xorl %ebx, %ebx
movzbl %bl, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl %r12d, %r15d
jne 0x126a7
movl %r14d, %r13d
movq -0x40(%rbp), %r15
movb (%r15), %r14b
testb %r14b, %r14b
je 0x12758
movq -0x38(%rbp), %r12
decq %r12
movq %r12, %rdi
movq %r15, %rsi
movq -0x58(%rbp), %rdx
movl %r13d, %ecx
callq 0x123f0
testl %eax, %eax
setne %bl
jne 0x1275a
cmpb $-0x40, %r14b
jb 0x12697
movb 0x1(%r15), %al
incq %r15
andb $-0x40, %al
negb %al
jo 0x12688
jmp 0x1269a
incq %r15
movb (%r15), %r14b
testb %r14b, %r14b
jne 0x12665
jmp 0x1275a
movq -0x38(%rbp), %r12
leaq -0x40(%rbp), %r13
movq %r13, %rdi
callq 0x368be
testl %eax, %eax
je 0x12632
movl %eax, %ecx
cmpb $0x0, -0x29(%rbp)
je 0x12715
movl %ecx, %eax
cmpl $0x7f, %ecx
ja 0x126db
movl %ecx, %eax
leaq 0x63989(%rip), %rcx     # 0x76060
movzbl (%rax,%rcx), %eax
cmpl $0x7f, %r15d
ja 0x126f0
movl %r15d, %ecx
leaq 0x63975(%rip), %rdx     # 0x76060
movzbl (%rcx,%rdx), %r15d
testl %eax, %eax
je 0x12730
cmpl %r15d, %eax
je 0x12730
movq %r13, %rdi
callq 0x368be
cmpl $0x7f, %eax
ja 0x126f0
movl %eax, %eax
leaq 0x63951(%rip), %rcx     # 0x76060
movzbl (%rax,%rcx), %eax
jmp 0x126f0
movl $0x1, %eax
cmpl %r15d, %ecx
je 0x12730
movq %r13, %rdi
callq 0x368be
testl %eax, %eax
je 0x12730
cmpl %r15d, %eax
jne 0x1271f
testl %eax, %eax
je 0x12632
movq -0x40(%rbp), %rsi
movq %r12, %rdi
movq -0x58(%rbp), %rdx
movl %r14d, %ecx
callq 0x123f0
testl %eax, %eax
je 0x126af
jmp 0x12634
xorl %ebx, %ebx
movq %r15, -0x40(%rbp)
jmp 0x12634