// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/deps/lua/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
pushq %rax
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x20(%rdi), %rax
movq %rax, (%rsp)
leaq 0x1(%r14), %r15
movq %r13, %r12
movzbl (%r12), %eax
leal -0x24(%rax), %ecx
cmpl $0x5, %ecx
ja 0x17a46
leaq 0x32f6(%rip), %rdx      # 0x1ac98
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movzbl 0x1(%r12), %r13d
cmpq $0x66, %r13
jne 0x17a27
cmpb $0x5b, 0x2(%r12)
je 0x179d1
movq 0x10(%rbx), %rdi
leaq 0x33a8(%rip), %rsi      # 0x1ad72
xorl %eax, %eax
callq 0xf48b
addq $0x2, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x17dec
movq %rax, %r13
cmpq (%rbx), %r14
je 0x179ef
movzbl -0x1(%r14), %edi
jmp 0x179f1
xorl %edi, %edi
leaq -0x1(%r13), %rbp
movq %r12, %rsi
movq %rbp, %rdx
callq 0x17e84
testl %eax, %eax
jne 0x17c6c
movzbl (%r14), %edi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x17e84
movq %r13, %r12
testl %eax, %eax
jne 0x1798a
jmp 0x17c6c
cmpl $0x62, %r13d
je 0x17aba
callq 0x4570
movq (%rax), %rax
testb $0x8, 0x1(%rax,%r13,2)
je 0x17a5c
jmp 0x17b5d
testl %eax, %eax
je 0x17c26
jmp 0x17a5c
cmpb $0x0, 0x1(%r12)
je 0x17d01
movq %rbx, %rdi
movq %r12, %rsi
callq 0x17dec
movq %rax, %r13
cmpq 0x8(%rbx), %r14
jae 0x17a86
movzbl (%r14), %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x17f05
testl %eax, %eax
setne %al
jmp 0x17a88
xorl %eax, %eax
movzbl (%r13), %ecx
cmpl $0x3f, %ecx
jne 0x17b20
testb %al, %al
je 0x17ab2
leaq 0x1(%r13), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x17967
testq %rax, %rax
jne 0x17c6e
incq %r13
jmp 0x17987
movb 0x2(%r12), %al
testb %al, %al
je 0x17acb
cmpb $0x0, 0x3(%r12)
jne 0x17ae2
movq 0x10(%rbx), %rdi
leaq 0x32e9(%rip), %rsi      # 0x1adbf
xorl %eax, %eax
callq 0xf48b
movb 0x2(%r12), %al
cmpb %al, (%r14)
jne 0x17c6c
movb 0x3(%r12), %cl
movq 0x8(%rbx), %rdx
pushq $0x1
popq %rsi
cmpq %rdx, %r15
jae 0x17c6c
movb (%r15), %dil
cmpb %cl, %dil
jne 0x17b0e
decl %esi
jne 0x17b1b
jmp 0x17b4b
xorl %r8d, %r8d
cmpb %al, %dil
sete %r8b
addl %r8d, %esi
incq %r15
jmp 0x17af7
cmpl $0x2a, %ecx
je 0x17ce2
cmpl $0x2b, %ecx
je 0x17cdb
cmpl $0x2d, %ecx
je 0x17c9f
testb %al, %al
je 0x17c6c
incq %r14
jmp 0x17983
incq %r15
addq $0x4, %r12
movq %r12, %r13
movq %r15, %r14
jmp 0x17983
cmpb $0x31, %r13b
jb 0x17b7e
leal -0x31(%r13), %eax
cmpl 0x18(%rbx), %eax
jge 0x17b7e
movl %eax, %ecx
shlq $0x4, %rcx
movq (%rsp), %rdx
cmpq $-0x1, 0x8(%rdx,%rcx)
jne 0x17b90
movq 0x10(%rbx), %rdi
leaq 0x328c(%rip), %rsi      # 0x1ae15
xorl %eax, %eax
callq 0xf48b
cltq
shlq $0x4, %rax
movq (%rsp), %rdx
movq 0x8(%rdx,%rax), %r15
movq 0x8(%rbx), %rcx
subq %r14, %rcx
cmpq %r15, %rcx
jb 0x17c6c
addq %rdx, %rax
movq (%rax), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4370
testl %eax, %eax
jne 0x17c6c
testq %r14, %r14
movl $0x0, %eax
je 0x17c6e
addq %r15, %r14
addq $0x2, %r12
movq %r12, %r13
jmp 0x17983
cmpb $0x29, 0x1(%r12)
jne 0x17c7d
addq $0x2, %r12
pushq $-0x2
jmp 0x17c82
incq %r12
movl 0x18(%rbx), %eax
movq %rax, %rcx
shlq $0x4, %rcx
addq %rbx, %rcx
addq $0x18, %rcx
movq (%rsp), %r13
testl %eax, %eax
jle 0x17c2b
decl %eax
cmpq $-0x1, (%rcx)
leaq -0x10(%rcx), %rcx
jne 0x17c14
jmp 0x17c3d
movq %r14, %rax
jmp 0x17c6e
movq 0x10(%rbx), %rdi
leaq 0x3171(%rip), %rsi      # 0x1ada7
xorl %eax, %eax
callq 0xf48b
movslq %eax, %r15
shlq $0x4, %r15
movq %r14, %rax
subq (%r13,%r15), %rax
movq %rax, 0x8(%r13,%r15)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x17967
testq %rax, %rax
jne 0x17c6e
addq %r15, %r13
orq $-0x1, 0x8(%r13)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incq %r12
pushq $-0x1
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17d82
movq %r13, %r15
incq %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x17967
testq %rax, %rax
jne 0x17c6e
cmpq 0x8(%rbx), %r14
jae 0x17c6c
movzbl (%r14), %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x17f05
incq %r14
testl %eax, %eax
movl $0x0, %eax
jne 0x17ca5
jmp 0x17c6e
testb %al, %al
je 0x17c6c
incq %r14
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17f34
xorl %eax, %eax
cmpq 0x8(%rbx), %r14
cmoveq %r14, %rax
jmp 0x17c6e