// File: attractivechaos[P]udb2/stb/./stb.h
// Function: stb__wildmatch_raw2
int stb__wildmatch_raw2(char *expr, char *candidate, int search, int insensitive)
{
   int where=0;
   int start = -1;
   
   if (!search) {
      // parse to first '*'
      if (*expr != '*')
         start = 0;
      while (*expr != '*') {
         if (!*expr)
            return *candidate == 0 ? 0 : -1;
         if (*expr == '?') {
            if (!*candidate) return -1;
         } else {
            if (insensitive) {
               if (tolower(*candidate) != tolower(*expr))
                  return -1;
            } else 
               if (*candidate != *expr)
                  return -1;
         }
         ++candidate, ++expr, ++where;
      }
   } else {
      // 0-length search string
      if (!*expr)
         return 0;
   }

   assert(search || *expr == '*');
   if (!search)
      ++expr;

   // implicit '*' at this point
      
   while (*expr) {
      int o=0;
      // combine redundant * characters
      while (expr[0] == '*') ++expr;

      // ok, at this point, expr[-1] == '*',
      // and expr[0] != '*'

      if (!expr[0]) return start >= 0 ? start : 0;

      // now find next '*'
      o = 0;
      while (expr[o] != '*') {
         if (expr[o] == 0)
            break;
         ++o;
      }
      // if no '*', scan to end, then match at end
      if (expr[o] == 0 && !search) {
         int z;
         for (z=0; z < o; ++z)
            if (candidate[z] == 0)
               return -1;
         while (candidate[z])
            ++z;
         // ok, now check if they match
         if (stb__match_qstring(candidate+z-o, expr, o, insensitive))
            return start >= 0 ? start : 0;
         return -1; 
      } else {
         // if yes '*', then do stb__find_qmatch on the intervening chars
         int n = stb__find_qstring(candidate, expr, o, insensitive);
         if (n < 0)
            return -1;
         if (start < 0)
            start = where + n;
         expr += o;
         candidate += n+o;
      }

      if (*expr == 0) {
         assert(search);
         return start;
      }

      assert(*expr == '*');
      ++expr;
   }

   return start >= 0 ? start : 0;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
movl %ecx, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
movl $0xffffffff, 0x20(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x2c(%rsp)
jne 0x16818
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
je 0x16726
movl $0x0, 0x20(%rsp)
jmp 0x16728
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
je 0x16816
movq 0x38(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x16761
movq 0x30(%rsp), %rax
movsbl (%rax), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movl %eax, 0x44(%rsp)
jmp 0x16b12
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3f, %eax
jne 0x16787
movq 0x30(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x16785
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x16b12
jmp 0x167ea
cmpl $0x0, 0x28(%rsp)
je 0x167c5
movq 0x30(%rsp), %rax
movsbl (%rax), %edi
callq 0x2250
movl %eax, 0x10(%rsp)
movq 0x38(%rsp), %rax
movsbl (%rax), %edi
callq 0x2250
movl %eax, %ecx
movl 0x10(%rsp), %eax
cmpl %ecx, %eax
je 0x167c3
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x16b12
jmp 0x167e8
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
movq 0x38(%rsp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x167e6
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x16b12
jmp 0x167e8
jmp 0x167ea
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x16728
jmp 0x16831
movq 0x38(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x1682f
movl $0x0, 0x44(%rsp)
jmp 0x16b12
jmp 0x16831
cmpl $0x0, 0x2c(%rsp)
jne 0x16845
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0x16847
jmp 0x16866
leaq 0x9392(%rip), %rdi      # 0x1fbe0
leaq 0x8b34(%rip), %rsi      # 0x1f389
movl $0x22f6, %edx           # imm = 0x22F6
leaq 0x9396(%rip), %rcx      # 0x1fbf7
callq 0x2140
cmpl $0x0, 0x2c(%rsp)
jne 0x1687b
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0x1687d
movq 0x38(%rsp), %rax
cmpb $0x0, (%rax)
je 0x16af1
movl $0x0, 0x1c(%rsp)
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0x168b0
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0x16893
movq 0x38(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x168e0
cmpl $0x0, 0x20(%rsp)
jl 0x168cb
movl 0x20(%rsp), %eax
movl %eax, 0xc(%rsp)
jmp 0x168d3
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x168d3
movl 0xc(%rsp), %eax
movl %eax, 0x44(%rsp)
jmp 0x16b12
movl $0x0, 0x1c(%rsp)
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2a, %eax
je 0x1691d
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x16910
jmp 0x1691d
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x168e8
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x16a03
cmpl $0x0, 0x2c(%rsp)
jne 0x16a03
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
cmpl 0x1c(%rsp), %eax
jge 0x16980
movq 0x30(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x16971
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x16b12
jmp 0x16973
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x16947
jmp 0x16982
movq 0x30(%rsp), %rax
movslq 0x18(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x1699f
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x16982
movq 0x30(%rsp), %rdi
movslq 0x18(%rsp), %rax
addq %rax, %rdi
movslq 0x1c(%rsp), %rcx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rdi
movq 0x38(%rsp), %rsi
movl 0x1c(%rsp), %edx
movl 0x28(%rsp), %ecx
callq 0x16b20
cmpl $0x0, %eax
je 0x169f6
cmpl $0x0, 0x20(%rsp)
jl 0x169e1
movl 0x20(%rsp), %eax
movl %eax, 0x8(%rsp)
jmp 0x169e9
xorl %eax, %eax
movl %eax, 0x8(%rsp)
jmp 0x169e9
movl 0x8(%rsp), %eax
movl %eax, 0x44(%rsp)
jmp 0x16b12
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x16b12
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movl 0x1c(%rsp), %edx
movl 0x28(%rsp), %ecx
callq 0x16c70
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x14(%rsp)
jge 0x16a32
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x16b12
cmpl $0x0, 0x20(%rsp)
jge 0x16a45
movl 0x24(%rsp), %eax
addl 0x14(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x1c(%rsp), %ecx
movq 0x38(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x38(%rsp)
movl 0x14(%rsp), %ecx
addl 0x1c(%rsp), %ecx
movq 0x30(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x16ab0
cmpl $0x0, 0x2c(%rsp)
je 0x16a87
jmp 0x16aa6
leaq 0x919b(%rip), %rdi      # 0x1fc29
leaq 0x88f4(%rip), %rsi      # 0x1f389
movl $0x2325, %edx           # imm = 0x2325
leaq 0x9156(%rip), %rcx      # 0x1fbf7
callq 0x2140
movl 0x20(%rsp), %eax
movl %eax, 0x44(%rsp)
jmp 0x16b12
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0x16abf
jmp 0x16ade
leaq 0x9124(%rip), %rdi      # 0x1fbea
leaq 0x88bc(%rip), %rsi      # 0x1f389
movl $0x2329, %edx           # imm = 0x2329
leaq 0x911e(%rip), %rcx      # 0x1fbf7
callq 0x2140
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0x1687d
cmpl $0x0, 0x20(%rsp)
jl 0x16b02
movl 0x20(%rsp), %eax
movl %eax, 0x4(%rsp)
jmp 0x16b0a
xorl %eax, %eax
movl %eax, 0x4(%rsp)
jmp 0x16b0a
movl 0x4(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopl (%rax,%rax)