// File: /workspace/github_c_makefile_star2_O2/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, %r13
movq %rsi, %r12
movq %rdi, %rbx
subl $0x1, 0x20(%rdi)
jae 0x1bf86
movq 0x18(%rbx), %rdi
leaq 0x5677(%rip), %rsi      # 0x215f6
xorl %eax, %eax
callq 0x12bd6
leaq 0x28(%rbx), %rax
movq %rax, (%rsp)
leaq 0x1(%r12), %r14
movq %r13, %r15
movq 0x10(%rbx), %rcx
cmpq %rcx, %r15
je 0x1c1f9
movzbl (%r15), %eax
addl $-0x24, %eax
cmpl $0x5, %eax
ja 0x1c061
leaq 0x5486(%rip), %rdx      # 0x21440
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movzbl 0x1(%r15), %eax
cmpl $0x66, %eax
jne 0x1c005
cmpb $0x5b, 0x2(%r15)
je 0x1bfe6
movq 0x18(%rbx), %rdi
leaq 0x562b(%rip), %rsi      # 0x2160a
xorl %eax, %eax
callq 0x12bd6
addq $0x2, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1c402
movq %rax, %r13
cmpq (%rbx), %r12
je 0x1c01b
movzbl -0x1(%r12), %edi
jmp 0x1c01d
leal -0x30(%rax), %edx
cmpl $0xa, %edx
jb 0x1c0e0
cmpl $0x62, %eax
jne 0x1c061
jmp 0x1c164
xorl %edi, %edi
leaq -0x1(%r13), %rbp
movq %r15, %rsi
movq %rbp, %rdx
callq 0x1c490
testl %eax, %eax
jne 0x1c27c
movzbl (%r12), %edi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x1c490
movq %r13, %r15
testl %eax, %eax
jne 0x1bf96
jmp 0x1c27c
leaq 0x1(%r15), %rax
cmpq %rcx, %rax
je 0x1c32b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1c402
movq %rax, %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x1c511
movzbl (%r13), %ecx
testl %eax, %eax
je 0x1c0b4
cmpl $0x3f, %ecx
jne 0x1c1d6
incq %r13
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x1bf5a
movq %r13, %r15
testq %rax, %rax
je 0x1bf96
jmp 0x1c294
cmpl $0x3f, %ecx
ja 0x1c27c
movl %ecx, %eax
movabsq $-0x7fffdc0000000000, %rcx # imm = 0x8000240000000000
btq %rax, %rcx
movl $0x0, %ebp
jae 0x1c297
incq %r13
jmp 0x1bf93
cmpb $0x31, %al
movq (%rsp), %r13
jb 0x1c101
addl $-0x31, %eax
movzbl 0x24(%rbx), %ecx
cmpl %ecx, %eax
jae 0x1c101
movl %eax, %ecx
shlq $0x4, %rcx
cmpq $-0x1, 0x8(%r13,%rcx)
jne 0x1c113
movq 0x18(%rbx), %rdi
leaq 0x55bd(%rip), %rsi      # 0x216c9
xorl %eax, %eax
callq 0x12bd6
cltq
shlq $0x4, %rax
movq 0x8(%r13,%rax), %r14
movq 0x8(%rbx), %rcx
subq %r12, %rcx
cmpq %r14, %rcx
jb 0x1c27c
addq %r13, %rax
movq (%rax), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x5370
testl %eax, %eax
jne 0x1c27c
movl $0x0, %ebp
testq %r12, %r12
je 0x1c297
addq %r14, %r12
addq $0x2, %r15
movq %r15, %r13
jmp 0x1bf8e
leaq 0x2(%r15), %r13
decq %rcx
cmpq %r13, %rcx
ja 0x1c182
movq 0x18(%rbx), %rdi
leaq 0x54dc(%rip), %rsi      # 0x21657
xorl %eax, %eax
callq 0x12bd6
movb (%r12), %al
cmpb (%r13), %al
jne 0x1c27c
movb 0x3(%r15), %cl
movq 0x8(%rbx), %rdx
pushq $0x1
popq %rsi
cmpq %rdx, %r14
jae 0x1c27c
movb (%r14), %dil
cmpb %cl, %dil
jne 0x1c1b2
decl %esi
jne 0x1c1bf
jmp 0x1c1c4
xorl %r8d, %r8d
cmpb %al, %dil
sete %r8b
addl %r8d, %esi
incq %r14
jmp 0x1c19b
incq %r14
addq $0x4, %r15
movq %r15, %r13
movq %r14, %r12
jmp 0x1bf8e
cmpl $0x2a, %ecx
je 0x1c2af
cmpl $0x2b, %ecx
je 0x1c2ac
cmpl $0x2d, %ecx
je 0x1c2f3
incq %r12
jmp 0x1bf8e
movq %r12, %rbp
jmp 0x1c297
cmpb $0x29, 0x1(%r15)
jne 0x1c280
addq $0x2, %r15
pushq $-0x2
jmp 0x1c285
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 0x1c23b
decq %rax
cmpq $-0x1, (%rcx)
leaq -0x10(%rcx), %rcx
jne 0x1c227
jmp 0x1c24d
movq 0x18(%rbx), %rdi
leaq 0x53f9(%rip), %rsi      # 0x2163f
xorl %eax, %eax
callq 0x12bd6
movslq %eax, %r14
shlq $0x4, %r14
movq %r12, %rax
subq (%r13,%r14), %rax
movq %rax, 0x8(%r13,%r14)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1bf5a
testq %rax, %rax
jne 0x1c294
addq %r14, %r13
orq $-0x1, 0x8(%r13)
xorl %ebp, %ebp
jmp 0x1c297
incq %r15
pushq $-0x1
popq %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1c398
movq %rax, %rbp
incl 0x20(%rbx)
movq %rbp, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incq %r12
pushq $-0x1
popq %r14
leaq (%r14,%r12), %rsi
incq %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r13, %rcx
callq 0x1c511
incq %r14
testl %eax, %eax
jne 0x1c2b3
incq %r13
testq %r14, %r14
js 0x1c27c
leaq (%r12,%r14), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x1bf5a
movq %rax, %rbp
decq %r14
testq %rax, %rax
je 0x1c2d2
jmp 0x1c297
movq %r13, %r14
incq %r14
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x1bf5a
testq %rax, %rax
jne 0x1c294
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x1c511
incq %r12
testl %eax, %eax
jne 0x1c2fb
jmp 0x1c297
xorl %ebp, %ebp
cmpq 0x8(%rbx), %r12
cmoveq %r12, %rbp
jmp 0x1c297