// File: /workspace/github_c_makefile_star2_O3/tylerneylon[P]APIsWithLua/lua/lstrlib.c
// Function: match
static const char *match (MatchState *ms, const char *s, const char *p) {
  if (ms->matchdepth-- == 0)
    luaL_error(ms->L, "pattern too complex");
  init: /* using goto's to optimize tail recursion */
  if (p != ms->p_end) {  /* end of pattern? */
    switch (*p) {
      case '(': {  /* start capture */
        if (*(p + 1) == ')')  /* position capture? */
          s = start_capture(ms, s, p + 2, CAP_POSITION);
        else
          s = start_capture(ms, s, p + 1, CAP_UNFINISHED);
        break;
      }
      case ')': {  /* end capture */
        s = end_capture(ms, s, p + 1);
        break;
      }
      case '$': {
        if ((p + 1) != ms->p_end)  /* is the '$' the last char in pattern? */
          goto dflt;  /* no; go to default */
        s = (s == ms->src_end) ? s : NULL;  /* check end of string */
        break;
      }
      case L_ESC: {  /* escaped sequences not in the format class[*+?-]? */
        switch (*(p + 1)) {
          case 'b': {  /* balanced string? */
            s = matchbalance(ms, s, p + 2);
            if (s != NULL) {
              p += 4; goto init;  /* return match(ms, s, p + 4); */
            }  /* else fail (s == NULL) */
            break;
          }
          case 'f': {  /* frontier? */
            const char *ep; char previous;
            p += 2;
            if (*p != '[')
              luaL_error(ms->L, "missing '[' after '%%f' in pattern");
            ep = classend(ms, p);  /* points to what is next */
            previous = (s == ms->src_init) ? '\0' : *(s - 1);
            if (!matchbracketclass(uchar(previous), p, ep - 1) &&
               matchbracketclass(uchar(*s), p, ep - 1)) {
              p = ep; goto init;  /* return match(ms, s, ep); */
            }
            s = NULL;  /* match failed */
            break;
          }
          case '0': case '1': case '2': case '3':
          case '4': case '5': case '6': case '7':
          case '8': case '9': {  /* capture results (%0-%9)? */
            s = match_capture(ms, s, uchar(*(p + 1)));
            if (s != NULL) {
              p += 2; goto init;  /* return match(ms, s, p + 2) */
            }
            break;
          }
          default: goto dflt;
        }
        break;
      }
      default: dflt: {  /* pattern class plus optional suffix */
        const char *ep = classend(ms, p);  /* points to optional suffix */
        /* does not match at least once? */
        if (!singlematch(ms, s, p, ep)) {
          if (*ep == '*' || *ep == '?' || *ep == '-') {  /* accept empty? */
            p = ep + 1; goto init;  /* return match(ms, s, ep + 1); */
          }
          else  /* '+' or no suffix */
            s = NULL;  /* fail */
        }
        else {  /* matched once */
          switch (*ep) {  /* handle optional suffix */
            case '?': {  /* optional */
              const char *res;
              if ((res = match(ms, s + 1, ep + 1)) != NULL)
                s = res;
              else {
                p = ep + 1; goto init;  /* else return match(ms, s, ep + 1); */
              }
              break;
            }
            case '+':  /* 1 or more repetitions */
              s++;  /* 1 match already done */
              /* FALLTHROUGH */
            case '*':  /* 0 or more repetitions */
              s = max_expand(ms, s, p, ep);
              break;
            case '-':  /* 0 or more repetitions (minimum) */
              s = min_expand(ms, s, p, ep);
              break;
            default:  /* no suffix */
              s++; p = ep; goto init;  /* return match(ms, s + 1, ep); */
          }
        }
        break;
      }
    }
  }
  ms->matchdepth++;
  return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %rbx
subl $0x1, 0x20(%rdi)
jae 0x1e7b1
movq 0x18(%rbx), %rdi
leaq 0x5de4(%rip), %rsi      # 0x2458e
xorl %eax, %eax
callq 0x14a62
leaq 0x28(%rbx), %rax
movq %rax, (%rsp)
leaq 0x1(%r14), %r13
movq %rbp, %r15
movq 0x10(%rbx), %rcx
cmpq %rcx, %r15
je 0x1ea34
movzbl (%r15), %eax
cmpl $0x25, %eax
jne 0x1e86a
movzbl 0x1(%r15), %eax
cmpl $0x66, %eax
jne 0x1e81b
cmpb $0x5b, 0x2(%r15)
je 0x1e7fd
movq 0x18(%rbx), %rdi
leaq 0x5dac(%rip), %rsi      # 0x245a2
xorl %eax, %eax
callq 0x14a62
addq $0x2, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1ec56
movq %rax, %r12
cmpq (%rbx), %r14
je 0x1e831
movzbl -0x1(%r14), %edi
jmp 0x1e833
leal -0x30(%rax), %edx
cmpl $0xa, %edx
jb 0x1e912
cmpl $0x62, %eax
jne 0x1e890
jmp 0x1e996
xorl %edi, %edi
leaq -0x1(%r12), %rbp
movq %r15, %rsi
movq %rbp, %rdx
callq 0x1ece4
testl %eax, %eax
jne 0x1eacd
movzbl (%r14), %edi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x1ece4
movq %r12, %r15
testl %eax, %eax
jne 0x1e7c0
jmp 0x1eacd
cmpl $0x24, %eax
je 0x1e883
cmpl $0x29, %eax
je 0x1ea5e
cmpl $0x28, %eax
je 0x1ea3c
jmp 0x1e890
leaq 0x1(%r15), %rax
cmpq %rcx, %rax
je 0x1eb7b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1ec56
movq %rax, %rbp
movq 0x8(%rbx), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x1ed75
movzbl (%rbp), %ecx
testl %eax, %eax
je 0x1e8e6
cmpl $0x3f, %ecx
jne 0x1ea11
incq %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1e785
movq %rbp, %r15
testq %rax, %rax
je 0x1e7c0
jmp 0x1eae7
cmpl $0x3f, %ecx
ja 0x1eacd
movl %ecx, %eax
movabsq $-0x7fffdc0000000000, %rcx # imm = 0x8000240000000000
btq %rax, %rcx
movl $0x0, %eax
jae 0x1eae7
incq %rbp
jmp 0x1e7bd
cmpb $0x31, %al
movq (%rsp), %r13
jb 0x1e933
addl $-0x31, %eax
movzbl 0x24(%rbx), %ecx
cmpl %ecx, %eax
jae 0x1e933
movl %eax, %ecx
shlq $0x4, %rcx
cmpq $-0x1, 0x8(%r13,%rcx)
jne 0x1e945
movq 0x18(%rbx), %rdi
leaq 0x5d23(%rip), %rsi      # 0x24661
xorl %eax, %eax
callq 0x14a62
cltq
shlq $0x4, %rax
movq 0x8(%r13,%rax), %r12
movq 0x8(%rbx), %rcx
subq %r14, %rcx
cmpq %r12, %rcx
jb 0x1eacd
addq %r13, %rax
movq (%rax), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x5380
testl %eax, %eax
jne 0x1eacd
movl $0x0, %eax
testq %r14, %r14
je 0x1eae7
addq %r12, %r14
addq $0x2, %r15
movq %r15, %rbp
jmp 0x1e7b9
leaq 0x2(%r15), %r12
decq %rcx
cmpq %r12, %rcx
ja 0x1e9b4
movq 0x18(%rbx), %rdi
leaq 0x5c42(%rip), %rsi      # 0x245ef
xorl %eax, %eax
callq 0x14a62
movb (%r14), %al
cmpb (%r12), %al
jne 0x1eacd
movq 0x8(%rbx), %rcx
incq %r14
cmpq %rcx, %r14
jae 0x1eacd
movb 0x3(%r15), %dl
movl $0x1, %esi
movb (%r14), %dil
cmpb %dl, %dil
jne 0x1e9e8
decl %esi
jne 0x1e9f5
jmp 0x1ea02
xorl %r8d, %r8d
cmpb %al, %dil
sete %r8b
addl %r8d, %esi
incq %r14
cmpq %rcx, %r14
jne 0x1e9da
jmp 0x1eacd
incq %r14
addq $0x4, %r15
movq %r15, %rbp
jmp 0x1e7b9
cmpl $0x2a, %ecx
je 0x1eb30
cmpl $0x2b, %ecx
je 0x1eb2d
cmpl $0x2d, %ecx
je 0x1eaf9
movq %r13, %r14
jmp 0x1e7b9
movq %r14, %rax
jmp 0x1eae7
cmpb $0x29, 0x1(%r15)
jne 0x1ead1
addq $0x2, %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
jmp 0x1eae2
incq %r15
movzbl 0x24(%rbx), %eax
movl %eax, %ecx
shll $0x4, %ecx
addq %rbx, %rcx
addq $0x20, %rcx
movq (%rsp), %r13
testq %rax, %rax
jle 0x1ea89
decq %rax
cmpq $-0x1, (%rcx)
leaq -0x10(%rcx), %rcx
jne 0x1ea75
jmp 0x1ea9b
movq 0x18(%rbx), %rdi
leaq 0x5b43(%rip), %rsi      # 0x245d7
xorl %eax, %eax
callq 0x14a62
movslq %eax, %r12
shlq $0x4, %r12
movq %r14, %rax
subq (%r13,%r12), %rax
movq %rax, 0x8(%r13,%r12)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1e785
testq %rax, %rax
jne 0x1eae7
addq %r12, %r13
movq $-0x1, 0x8(%r13)
xorl %eax, %eax
jmp 0x1eae7
incq %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x1ebec
incl 0x20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %r12
incq %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1e785
testq %rax, %rax
jne 0x1eae7
movq 0x8(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x1ed75
testl %eax, %eax
je 0x1eacd
incq %r14
jmp 0x1eaff
incq %r14
movq $-0x1, %r13
leaq (%r14,%r13), %rsi
incq %rsi
movq %r12, %rdi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x1ed75
incq %r13
testl %eax, %eax
jne 0x1eb37
incq %rbp
testq %r13, %r13
js 0x1eacd
leaq (%r14,%r13), %rsi
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x1e785
decq %r13
testq %rax, %rax
je 0x1eb56
jmp 0x1eae7
xorl %eax, %eax
cmpq 0x8(%rbx), %r14
cmoveq %r14, %rax
jmp 0x1eae7