// File: /workspace/github_c_makefile_star2_O2/orangeduck[P]mpc/mpc.c
// Function: mpca_grammar_st
mpc_parser_t *mpca_grammar_st(const char *grammar, mpca_grammar_st_t *st) {

  char *err_msg;
  mpc_parser_t *err_out;
  mpc_result_t r;
  mpc_parser_t *GrammarTotal, *Grammar, *Term, *Factor, *Base;

  GrammarTotal = mpc_new("grammar_total");
  Grammar = mpc_new("grammar");
  Term = mpc_new("term");
  Factor = mpc_new("factor");
  Base = mpc_new("base");

  mpc_define(GrammarTotal,
    mpc_predictive(mpc_total(Grammar, mpc_soft_delete))
  );

  mpc_define(Grammar, mpc_and(2, mpcaf_grammar_or,
    Term,
    mpc_maybe(mpc_and(2, mpcf_snd_free, mpc_sym("|"), Grammar, free)),
    mpc_soft_delete
  ));

  mpc_define(Term, mpc_many1(mpcaf_grammar_and, Factor));

  mpc_define(Factor, mpc_and(2, mpcaf_grammar_repeat,
    Base,
      mpc_or(6,
        mpc_sym("*"),
        mpc_sym("+"),
        mpc_sym("?"),
        mpc_sym("!"),
        mpc_tok_brackets(mpc_int(), free),
        mpc_pass()),
    mpc_soft_delete
  ));

  mpc_define(Base, mpc_or(5,
    mpc_apply_to(mpc_tok(mpc_string_lit()), mpcaf_grammar_string, st),
    mpc_apply_to(mpc_tok(mpc_char_lit()),   mpcaf_grammar_char, st),
    mpc_tok(mpc_and(3, mpcaf_fold_regex, mpc_regex_lit(), mpc_many(mpcf_strfold, mpc_oneof("ms")), mpc_lift_val(st), free, free)),
    mpc_apply_to(mpc_tok_braces(mpc_or(2, mpc_digits(), mpc_ident()), free), mpcaf_grammar_id, st),
    mpc_tok_parens(Grammar, mpc_soft_delete)
  ));

  mpc_optimise(GrammarTotal);
  mpc_optimise(Grammar);
  mpc_optimise(Factor);
  mpc_optimise(Term);
  mpc_optimise(Base);

  if(!mpc_parse("<mpc_grammar_compiler>", grammar, GrammarTotal, &r)) {
    err_msg = mpc_err_string(r.error);
    err_out = mpc_failf("Invalid Grammar: %s", err_msg);
    mpc_err_delete(r.error);
    free(err_msg);
    r.output = err_out;
  }

  mpc_cleanup(5, GrammarTotal, Grammar, Term, Factor, Base);

  mpc_optimise(r.output);

  return (st->flags & MPCA_LANG_PREDICTIVE) ? mpc_predictive(r.output) : r.output;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, 0x38(%rsp)
movq %rdi, 0x50(%rsp)
leaq 0x2c2a(%rip), %rdi      # 0xc5c6
callq 0x40c0
movq %rax, %rbx
movq %rax, 0x48(%rsp)
leaq 0x2c24(%rip), %rdi      # 0xc5d4
callq 0x40c0
movq %rax, %r15
leaq 0x2bb3(%rip), %rdi      # 0xc572
callq 0x40c0
movq %rax, %r14
leaq 0x2ba9(%rip), %rdi      # 0xc577
callq 0x40c0
movq %rax, %r12
leaq 0x2ba1(%rip), %rdi      # 0xc57e
callq 0x40c0
movq %rax, 0x30(%rsp)
leaq 0x34d(%rip), %r13       # 0x9d3b
movq %r15, %rdi
movq %r13, %rsi
callq 0x4670
movq %rax, %rdi
callq 0x40d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x40f0
leaq 0x2b77(%rip), %rdi      # 0xc58a
callq 0x47e0
movq 0x74f1(%rip), %rsi      # 0x10f10
movq 0x74fa(%rip), %r8       # 0x10f20
pushq $0x2
popq %rbx
movl %ebx, %edi
movq %rax, %rdx
movq %r15, %rcx
movq %r15, 0x10(%rsp)
xorl %eax, %eax
callq 0x41d0
movq %rax, %rdi
callq 0x47d0
leaq 0x2f6(%rip), %rsi       # 0x9d42
movl %ebx, %edi
movq %r14, 0x40(%rsp)
movq %r14, %rdx
movq %rax, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x41d0
movq %r15, %rdi
movq %rax, %rsi
callq 0x40f0
leaq 0x2ea(%rip), %rdi       # 0x9d5f
movq %r12, %rsi
movq %r12, %r15
movq %r12, 0x18(%rsp)
callq 0x4260
movq %r14, %rdi
movq %rax, %rsi
callq 0x40f0
leaq 0x2b45(%rip), %rdi      # 0xc5dc
callq 0x47e0
movq %rax, %r14
leaq 0x2b38(%rip), %rdi      # 0xc5de
callq 0x47e0
movq %rax, %r12
leaq 0x2d36(%rip), %rdi      # 0xc7eb
callq 0x47e0
movq %rax, %r13
leaq 0x2d8f(%rip), %rdi      # 0xc853
callq 0x47e0
movq %rax, %rbp
callq 0x4340
movq %rax, %rdi
movq 0x7445(%rip), %rsi      # 0x10f20
callq 0x4410
movq %rax, %rbx
callq 0x4560
movq %rax, (%rsp)
pushq $0x6
popq %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %rbp, %r8
movq 0x38(%rsp), %rbp
movq %rbx, %r9
xorl %eax, %eax
callq 0x47c0
leaq 0x299(%rip), %rsi       # 0x9daa
pushq $0x2
popq %rdi
movq 0x30(%rsp), %r14
movq %r14, %rdx
movq %rax, %rcx
leaq 0x215(%rip), %r8        # 0x9d3b
xorl %eax, %eax
callq 0x41d0
movq %r15, %rdi
movq %rax, %rsi
callq 0x40f0
callq 0x4330
movq %rax, %rdi
callq 0x47b0
leaq 0x2f1(%rip), %rsi       # 0x9e3d
movq %rax, %rdi
movq %rbp, %rdx
callq 0x44d0
movq %rax, 0x28(%rsp)
callq 0x46a0
movq %rax, %rdi
callq 0x47b0
leaq 0x32e(%rip), %rsi       # 0x9e9e
movq %rax, %rdi
movq %rbp, %rdx
callq 0x44d0
movq %rax, 0x20(%rsp)
callq 0x4790
movq %rax, %rbx
leaq 0x2a51(%rip), %rdi      # 0xc5e0
callq 0x4090
movq 0x7425(%rip), %rdi      # 0x10fc0
movq %rax, %rsi
callq 0x4290
movq %rax, %r13
movq %rbp, %rdi
callq 0x42d0
movq 0x736b(%rip), %r9       # 0x10f20
movq %r9, (%rsp)
leaq 0x33f(%rip), %rsi       # 0x9eff
pushq $0x3
popq %rdi
movq %rbx, %rdx
movq %r13, %rcx
movq %rax, %r8
movq %r9, %r12
xorl %eax, %eax
callq 0x41d0
movq %rax, %rdi
callq 0x47b0
movq %rax, %r13
callq 0x4270
movq %rax, %rbx
callq 0x46f0
pushq $0x2
popq %rdi
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x47c0
movq %rax, %rdi
movq %r12, %rsi
callq 0x4450
leaq 0x399(%rip), %rsi       # 0x9fa9
movq %rax, %rdi
movq %rbp, %rdx
callq 0x44d0
movq %rax, %rbx
movq 0x10(%rsp), %r15
movq %r15, %rdi
leaq 0x10e(%rip), %rsi       # 0x9d3b
callq 0x44c0
pushq $0x5
popq %rdi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x48(%rsp), %r12
movq %r13, %rcx
movq 0x40(%rsp), %r13
movq %rbx, %r8
movq 0x18(%rsp), %rbx
movq %rax, %r9
xorl %eax, %eax
callq 0x47c0
movq %r14, %rdi
movq %rax, %rsi
callq 0x40f0
movq %r12, %rdi
callq 0x4530
movq %r15, %rdi
callq 0x4530
movq %rbx, %rdi
callq 0x4530
movq %r13, %rdi
callq 0x4530
movq %r14, %rdi
callq 0x4530
leaq 0x294b(%rip), %rdi      # 0xc5e3
leaq 0x8(%rsp), %rcx
movq 0x50(%rsp), %rsi
movq %r12, %rdx
callq 0x4860
testl %eax, %eax
jne 0x9cf6
movq 0x8(%rsp), %rdi
callq 0x44e0
movq %rax, %rbx
leaq 0x2938(%rip), %rdi      # 0xc5fa
movq %rax, %rsi
xorl %eax, %eax
callq 0x4360
movq %r14, %r15
movq %rax, %r14
movq 0x8(%rsp), %rdi
callq 0x4580
movq %rbx, %rdi
movq 0x18(%rsp), %rbx
callq 0x4880
movq %r14, 0x8(%rsp)
movq %r15, %r14
movq 0x10(%rsp), %r15
pushq $0x5
popq %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %rcx
movq %rbx, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x4720
movq 0x8(%rsp), %rdi
callq 0x4530
testb $0x1, 0x18(%rbp)
movq 0x8(%rsp), %rax
je 0x9d2c
movq %rax, %rdi
callq 0x40d0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq