// File: /workspace/github_cpp_makefile_star2_O2/jgeumlek[P]moltengamepadctl/source/oscpkt/oscpkt.hh
// Function: oscpkt::internalPatternMatch(char const*, char const*)
inline const char *internalPatternMatch(const char *pattern, const char *path) {
  while (*pattern) {
    const char *p = pattern;
    if (*p == '?' && *path) { ++p; ++path; }
    else if (*p == '[' && *path) { // bracketted range, e.g. [a-zABC]
      ++p;
      bool reverse = false;
      if (*p == '!') { reverse = true; ++p; }
      bool match = reverse;
      for (; *p && *p != ']'; ++p) {
        char c0 = *p, c1 = c0;
        if (p[1] == '-' && p[2] && p[2] != ']') { p += 2; c1 = *p; }
        if (*path >= c0 && *path <= c1) { match = !reverse; }
      }
      if (!match || *p != ']') return pattern;
      ++p; ++path;
    } else if (*p == '*') { // wildcard '*'
      while (*p == '*') ++p; 
      const char *best = 0;
      while (true) {
        const char *ret = internalPatternMatch(p, path);
        if (ret && ret > best) best = ret;
        if (*path == 0 || *path == '/') break;
        else ++path;
      }
      return best;
    } else if (*p == '/' && *(p+1) == '/') { // the super-wildcard '//'
      while (*(p+1)=='/') ++p;
      const char *best = 0;
      while (true) {
        const char *ret = internalPatternMatch(p, path);
        if (ret && ret > best) best = ret;
        if (*path == 0) break;
        if (*path == 0 || (path = strchr(path+1, '/')) == 0) break;
      }      
      return best;
    } else if (*p == '{') { // braced list {foo,bar,baz}
      const char *end = strchr(p, '}'), *q;
      if (!end) return 0; // syntax error in brace list..
      bool match = false;
      do {
        ++p;
        q = strchr(p, ',');
        if (q == 0 || q > end) q = end;
        if (strncmp(p, path, q-p)==0) {
          path += (q-p); p = end+1; match = true;
        } else p=q;
      } while (q != end && !match);
      if (!match) return pattern;
    } else if (*p == *path) { ++p; ++path; } // any other character
    else break;
    pattern = p;
  }
  return (*path == 0 ? pattern : 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbp
movq %rdi, %r12
movq %r12, %r15
movzbl (%r12), %ecx
cmpl $0x2f, %ecx
je 0x49ca
cmpl $0x3f, %ecx
je 0x49c2
cmpl $0x5b, %ecx
je 0x4957
cmpl $0x7b, %ecx
je 0x49ee
testl %ecx, %ecx
je 0x4a94
cmpl $0x2a, %ecx
jne 0x49d5
jmp 0x4aa4
movb (%rbp), %al
testb %al, %al
je 0x49d5
leaq 0x1(%r15), %r12
leaq 0x2(%r15), %rsi
xorl %edx, %edx
cmpb $0x21, 0x1(%r15)
sete %cl
setne %dl
cmoveq %rsi, %r12
movzbl (%r12), %esi
testl %esi, %esi
je 0x4a75
cmpl $0x5d, %esi
je 0x4a75
cmpb $0x2d, 0x1(%r12)
jne 0x49a4
movzbl 0x2(%r12), %edi
testl %edi, %edi
je 0x49a4
cmpl $0x5d, %edi
jne 0x49bc
movl %esi, %edi
cmpb %dil, %al
movzbl %cl, %edi
movl %edx, %ecx
cmovgl %edi, %ecx
cmpb %sil, %al
cmovll %edi, %ecx
incq %r12
jmp 0x4977
addq $0x2, %r12
jmp 0x49a6
cmpb $0x0, (%rbp)
jne 0x49e0
jmp 0x49d5
cmpb $0x2f, 0x1(%r15)
je 0x4aeb
movb (%rbp), %al
cmpb %al, %cl
jne 0x4a97
incq %r15
incq %rbp
movq %r15, %r12
jmp 0x4919
movq %r15, %rdi
pushq $0x7d
popq %rsi
callq 0x20b0
testq %rax, %rax
je 0x4ae6
movq %rax, %r13
leaq 0x1(%rax), %r12
movq %r15, (%rsp)
movq %r15, %r14
movq %rbp, %r15
incq %r14
movq %r14, %rdi
pushq $0x2c
popq %rsi
callq 0x20b0
cmpq %r13, %rax
movq %rax, %rbx
cmovaq %r13, %rbx
testq %rax, %rax
cmoveq %r13, %rbx
movq %rbx, %rbp
subq %r14, %rbp
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2110
testl %eax, %eax
movq %rbx, %r14
cmoveq %r12, %r14
movl $0x0, %ecx
cmovneq %rcx, %rbp
addq %r15, %rbp
cmpq %r13, %rbx
je 0x4a64
testl %eax, %eax
jne 0x4a10
testl %eax, %eax
movq (%rsp), %r15
je 0x4919
jmp 0x4b39
cmpb $0x5d, %sil
setne %al
notb %cl
orb %al, %cl
testb $0x1, %cl
jne 0x4b39
incq %r12
incq %rbp
jmp 0x4919
movb (%rbp), %al
xorl %ecx, %ecx
testb %al, %al
cmovneq %rcx, %r15
jmp 0x4b39
movq %r15, %r14
cmpb $0x2a, %cl
jne 0x4ab5
movb 0x1(%r14), %cl
incq %r14
jmp 0x4aa7
xorl %r15d, %r15d
movq %r15, %r12
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4908
cmpq %r15, %rax
cmovaq %rax, %r15
testq %rax, %rax
cmoveq %r12, %r15
movzbl (%rbp), %eax
testl %eax, %eax
je 0x4b39
cmpl $0x2f, %eax
je 0x4b39
incq %rbp
jmp 0x4ab8
xorl %r15d, %r15d
jmp 0x4b39
decq %r15
movq %r15, %r14
cmpb $0x2f, 0x2(%r14)
leaq 0x1(%r14), %r14
je 0x4af1
xorl %r15d, %r15d
pushq $0x2f
popq %rbx
movq %r15, %r12
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4908
cmpq %r15, %rax
cmovaq %rax, %r15
testq %rax, %rax
cmoveq %r12, %r15
cmpb $0x0, (%rbp)
je 0x4b39
incq %rbp
movq %rbp, %rdi
movl %ebx, %esi
callq 0x20b0
movq %rax, %rbp
testq %rax, %rax
jne 0x4b02
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop