// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/lua-5.1.5/src/lstrlib.c
// Function: match
static const char *match (MatchState *ms, const char *s, const char *p) {
  init: /* using goto's to optimize tail recursion */
  switch (*p) {
    case '(': {  /* start capture */
      if (*(p+1) == ')')  /* position capture? */
        return start_capture(ms, s, p+2, CAP_POSITION);
      else
        return start_capture(ms, s, p+1, CAP_UNFINISHED);
    }
    case ')': {  /* end capture */
      return end_capture(ms, s, p+1);
    }
    case L_ESC: {
      switch (*(p+1)) {
        case 'b': {  /* balanced string? */
          s = matchbalance(ms, s, p+2);
          if (s == NULL) return NULL;
          p+=4; goto init;  /* else return match(ms, s, p+4); */
        }
        case 'f': {  /* frontier? */
          const char *ep; char previous;
          p += 2;
          if (*p != '[')
            luaL_error(ms->L, "missing " LUA_QL("[") " after "
                               LUA_QL("%%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)) return NULL;
          p=ep; goto init;  /* else return match(ms, s, ep); */
        }
        default: {
          if (isdigit(uchar(*(p+1)))) {  /* capture results (%0-%9)? */
            s = match_capture(ms, s, uchar(*(p+1)));
            if (s == NULL) return NULL;
            p+=2; goto init;  /* else return match(ms, s, p+2) */
          }
          goto dflt;  /* case default */
        }
      }
    }
    case '\0': {  /* end of pattern */
      return s;  /* match succeeded */
    }
    case '$': {
      if (*(p+1) == '\0')  /* is the `$' the last char in pattern? */
        return (s == ms->src_end) ? s : NULL;  /* check end of string */
      else goto dflt;
    }
    default: dflt: {  /* it is a pattern item */
      const char *ep = classend(ms, p);  /* points to what is next */
      int m = s<ms->src_end && singlematch(uchar(*s), p, ep);
      switch (*ep) {
        case '?': {  /* optional */
          const char *res;
          if (m && ((res=match(ms, s+1, ep+1)) != NULL))
            return res;
          p=ep+1; goto init;  /* else return match(ms, s, ep+1); */
        }
        case '*': {  /* 0 or more repetitions */
          return max_expand(ms, s, p, ep);
        }
        case '+': {  /* 1 or more repetitions */
          return (m ? max_expand(ms, s+1, p, ep) : NULL);
        }
        case '-': {  /* 0 or more repetitions (minimum) */
          return min_expand(ms, s, p, ep);
        }
        default: {
          if (!m) return NULL;
          s++; p=ep; goto init;  /* else return match(ms, s+1, ep); */
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x20(%rdi), %r13
movq %r13, 0x10(%rsp)
movzbl (%r15), %eax
cmpl $0x25, %eax
jne 0x6d54d
movzbl 0x1(%r15), %r14d
cmpq $0x66, %r14
jne 0x6d58a
cmpb $0x5b, 0x2(%r15)
jne 0x6d8a6
addq $0x2, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d97e
movq %rax, %r14
cmpq (%rbx), %r12
je 0x6d4fe
movzbl -0x1(%r12), %edi
jmp 0x6d500
xorl %edi, %edi
leaq -0x1(%r14), %rbp
movq %r15, %rsi
movq %rbp, %rdx
callq 0x6d9f1
movb $0x1, %r13b
testl %eax, %eax
je 0x6d520
movq $0x0, (%rsp)
jmp 0x6d53a
movzbl (%r12), %edi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x6d9f1
testl %eax, %eax
je 0x6d516
xorl %r13d, %r13d
movq %r14, %r15
testb %r13b, %r13b
movq 0x10(%rsp), %r13
je 0x6d4b8
jmp 0x6d82d
cmpl $0x27, %eax
jg 0x6d573
testl %eax, %eax
je 0x6d7c8
cmpl $0x24, %eax
jne 0x6d60f
cmpb $0x0, 0x1(%r15)
jne 0x6d60f
jmp 0x6d889
cmpl $0x29, %eax
je 0x6d7ce
cmpl $0x28, %eax
je 0x6d840
jmp 0x6d60f
cmpl $0x62, %r14d
jne 0x6d5fb
movb 0x2(%r15), %al
testb %al, %al
je 0x6d8b8
movb 0x3(%r15), %cl
testb %cl, %cl
je 0x6d8b8
cmpb %al, (%r12)
jne 0x6d5e6
movq 0x8(%rbx), %rdx
incq %r12
cmpq %rdx, %r12
jae 0x6d5e6
movl $0x1, %esi
movb (%r12), %dil
cmpb %cl, %dil
jne 0x6d5d1
decl %esi
jne 0x6d5de
jmp 0x6d7c0
xorl %r8d, %r8d
cmpb %al, %dil
sete %r8b
addl %r8d, %esi
incq %r12
cmpq %rdx, %r12
jne 0x6d5bf
xorl %r12d, %r12d
testq %r12, %r12
je 0x6d87f
addq $0x4, %r15
jmp 0x6d4b8
callq 0xb6e0
movq (%rax), %rax
testb $0x8, 0x1(%rax,%r14,2)
jne 0x6d72d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d97e
movq %rax, %r14
cmpq 0x8(%rbx), %r12
jae 0x6d63a
movzbl (%r12), %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6da82
testl %eax, %eax
setne %al
jmp 0x6d63c
xorl %eax, %eax
movzbl (%r14), %ecx
cmpl $0x2c, %ecx
jg 0x6d67a
cmpl $0x2a, %ecx
je 0x6d6f0
cmpl $0x2b, %ecx
jne 0x6d6e3
movb $0x1, %bpl
testb %al, %al
je 0x6d779
leaq 0x1(%r12), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x6dab3
jmp 0x6d727
cmpl $0x3f, %ecx
je 0x6d70a
cmpl $0x2d, %ecx
jne 0x6d6e3
movq %r14, 0x8(%rsp)
movq %r14, %rbp
incq %rbp
movq %r12, %r14
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x6d498
testq %rax, %rax
je 0x6d6b1
xorl %ecx, %ecx
movq %rax, (%rsp)
jmp 0x6d6dd
cmpq 0x8(%rbx), %r14
jae 0x6d6d3
movzbl (%r14), %edi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
callq 0x6da82
testl %eax, %eax
je 0x6d6d3
incq %r14
movb $0x1, %cl
jmp 0x6d6dd
movq $0x0, (%rsp)
xorl %ecx, %ecx
testb %cl, %cl
jne 0x6d696
jmp 0x6d705
testb %al, %al
je 0x6d776
incq %r12
jmp 0x6d76f
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x6dab3
movq %rax, (%rsp)
movb $0x1, %bpl
jmp 0x6d781
testb %al, %al
je 0x6d76c
leaq 0x1(%r12), %rsi
leaq 0x1(%r14), %rdx
movq %rbx, %rdi
callq 0x6d498
testq %rax, %rax
je 0x6d76c
movb $0x1, %bpl
movq %rax, (%rsp)
jmp 0x6d781
cmpb $0x31, %r14b
jb 0x6d8c5
leal -0x31(%r14), %eax
cmpl 0x18(%rbx), %eax
jge 0x6d8c5
movl %eax, %eax
shlq $0x4, %rax
cmpq $-0x1, 0x8(%r13,%rax)
je 0x6d8c5
movq 0x8(%r13,%rax), %r14
movq 0x8(%rbx), %rcx
subq %r12, %rcx
cmpq %r14, %rcx
jae 0x6d78f
xorl %r12d, %r12d
jmp 0x6d7ae
incq %r14
xorl %ebp, %ebp
movq %r14, %r15
jmp 0x6d781
movb $0x1, %bpl
movq $0x0, (%rsp)
testb %bpl, %bpl
je 0x6d4b8
jmp 0x6d82d
addq %r13, %rax
movq (%rax), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xb6b0
addq %r14, %r12
testl %eax, %eax
movl $0x0, %eax
cmovneq %rax, %r12
testq %r12, %r12
je 0x6d87f
addq $0x2, %r15
jmp 0x6d4b8
incq %r12
jmp 0x6d5e9
movq %r12, (%rsp)
jmp 0x6d82d
incq %r15
movl 0x18(%rbx), %eax
movq %rax, %rcx
shlq $0x4, %rcx
addq %rbx, %rcx
addq $0x18, %rcx
testl %eax, %eax
jle 0x6d899
decq %rax
cmpq $-0x1, (%rcx)
leaq -0x10(%rcx), %rcx
jne 0x6d7e2
movl %eax, %r14d
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 0x6d498
movq %rax, (%rsp)
testq %rax, %rax
jne 0x6d82d
addq %r14, %r13
movq $-0x1, 0x8(%r13)
movq (%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x29, 0x1(%r15)
jne 0x6d85b
addq $0x2, %r15
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
jmp 0x6d86c
incq %r15
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6d933
movq $0x0, (%rsp)
jmp 0x6d82d
xorl %eax, %eax
cmpq 0x8(%rbx), %r12
cmoveq %r12, %rax
movq %rax, (%rsp)
jmp 0x6d82d
movq 0x10(%rbx), %rdi
leaq 0x814f7(%rip), %rsi     # 0xeed9b
jmp 0x6d8b1
movq 0x10(%rbx), %rdi
leaq 0x814b5(%rip), %rsi     # 0xeed66
xorl %eax, %eax
callq 0x5af61
movq 0x10(%rbx), %rdi
leaq 0x814f0(%rip), %rsi     # 0xeedb3
jmp 0x6d8b1
movq 0x10(%rbx), %rdi
leaq 0x81539(%rip), %rsi     # 0xeee09
jmp 0x6d8b1