// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movq %rsi, 0x18(%rsp)
movq %rdi, 0x40(%rsp)
leaq 0x3d38(%rip), %rdi      # 0xe5d6
callq 0x40a0
movq %rax, %r14
movq %rax, 0x38(%rsp)
leaq 0x3d32(%rip), %rdi      # 0xe5e4
callq 0x40a0
movq %rax, %rbp
leaq 0x3cc1(%rip), %rdi      # 0xe582
callq 0x40a0
movq %rax, %r12
leaq 0x3cb7(%rip), %rdi      # 0xe587
callq 0x40a0
movq %rax, %r13
leaq 0x3caf(%rip), %rdi      # 0xe58e
callq 0x40a0
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
callq 0x4400
leaq 0x4ec(%rip), %r15       # 0xade4
movq %rax, %rdi
movq %r15, %rsi
callq 0x4040
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movb $0x11, 0x30(%rax)
movq %rbx, 0x8(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x40c0
leaq 0x3c6b(%rip), %rdi      # 0xe59a
callq 0x4510
movq 0x85d5(%rip), %rsi      # 0x12f10
movq 0x85de(%rip), %r8       # 0x12f20
movl $0x2, %edi
movq %rax, %rdx
movq %rbp, %rcx
movq %rbp, 0x30(%rsp)
xorl %eax, %eax
callq 0x4140
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movb $0x13, 0x30(%rax)
movq %rbx, 0x8(%rax)
movq 0x861e(%rip), %rcx      # 0x12f98
movq %rcx, 0x18(%rax)
leaq 0x466(%rip), %rsi       # 0xadeb
movl $0x2, %edi
movq %r12, 0x28(%rsp)
movq %r12, %rdx
movq %rax, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x4140
movq %rbp, %rdi
movq %rax, %rsi
callq 0x40c0
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movb $0x15, 0x30(%rax)
movq %r13, 0x18(%rax)
movq %r13, %r15
movq %r13, 0x20(%rsp)
leaq 0x43a(%rip), %rcx       # 0xae0a
movq %rcx, 0x10(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x40c0
leaq 0x3c06(%rip), %rdi      # 0xe5ec
callq 0x4510
movq %rax, %r14
leaq 0x3bf9(%rip), %rdi      # 0xe5ee
callq 0x4510
movq %rax, %r12
leaq 0x3df7(%rip), %rdi      # 0xe7fb
callq 0x4510
movq %rax, %r13
leaq 0x3e50(%rip), %rdi      # 0xe863
callq 0x4510
movq %rax, %rbx
callq 0x4220
leaq 0x3b57(%rip), %rdx      # 0xe57e
leaq 0x3dc2(%rip), %rcx      # 0xe7f0
movq %rax, %rdi
movq 0x84e8(%rip), %rsi      # 0x12f20
callq 0x42e0
movq %rax, %rbp
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movb $0x1, 0x30(%rax)
movq %rax, (%rsp)
movl $0x6, %edi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %rbx, %r8
movq %rbp, %r9
xorl %eax, %eax
callq 0x4500
leaq 0x3e5(%rip), %rsi       # 0xae5e
movl $0x2, %edi
movq 0x10(%rsp), %rdx
movq %rax, %rcx
leaq 0x357(%rip), %r8        # 0xade4
xorl %eax, %eax
callq 0x4140
movq %r15, %rdi
movq %rax, %rsi
callq 0x40c0
callq 0x4210
movq %rax, %rbx
callq 0x4340
movq 0x84a5(%rip), %r13      # 0x12f58
movq 0x853e(%rip), %r12      # 0x12ff8
movl $0x2, %edi
movq %r13, %rsi
movq %rbx, %rdx
movq %rax, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x4140
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r14
movb $0x10, %al
movb %al, 0x30(%r14)
movb $0x10, %bpl
movq %rbx, 0x8(%r14)
leaq 0x483(%rip), %rax       # 0xaf7e
movq %rax, 0x10(%r14)
movq 0x18(%rsp), %r15
movq %r15, 0x18(%r14)
callq 0x4450
movq %rax, %rbx
callq 0x4340
movl $0x2, %edi
movq %r13, %rsi
movq %rbx, %rdx
movq %rax, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x4140
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r12
movb %bpl, 0x30(%rax)
movq %rbx, 0x8(%rax)
leaq 0x532(%rip), %rax       # 0xb083
movq %rax, 0x10(%r12)
movq %r15, 0x18(%r12)
movq %r15, %rbp
callq 0x44e0
movq %rax, %rbx
leaq 0x3a83(%rip), %rdi      # 0xe5f0
callq 0x4070
movq %rax, %r15
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r13
movb $0x14, 0x30(%rax)
movq %r15, 0x18(%rax)
movq 0x842a(%rip), %rax      # 0x12fc0
movq %rax, 0x10(%r13)
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movb $0x4, 0x30(%rax)
movq %rbp, 0x10(%rax)
movq 0x8368(%rip), %r9       # 0x12f20
movq %r9, (%rsp)
leaq 0x5ea(%rip), %rsi       # 0xb1ad
movl $0x3, %edi
movq %rbx, %rdx
movq %r13, %rcx
movq %rax, %r8
movq %r9, %r15
xorl %eax, %eax
callq 0x4140
movq %rax, %rbx
callq 0x4340
movl $0x2, %edi
movq 0x8369(%rip), %rsi      # 0x12f58
movq %rbx, %rdx
movq %rax, %rcx
movq 0x83fc(%rip), %r8       # 0x12ff8
xorl %eax, %eax
callq 0x4140
movq %rax, %r13
callq 0x41b0
movq %rax, %rbx
callq 0x4480
movl $0x2, %edi
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4500
leaq 0x3950(%rip), %rdx      # 0xe57c
leaq 0x3b91(%rip), %rcx      # 0xe7c4
movq %rax, %rdi
movq %r15, %rsi
callq 0x42e0
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r15
movb $0x10, %al
movb %al, 0x30(%r15)
movq %rbx, 0x8(%r15)
leaq 0x68f(%rip), %rax       # 0xb2f3
movq %rax, 0x10(%r15)
movq %rbp, 0x18(%r15)
leaq 0x3b80(%rip), %rdx      # 0xe7f3
leaq 0x3900(%rip), %rcx      # 0xe57a
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
leaq 0x15b(%rip), %rsi       # 0xade4
callq 0x42e0
movl $0x5, %edi
movq %r14, %rsi
movq 0x20(%rsp), %r14
movq %r12, %rdx
movq %rbx, %r12
movq %r13, %rcx
movq 0x28(%rsp), %r13
movq %r15, %r8
movq 0x38(%rsp), %r15
movq %rax, %r9
xorl %eax, %eax
callq 0x4500
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x40c0
movq %r15, %rdi
movl $0x1, %esi
callq 0xbfc5
movq %r12, %rdi
movl $0x1, %esi
callq 0xbfc5
movq %r14, %rdi
movl $0x1, %esi
callq 0xbfc5
movq %r13, %rdi
movl $0x1, %esi
callq 0xbfc5
movq %rbx, %rdi
movl $0x1, %esi
callq 0xbfc5
leaq 0x38e0(%rip), %rdi      # 0xe5f3
movq 0x40(%rsp), %rsi
callq 0x5bb6
movq %rax, %rbx
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x4090
movl %eax, %ebp
movq %rbx, %rdi
callq 0x5c78
testl %ebp, %ebp
jne 0xad7c
movq 0x8(%rsp), %rdi
callq 0x4320
movq %rax, %rbx
leaq 0x38b8(%rip), %rdi      # 0xe60a
movq %rax, %rsi
xorl %eax, %eax
callq 0x4240
movq %r14, %rbp
movq %rax, %r14
movq 0x8(%rsp), %rdi
callq 0x4380
movq %rbx, %rdi
callq 0x4580
movq %r14, 0x8(%rsp)
movq %rbp, %r14
movl $0x5, %edi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %r14, %r8
movq 0x10(%rsp), %r9
xorl %eax, %eax
callq 0x44a0
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0xbfc5
movq 0x18(%rsp), %rax
testb $0x1, 0x18(%rax)
movq 0x8(%rsp), %rbx
je 0xadd2
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movb $0x11, 0x30(%rax)
movq %rbx, 0x8(%rax)
movq %rax, %rbx
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq