// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %rdi, 0x50(%rsp)
leaq 0x1c(%rsp), %rax
movl %esi, (%rax)
leaq 0x6276(%rip), %rdi      # 0xe544
callq 0x40a0
movq %rax, %r13
leaq 0x6275(%rip), %rdi      # 0xe552
callq 0x40a0
movq %rax, %r15
leaq 0x626b(%rip), %rdi      # 0xe557
callq 0x40a0
movq %rax, %r12
leaq 0x6263(%rip), %rdi      # 0xe55e
callq 0x40a0
movq %rax, %rbx
movq %rax, 0x48(%rsp)
leaq 0x6254(%rip), %rdi      # 0xe563
callq 0x40a0
movq %rax, 0x20(%rsp)
movl $0x7c, %edi
callq 0x43b0
movq 0xabe6(%rip), %rsi      # 0x12f10
movq 0xabef(%rip), %r8       # 0x12f20
xorl %ebp, %ebp
movl $0x2, %edi
movq %rax, %rdx
movq %r13, %rcx
movq %r13, 0x10(%rsp)
xorl %eax, %eax
callq 0x4130
movq %rax, %r14
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rbp, (%rax)
xorl %ebp, %ebp
movw $0x13, 0x30(%rax)
movq %r14, 0x8(%rax)
movq 0xac26(%rip), %rcx      # 0x12f98
movq %rcx, 0x18(%rax)
leaq 0x3be(%rip), %rsi       # 0x873b
movq 0xabec(%rip), %r8       # 0x12f70
movl $0x2, %edi
movq %r15, 0x30(%rsp)
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x4130
movq %r13, %rdi
movq %rax, %rsi
callq 0x40c0
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rbp, (%rax)
movw $0x14, %cx
movw %cx, 0x30(%rax)
movq %r12, 0x18(%rax)
movq %r12, %r13
movq %r12, 0x28(%rsp)
leaq 0x387(%rip), %rcx       # 0x875a
movq %rcx, 0x10(%rax)
movq %r15, %rdi
movq %rax, %rsi
callq 0x40c0
movl $0x2a, %edi
callq 0x43b0
movq %rax, %r14
movl $0x2b, %edi
callq 0x43b0
movq %rax, %r15
movl $0x3f, %edi
callq 0x43b0
movq %rax, %r12
callq 0x4220
leaq 0x6139(%rip), %rdx      # 0xe54e
leaq 0x63a4(%rip), %rcx      # 0xe7c0
movq %rax, %rdi
movq 0xaafa(%rip), %rsi      # 0x12f20
callq 0x40f0
movq %rax, %rbp
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
xorl %ecx, %ecx
movq %rcx, (%rax)
movw $0x1, 0x30(%rax)
movl $0x5, %edi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %rbp, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x4500
leaq 0x36f(%rip), %rsi       # 0x87d9
movl $0x2, %edi
movq %rbx, %rdx
movq %rax, %rcx
movq 0xaaf4(%rip), %rbx      # 0x12f70
movq %rbx, %r8
xorl %eax, %eax
callq 0x4130
movq %r13, %rdi
movq %rax, %rsi
callq 0x40c0
leaq 0x632b(%rip), %rdx      # 0xe7c3
leaq 0x60ab(%rip), %rcx      # 0xe54a
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x40f0
movq %rax, 0x40(%rsp)
leaq 0x6098(%rip), %rdx      # 0xe550
leaq 0x62f1(%rip), %rcx      # 0xe7b0
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x40f0
movq %rax, 0x38(%rsp)
callq 0x4360
movq %rax, %r12
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r13
xorl %r15d, %r15d
movq %r15, (%rax)
movw $0x10, %bp
movw %bp, 0x30(%rax)
movq %r12, 0x8(%rax)
leaq 0x3db(%rip), %rbx       # 0x88df
movq %rbx, 0x10(%rax)
leaq 0x1c(%rsp), %r14
movq %r14, 0x18(%rax)
leaq 0x6051(%rip), %rdi      # 0xe569
callq 0x4190
movq %rax, %r12
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %r15, (%rax)
movw %bp, 0x30(%rax)
movq %r12, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq 0x10(%rsp), %r12
movq %r14, 0x18(%rax)
movl $0x4, %edi
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r13, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x4500
movq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x40c0
callq 0x4360
movq %rax, %r14
leaq 0x622e(%rip), %rdi      # 0xe7b0
callq 0x4190
movl $0x2, %edi
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4500
movq %rax, %r14
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r15
xorl %ebp, %ebp
movq %rbp, (%rax)
movw $0x14, %ax
movw %ax, 0x30(%r15)
movq %r14, 0x18(%r15)
movq 0xa9f9(%rip), %rax      # 0x12fc0
movq %rax, 0x10(%r15)
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rbp, (%rax)
xorl %ebp, %ebp
movw $0xf, 0x30(%rax)
movq %r15, 0x8(%rax)
leaq 0x7bc(%rip), %rcx       # 0x8dac
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x40c0
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rbp, (%rax)
movw $0x11, 0x30(%rax)
movq %r12, 0x8(%rax)
movq %rax, %rdi
movq 0xa946(%rip), %rsi      # 0x12f70
callq 0x4040
movq %rax, %rbp
movq %rax, %rdi
movl $0x1, %esi
callq 0xc0b6
movq %r12, %rdi
movl $0x1, %esi
callq 0xc0b6
movq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0xc0b6
movq 0x28(%rsp), %rdi
movl $0x1, %esi
callq 0xc0b6
movq %rbx, %r12
movq %rbx, %rdi
movl $0x1, %esi
callq 0xc0b6
movq %r13, %rdi
movl $0x1, %esi
callq 0xc0b6
leaq 0x5ede(%rip), %rdi      # 0xe56c
movq 0x50(%rsp), %rsi
callq 0x5bc4
movq %rax, %r14
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4090
movl %eax, %r15d
movq %r14, %rdi
callq 0x5c86
testl %r15d, %r15d
jne 0x86f3
movq 0x8(%rsp), %rdi
callq 0x4320
movq %rax, %r14
leaq 0x5eaf(%rip), %rdi      # 0xe57e
movq %rax, %rsi
xorl %eax, %eax
callq 0x4240
movq %rax, %r15
movq 0x8(%rsp), %rdi
callq 0x4380
movq %r14, %rdi
callq 0x4580
movq %r15, 0x8(%rsp)
movq %r13, (%rsp)
movl $0x6, %edi
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x44b0
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0xc0b6
movq 0x8(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq