// File: /workspace/github_c_makefile_star2_O2/orangeduck[P]mpc/mpc.c
// Function: mpc_re_mode
mpc_parser_t *mpc_re_mode(const char *re, int mode) {

  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_to(mpc_escape(), mpcf_re_escape, &mode),
    mpc_apply_to(mpc_noneof(")|"), mpcf_re_escape, &mode)
  ));

  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 0x1c(%rsp), %rax
movl %esi, (%rax)
leaq 0x4ada(%rip), %rdi      # 0xc564
callq 0x40c0
movq %rax, %rbx
leaq 0x4ad9(%rip), %rdi      # 0xc572
callq 0x40c0
movq %rax, %r14
movq %rax, 0x30(%rsp)
leaq 0x4aca(%rip), %rdi      # 0xc577
callq 0x40c0
movq %rax, %r13
leaq 0x4ac2(%rip), %rdi      # 0xc57e
callq 0x40c0
movq %rax, 0x10(%rsp)
leaq 0x4ab6(%rip), %rdi      # 0xc583
callq 0x40c0
movq %rax, 0x38(%rsp)
pushq $0x7c
popq %rdi
callq 0x45b0
movq 0x942a(%rip), %rsi      # 0x10f10
movq 0x9433(%rip), %rbp      # 0x10f20
pushq $0x2
popq %r12
movl %r12d, %edi
movq %rax, %rdx
movq %rbx, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x41d0
movq %rax, %rdi
callq 0x47d0
leaq 0x295(%rip), %rsi       # 0x7da8
movq 0x9456(%rip), %r8       # 0x10f70
movl %r12d, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x41d0
movq %rbx, %rdi
movq %rbx, 0x20(%rsp)
movq %rax, %rsi
callq 0x40f0
leaq 0x284(%rip), %rdi       # 0x7dc5
movq %r13, %rsi
movq %r13, 0x28(%rsp)
callq 0x4290
movq %r14, %rdi
movq %rax, %rsi
callq 0x40f0
pushq $0x2a
popq %rdi
callq 0x45b0
movq %rax, %r14
pushq $0x2b
popq %rdi
callq 0x45b0
movq %rax, %r15
pushq $0x3f
popq %rdi
callq 0x45b0
movq %rax, %r12
callq 0x4340
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4060
movq %rax, %rbp
callq 0x4560
pushq $0x5
popq %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %rbp, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x47c0
leaq 0x27c(%rip), %rsi       # 0x7e2e
pushq $0x2
popq %rdi
movq 0x10(%rsp), %rdx
movq %rax, %rcx
movq 0x93ac(%rip), %r14      # 0x10f70
movq %r14, %r8
xorl %eax, %eax
callq 0x41d0
movq %r13, %rdi
movq %rax, %rsi
callq 0x40f0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4780
movq %rax, %rbp
movq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4540
movq %rax, %r14
callq 0x4520
leaq 0x2c6(%rip), %rbx       # 0x7ecc
movq %rax, %rdi
movq %rbx, %rsi
leaq 0x1c(%rsp), %r13
movq %r13, %rdx
callq 0x44d0
movq %rax, %r12
leaq 0x4966(%rip), %rdi      # 0xc589
callq 0x4230
movq %rax, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x44d0
pushq $0x4
popq %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq 0x28(%rsp), %r12
movq 0x30(%rsp), %r13
movq %rax, %r8
xorl %eax, %eax
callq 0x47c0
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %rax, %rsi
callq 0x40f0
callq 0x4520
movq %rax, %r14
leaq 0x4b5b(%rip), %rdi      # 0xc7d0
callq 0x4230
pushq $0x2
popq %rdi
movq %r14, %rsi
movq %rbp, %r14
movq %rax, %rdx
xorl %eax, %eax
callq 0x47c0
movq 0x932c(%rip), %rdi      # 0x10fc0
movq %rax, %rsi
callq 0x4290
leaq 0x505(%rip), %rsi       # 0x81a8
movq %rax, %rdi
callq 0x4250
movq %r15, %rdi
movq %rax, %rsi
callq 0x40f0
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x40d0
movq %rax, %rdi
movq 0x92a3(%rip), %rsi      # 0x10f70
callq 0x4050
movq %rax, %rbp
movq %rax, %rdi
callq 0x4530
movq %rbx, %rdi
callq 0x4530
movq %r13, %rbx
movq %r13, %rdi
callq 0x4530
movq %r12, %r13
movq %r12, %rdi
callq 0x4530
movq %r14, %rdi
callq 0x4530
movq %r15, %rdi
callq 0x4530
leaq 0x487a(%rip), %rdi      # 0xc58c
leaq 0x8(%rsp), %rcx
movq 0x40(%rsp), %rsi
movq %rbp, %rdx
callq 0x4860
testl %eax, %eax
jne 0x7d6b
movq 0x8(%rsp), %rdi
callq 0x44e0
movq %rax, %r14
leaq 0x4862(%rip), %rdi      # 0xc59e
movq %rax, %rsi
xorl %eax, %eax
callq 0x4360
movq %r15, %r12
movq %rax, %r15
movq 0x8(%rsp), %rdi
callq 0x4580
movq %r14, %rdi
movq 0x10(%rsp), %r14
callq 0x4880
movq %r15, 0x8(%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 0x4720
movq 0x8(%rsp), %rdi
callq 0x4530
movq 0x8(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq