// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rdi, %rbx
subl $0x1, 0x20(%rdi)
jae 0x1dc09
movq 0x18(%rbx), %rdi
leaq 0x58d4(%rip), %rsi      # 0x234d6
xorl %eax, %eax
callq 0x13f8e
movq 0x10(%rbx), %rcx
cmpq %rbp, %rcx
je 0x1df5a
leaq 0x28(%rbx), %r12
movq %r12, (%rsp)
movzbl (%rbp), %eax
addl $-0x24, %eax
cmpl $0x5, %eax
ja 0x1dc47
leaq 0x56ef(%rip), %rdx      # 0x23320
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
leaq 0x1(%rbp), %rax
cmpq %rcx, %rax
je 0x1dfba
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1e106
movq %rax, %r14
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rax, %rcx
callq 0x1e225
movzbl (%r14), %ecx
testl %eax, %eax
je 0x1dd47
cmpl $0x2c, %ecx
jg 0x1dd73
cmpl $0x2a, %ecx
je 0x1dc8c
cmpl $0x2b, %ecx
jne 0x1de0a
incq %r13
movq $-0x1, %r15
xorl %ecx, %ecx
movq %rcx, %r12
leaq (%r15,%r13), %rsi
incq %rsi
movq %rbx, %rdi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x1e225
incq %r15
leaq 0x1(%r12), %rcx
testl %eax, %eax
jne 0x1dc95
incq %r14
testq %r12, %r12
js 0x1ddff
leaq (%r12,%r13), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1dbdd
decq %r12
testq %rax, %rax
cmovneq %rax, %r15
je 0x1dcbc
jmp 0x1ddca
movzbl 0x1(%rbp), %eax
leal -0x30(%rax), %edx
cmpl $0xa, %edx
jae 0x1de57
cmpb $0x31, %al
jb 0x1dd12
addl $-0x31, %eax
movzbl 0x24(%rbx), %ecx
cmpl %ecx, %eax
jge 0x1dd12
movl %eax, %ecx
shlq $0x4, %rcx
cmpq $-0x1, 0x8(%r12,%rcx)
jne 0x1dd24
movq 0x18(%rbx), %rdi
leaq 0x588c(%rip), %rsi      # 0x235a9
xorl %eax, %eax
callq 0x13f8e
cltq
shlq $0x4, %rax
movq 0x8(%r12,%rax), %r14
movq 0x8(%rbx), %rcx
subq %r13, %rcx
cmpq %r14, %rcx
jae 0x1ddce
xorl %r15d, %r15d
jmp 0x1ddf0
xorl %r15d, %r15d
xorl %eax, %eax
cmpl $0x3f, %ecx
ja 0x1de3a
movl %ecx, %ecx
movabsq $-0x7fffdc0000000000, %rdx # imm = 0x8000240000000000
btq %rcx, %rdx
jae 0x1de3a
incq %r14
jmp 0x1de0d
cmpl $0x3f, %ecx
je 0x1de17
cmpl $0x2d, %ecx
jne 0x1de0a
movq %r14, %r12
incq %r12
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x1dbdd
testq %rax, %rax
je 0x1dda5
xorl %ecx, %ecx
movq %rax, %r15
jmp 0x1ddc6
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x1e225
testl %eax, %eax
je 0x1ddc1
incq %r13
movb $0x1, %cl
jmp 0x1ddc6
xorl %r15d, %r15d
xorl %ecx, %ecx
testb %cl, %cl
jne 0x1dd8b
xorl %eax, %eax
jmp 0x1de04
addq %r12, %rax
movq (%rax), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x5390
addq %r14, %r13
testl %eax, %eax
movl $0x0, %eax
cmovneq %rax, %r13
movq %r13, %r15
testq %r15, %r15
je 0x1dfc7
addq $0x2, %rbp
jmp 0x1de42
xorl %eax, %eax
xorl %r15d, %r15d
movq (%rsp), %r12
jmp 0x1de3a
incq %r13
movb $0x1, %al
movq %r14, %rbp
movq %r13, %r15
jmp 0x1de3a
leaq 0x1(%r13), %rsi
incq %r14
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1dbdd
movq %rax, %r15
testq %rax, %rax
sete %al
cmoveq %r14, %rbp
cmoveq %r13, %r15
testb %al, %al
je 0x1df5d
movq 0x10(%rbx), %rcx
movq %r15, %r13
cmpq %rcx, %rbp
jne 0x1dc1e
jmp 0x1df5d
cmpl $0x66, %eax
je 0x1dee0
cmpl $0x62, %eax
jne 0x1dc47
leaq 0x2(%rbp), %r14
decq %rcx
cmpq %r14, %rcx
ja 0x1de87
movq 0x18(%rbx), %rdi
leaq 0x56b7(%rip), %rsi      # 0x23537
xorl %eax, %eax
callq 0x13f8e
movb (%r14), %al
cmpb %al, (%r13)
jne 0x1decb
movq 0x8(%rbx), %rcx
incq %r13
cmpq %rcx, %r13
jae 0x1decb
movb 0x3(%rbp), %dl
movl $0x1, %esi
movb (%r13), %dil
cmpb %dl, %dil
jne 0x1deb6
decl %esi
jne 0x1dec3
jmp 0x1df4f
xorl %r8d, %r8d
cmpb %al, %dil
sete %r8b
addl %r8d, %esi
incq %r13
cmpq %rcx, %r13
jne 0x1dea4
xorl %r15d, %r15d
testq %r15, %r15
je 0x1dfc7
addq $0x4, %rbp
jmp 0x1de42
cmpb $0x5b, 0x2(%rbp)
je 0x1def8
movq 0x18(%rbx), %rdi
leaq 0x55f9(%rip), %rsi      # 0x234ea
xorl %eax, %eax
callq 0x13f8e
addq $0x2, %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1e106
movq %rax, %r14
cmpq (%rbx), %r13
je 0x1df16
movzbl -0x1(%r13), %edi
jmp 0x1df18
xorl %edi, %edi
leaq -0x1(%r14), %r15
movq %rbp, %rsi
movq %r15, %rdx
callq 0x1e194
testl %eax, %eax
je 0x1df35
xorl %eax, %eax
xorl %r13d, %r13d
jmp 0x1de12
movzbl (%r13), %edi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x1e194
testl %eax, %eax
jne 0x1de0d
jmp 0x1df2b
incq %r13
movq %r13, %r15
jmp 0x1dece
movq %r13, %r15
incl 0x20(%rbx)
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x29, 0x1(%rbp)
jne 0x1e01c
addq $0x2, %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
jmp 0x1e02d
incq %rbp
movzbl 0x24(%rbx), %eax
movl %eax, %ecx
shll $0x4, %ecx
addq %rbx, %rcx
addq $0x20, %rcx
testq %rax, %rax
jle 0x1dfcc
decq %rax
cmpq $-0x1, (%rcx)
leaq -0x10(%rcx), %rcx
jne 0x1dfa6
jmp 0x1dfde
xorl %r15d, %r15d
cmpq 0x8(%rbx), %r13
cmoveq %r13, %r15
jmp 0x1df5d
xorl %r15d, %r15d
jmp 0x1df5d
movq 0x18(%rbx), %rdi
leaq 0x5548(%rip), %rsi      # 0x2351f
xorl %eax, %eax
callq 0x13f8e
movslq %eax, %r14
shlq $0x4, %r14
movq %r13, %rax
subq (%r12,%r14), %rax
movq %rax, 0x8(%r12,%r14)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1dbdd
movq %rax, %r15
testq %rax, %rax
jne 0x1df5d
addq %r14, %r12
movq $-0x1, 0x8(%r12)
jmp 0x1df5d
incq %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x1e09c
movq %rax, %r15
jmp 0x1df5d