// File: /workspace/github_c_makefile_star2_O2/voithos[P]awl/src/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);
  
  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_delete(RegexEnclose);
  mpc_cleanup(5, Regex, Term, Factor, Base, Range);
  
  return r.output;
  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, 0x18(%rsp)
leaq 0x72bf(%rip), %rdi      # 0x10d55
callq 0x86eb
movq %rax, %rbx
leaq 0x72be(%rip), %rdi      # 0x10d63
callq 0x86eb
movq %rax, %r14
leaq 0x72b4(%rip), %rdi      # 0x10d68
callq 0x86eb
movq %rax, %rbp
leaq 0x72ac(%rip), %rdi      # 0x10d6f
callq 0x86eb
movq %rax, (%rsp)
leaq 0x72a1(%rip), %rdi      # 0x10d74
callq 0x86eb
movq %rax, 0x10(%rsp)
pushq $0x7c
popq %rdi
callq 0x8b6a
leaq -0x170(%rip), %rsi      # 0x997c
movq 0xf4bd(%rip), %r15      # 0x18fb0
pushq $0x2
popq %r12
movl %r12d, %edi
movq %rax, %rdx
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x8f05
movq %rax, %rdi
callq 0x8d89
leaq 0x242(%rip), %rsi       # 0x9d5b
leaq -0x152f(%rip), %r8      # 0x85f1
movl %r12d, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x8f05
movq %rbx, %rdi
movq %rax, %rsi
callq 0x874e
leaq 0x236(%rip), %rdi       # 0x9d78
movq %rbp, %rsi
callq 0x8d95
movq %r14, 0x28(%rsp)
movq %r14, %rdi
movq %rax, %rsi
callq 0x874e
pushq $0x2a
popq %rdi
callq 0x8b6a
movq %rax, %r12
pushq $0x2b
popq %rdi
callq 0x8b6a
movq %rax, %r14
pushq $0x3f
popq %rdi
callq 0x8b6a
movq %rax, %r13
callq 0x935c
movq %rax, %rdi
movq %r15, %rsi
callq 0x99aa
movq %rax, %r15
callq 0x89a4
pushq $0x5
popq %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r15, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x8e10
leaq 0x22e(%rip), %rsi       # 0x9de1
pushq $0x2
popq %rdi
movq (%rsp), %r15
movq %r15, %rdx
movq %rax, %rcx
leaq -0x15d6(%rip), %r14     # 0x85f1
movq %r14, %r8
xorl %eax, %eax
callq 0x8f05
movq %rbp, 0x20(%rsp)
movq %rbp, %rdi
movq %r15, %rbp
movq %rbx, 0x8(%rsp)
movq %rax, %rsi
callq 0x874e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9984
movq %rax, %r15
movq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x99bd
movq %rax, %r14
callq 0x91b4
leaq 0x27b(%rip), %rbx       # 0x9e91
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8ccf
movq %rax, %r13
leaq 0x714f(%rip), %rdi      # 0x10d7a
callq 0x8c0d
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8ccf
pushq $0x4
popq %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x8e10
movq %rbp, %rdi
movq %rax, %rsi
callq 0x874e
callq 0x91b4
movq %rax, %r14
leaq 0x72e3(%rip), %rdi      # 0x10f4e
callq 0x8c0d
pushq $0x2
popq %rdi
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x8e10
leaq -0xbb4(%rip), %rdi      # 0x90d3
movq %rax, %rsi
callq 0x8d95
leaq 0x3ae(%rip), %rsi       # 0xa044
movq %rax, %rdi
callq 0x8ccf
movq %r12, %rdi
movq %rax, %rsi
callq 0x874e
movq 0x8(%rsp), %rdi
movq %rdi, %rbx
callq 0x8d1b
movq %rax, %rdi
leaq -0x16cf(%rip), %rsi     # 0x85f1
callq 0x9854
movq %rax, %r14
leaq 0x70ae(%rip), %rdi      # 0x10d7d
leaq 0x30(%rsp), %r15
movq 0x18(%rsp), %rsi
movq %rax, %rdx
movq %r15, %rcx
callq 0x833f
movq (%r15), %r15
testl %eax, %eax
jne 0x9d23
movq %r15, %rdi
callq 0x6e6f
movq %r12, %rbp
movq %rax, %r12
leaq 0x708f(%rip), %rdi      # 0x10d8f
movq %rax, %rsi
xorl %eax, %eax
callq 0x87b7
movq %rax, %r13
movq %r15, %rdi
callq 0x6dec
movq %r12, %rdi
movq %rbp, %r12
callq 0x23f0
movq %r13, %r15
movq %r14, %rdi
callq 0x85f1
pushq $0x5
popq %rdi
movq %rbx, %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq (%rsp), %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x8892
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq