// File: /workspace/github_c_makefile_star2_O2/mattn[P]orelang/mpc.c
// Function: mpc_re
mpc_parser_t *mpc_re(const char *re) {
  
  char *err_msg;
  mpc_parser_t *err_out;
  mpc_result_t r;
  mpc_parser_t *Regex, *Term, *Factor, *Base, *Range, *RegexEnclose; 
  
  Regex  = mpc_new("regex");
  Term   = mpc_new("term");
  Factor = mpc_new("factor");
  Base   = mpc_new("base");
  Range  = mpc_new("range");
  
  mpc_define(Regex, mpc_and(2, mpcf_re_or,
    Term, 
    mpc_maybe(mpc_and(2, mpcf_snd_free, mpc_char('|'), Regex, free)),
    (mpc_dtor_t)mpc_delete
  ));
  
  mpc_define(Term, mpc_many(mpcf_re_and, Factor));
  
  mpc_define(Factor, mpc_and(2, mpcf_re_repeat,
    Base,
    mpc_or(5,
      mpc_char('*'), mpc_char('+'), mpc_char('?'),
      mpc_brackets(mpc_int(), free),
      mpc_pass()),
    (mpc_dtor_t)mpc_delete
  ));
  
  mpc_define(Base, mpc_or(4,
    mpc_parens(Regex, (mpc_dtor_t)mpc_delete),
    mpc_squares(Range, (mpc_dtor_t)mpc_delete),
    mpc_apply(mpc_escape(), mpcf_re_escape),
    mpc_apply(mpc_noneof(")|"), mpcf_re_escape)
  ));
  
  mpc_define(Range, mpc_apply(
    mpc_many(mpcf_strfold, mpc_or(2, mpc_escape(), mpc_noneof("]"))),
    mpcf_re_range
  ));
  
  RegexEnclose = mpc_whole(mpc_predictive(Regex), (mpc_dtor_t)mpc_delete);
  
  mpc_optimise(RegexEnclose);
  mpc_optimise(Regex);
  mpc_optimise(Term);
  mpc_optimise(Factor);
  mpc_optimise(Base);
  mpc_optimise(Range);
  
  if(!mpc_parse("<mpc_re_compiler>", re, RegexEnclose, &r)) {
    err_msg = mpc_err_string(r.error);
    err_out = mpc_failf("Invalid Regex: %s", err_msg);
    mpc_err_delete(r.error);  
    free(err_msg);
    r.output = err_out;
  }
  
  mpc_cleanup(6, RegexEnclose, Regex, Term, Factor, Base, Range);
  
  mpc_optimise(r.output);
  
  return r.output;
  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
leaq 0xb567(%rip), %rdi      # 0x104fd
callq 0x395e
movq %rax, %rbx
leaq 0xb566(%rip), %rdi      # 0x1050b
callq 0x395e
movq %rax, %r14
movq %rax, 0x30(%rsp)
leaq 0xb557(%rip), %rdi      # 0x10510
callq 0x395e
movq %rax, %r13
leaq 0xb54f(%rip), %rdi      # 0x10517
callq 0x395e
movq %rax, 0x18(%rsp)
leaq 0xb543(%rip), %rdi      # 0x1051c
callq 0x395e
movq %rax, 0x38(%rsp)
pushq $0x7c
popq %rdi
callq 0x3faf
leaq -0x176(%rip), %rsi      # 0x4e7c
movq 0x12fb7(%rip), %rbp     # 0x17fb0
pushq $0x2
popq %r12
movl %r12d, %edi
movq %rax, %rdx
movq %rbx, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x434a
movq %rax, %rdi
callq 0x41ce
leaq 0x288(%rip), %rsi       # 0x52a7
leaq -0x17c2(%rip), %r8      # 0x3864
movl %r12d, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x434a
movq %rbx, %rdi
movq %rbx, 0x20(%rsp)
movq %rax, %rsi
callq 0x3b7e
leaq 0x277(%rip), %rdi       # 0x52c4
movq %r13, %rsi
movq %r13, 0x28(%rsp)
callq 0x41da
movq %r14, %rdi
movq %rax, %rsi
callq 0x3b7e
pushq $0x2a
popq %rdi
callq 0x3faf
movq %rax, %r14
pushq $0x2b
popq %rdi
callq 0x3faf
movq %rax, %r15
pushq $0x3f
popq %rdi
callq 0x3faf
movq %rax, %r12
callq 0x485c
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4eaa
movq %rax, %rbp
callq 0x3dd4
pushq $0x5
popq %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %rbp, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x4255
leaq 0x26f(%rip), %rsi       # 0x532d
pushq $0x2
popq %rdi
movq 0x18(%rsp), %rbp
movq %rbp, %rdx
movq %rax, %rcx
leaq -0x186f(%rip), %r14     # 0x3864
movq %r14, %r8
xorl %eax, %eax
callq 0x434a
movq %r13, %rdi
movq %rax, %rsi
callq 0x3b7e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4e84
movq %rax, %r13
movq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4ebd
movq %rax, %r14
callq 0x46b4
leaq 0x2c8(%rip), %rbx       # 0x53dd
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4114
movq %rax, %r12
leaq 0xb3f8(%rip), %rdi      # 0x10522
callq 0x4052
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4114
pushq $0x4
popq %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq 0x28(%rsp), %r12
movq 0x30(%rsp), %r13
movq %rax, %r8
xorl %eax, %eax
callq 0x4255
movq %rbp, %rdi
movq %rax, %rsi
callq 0x3b7e
callq 0x46b4
movq %rax, %r14
leaq 0xb5b3(%rip), %rdi      # 0x10727
callq 0x4052
pushq $0x2
popq %rdi
movq %r14, %rsi
movq %rbp, %r14
movq %rax, %rdx
xorl %eax, %eax
callq 0x4255
leaq -0xbc7(%rip), %rdi      # 0x45cc
movq %rax, %rsi
callq 0x41da
leaq 0x3ee(%rip), %rsi       # 0x5590
movq %rax, %rdi
callq 0x4114
movq %r15, %rdi
movq %rax, %rsi
callq 0x3b7e
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x4160
movq %rax, %rdi
leaq -0x1968(%rip), %rsi     # 0x3864
callq 0x4d54
movq %rax, %rbp
movq %rax, %rdi
callq 0x57da
movq %rbx, %rdi
callq 0x57da
movq %r13, %rbx
movq %r13, %rdi
callq 0x57da
movq %r12, %r13
movq %r12, %rdi
callq 0x57da
movq %r14, %rdi
callq 0x57da
movq %r15, %rdi
callq 0x57da
leaq 0xb314(%rip), %rdi      # 0x10525
leaq 0x10(%rsp), %rcx
movq 0x40(%rsp), %rsi
movq %rbp, %rdx
callq 0x34c7
testl %eax, %eax
jne 0x526a
movq 0x10(%rsp), %rdi
callq 0x243f
movq %rax, %r14
leaq 0xb2fc(%rip), %rdi      # 0x10537
movq %rax, %rsi
xorl %eax, %eax
callq 0x3be7
movq %r15, %r12
movq %rax, %r15
movq 0x10(%rsp), %rdi
callq 0x23bc
movq %r14, %rdi
movq 0x18(%rsp), %r14
callq 0x22c0
movq %r15, 0x10(%rsp)
movq %r12, %r15
movq %r15, (%rsp)
pushq $0x6
popq %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rcx
movq %r13, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x3cc2
movq 0x10(%rsp), %rdi
callq 0x57da
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq