// File: /workspace/github_c_makefile_star2_O1/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, 0x20(%rsp)
movq %rdi, 0x50(%rsp)
leaq 0x3c22(%rip), %rdi      # 0xe5a6
callq 0x40a0
movq %rax, %r14
movq %rax, 0x48(%rsp)
leaq 0x3c1c(%rip), %rdi      # 0xe5b4
callq 0x40a0
movq %rax, %rbp
leaq 0x3bab(%rip), %rdi      # 0xe552
callq 0x40a0
movq %rax, %r12
leaq 0x3ba1(%rip), %rdi      # 0xe557
callq 0x40a0
movq %rax, %r13
leaq 0x3b99(%rip), %rdi      # 0xe55e
callq 0x40a0
movq %rax, 0x18(%rsp)
movq %rbp, %rdi
callq 0x4410
leaq 0x53a(%rip), %r15       # 0xaf18
movq %rax, %rdi
movq %r15, %rsi
callq 0x4040
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
xorl %ecx, %ecx
movq %rcx, (%rax)
movw $0x11, 0x30(%rax)
movq %rbx, 0x8(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x40c0
leaq 0x3b4e(%rip), %rdi      # 0xe56a
callq 0x4510
movq 0x84e8(%rip), %rsi      # 0x12f10
movq 0x84f1(%rip), %r8       # 0x12f20
movl $0x2, %edi
movq %rax, %rdx
movq %rbp, %rcx
movq %rbp, 0x40(%rsp)
xorl %eax, %eax
callq 0x4130
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
xorl %ecx, %ecx
movq %rcx, (%rax)
xorl %r14d, %r14d
movw $0x13, 0x30(%rax)
movq %rbx, 0x8(%rax)
movq 0x8527(%rip), %rcx      # 0x12f98
movq %rcx, 0x18(%rax)
leaq 0x4a3(%rip), %rsi       # 0xaf1f
movl $0x2, %edi
movq %r12, 0x38(%rsp)
movq %r12, %rdx
movq %rax, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x4130
movq %rbp, %rdi
movq %rax, %rsi
callq 0x40c0
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %r14, (%rax)
movw $0x15, 0x30(%rax)
movq %r13, 0x18(%rax)
movq %r13, %r15
movq %r13, 0x30(%rsp)
leaq 0x472(%rip), %rcx       # 0xaf3e
movq %rcx, 0x10(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x40c0
leaq 0x3ada(%rip), %rdi      # 0xe5bc
callq 0x4510
movq %rax, %r14
leaq 0x3acd(%rip), %rdi      # 0xe5be
callq 0x4510
movq %rax, %r12
leaq 0x3ccb(%rip), %rdi      # 0xe7cb
callq 0x4510
movq %rax, %r13
leaq 0x3d24(%rip), %rdi      # 0xe833
callq 0x4510
movq %rax, %rbx
callq 0x4220
leaq 0x3a2b(%rip), %rdx      # 0xe54e
leaq 0x3c96(%rip), %rcx      # 0xe7c0
movq %rax, %rdi
movq 0x83ec(%rip), %rsi      # 0x12f20
callq 0x42e0
movq %rax, %rbp
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
xorl %ecx, %ecx
movq %rcx, (%rax)
movw $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 0x41f(%rip), %rsi       # 0xaf9b
movl $0x2, %edi
movq 0x18(%rsp), %rdx
movq %rax, %rcx
leaq 0x388(%rip), %r8        # 0xaf18
xorl %eax, %eax
callq 0x4130
movq %r15, %rdi
movq %rax, %rsi
callq 0x40c0
callq 0x4210
movq %rax, %rbx
callq 0x4340
movq 0x83a2(%rip), %rbp      # 0x12f58
movq 0x843b(%rip), %r12      # 0x12ff8
movl $0x2, %edi
movq %rbp, %rsi
movq %rbx, %rdx
movq %rax, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x4130
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r14
xorl %r13d, %r13d
movq %r13, (%rax)
movw $0x10, %ax
movw %ax, 0x30(%r14)
movq %rbx, 0x8(%r14)
leaq 0x4e4(%rip), %rax       # 0xb0e8
movq %rax, 0x10(%r14)
movq 0x20(%rsp), %r15
movq %r15, 0x18(%r14)
callq 0x4460
movq %rax, %rbx
callq 0x4340
movl $0x2, %edi
movq %rbp, %rsi
movq %rbx, %rdx
movq %rax, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x4130
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r12
movq %r13, (%rax)
movw $0x10, %ax
movw %ax, 0x30(%r12)
movq %rbx, 0x8(%r12)
leaq 0x565(%rip), %rax       # 0xb1c9
movq %rax, 0x10(%r12)
movq %r15, 0x18(%r12)
movq %r15, %rbp
callq 0x44f0
movq %rax, 0x28(%rsp)
leaq 0x393e(%rip), %rdi      # 0xe5c0
callq 0x4070
movq %rax, %r15
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r13
xorl %ebx, %ebx
movq %rbx, (%rax)
movw $0x14, 0x30(%rax)
movq %r15, 0x18(%rax)
movq 0x830e(%rip), %rax      # 0x12fc0
movq %rax, 0x10(%r13)
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rbx, (%rax)
movw $0x4, 0x30(%rax)
movq %rbp, 0x10(%rax)
movq 0x8247(%rip), %r9       # 0x12f20
movq %r9, (%rsp)
leaq 0x5c6(%rip), %rsi       # 0xb2aa
movl $0x3, %edi
movq 0x28(%rsp), %rdx
movq %r13, %rcx
movq %rax, %r8
movq %r9, %r15
xorl %eax, %eax
callq 0x4130
movq %rax, %rbx
callq 0x4340
movl $0x2, %edi
movq 0x8246(%rip), %rsi      # 0x12f58
movq %rbx, %rdx
movq %rax, %rcx
movq 0x82d9(%rip), %r8       # 0x12ff8
xorl %eax, %eax
callq 0x4130
movq %rax, %r13
callq 0x41b0
movq %rax, %rbx
callq 0x4490
movl $0x2, %edi
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4500
leaq 0x37fd(%rip), %rdx      # 0xe54c
leaq 0x3a3e(%rip), %rcx      # 0xe794
movq %rax, %rdi
movq %r15, %rsi
callq 0x42e0
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r15
xorl %eax, %eax
movq %rax, (%r15)
movw $0x10, %ax
movw %ax, 0x30(%r15)
movq %rbx, 0x8(%r15)
leaq 0x63d(%rip), %rax       # 0xb3cc
movq %rax, 0x10(%r15)
movq %rbp, 0x18(%r15)
leaq 0x3a25(%rip), %rdx      # 0xe7c3
leaq 0x37a5(%rip), %rcx      # 0xe54a
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
leaq 0x164(%rip), %rsi       # 0xaf18
callq 0x42e0
movl $0x5, %edi
movq %r14, %rsi
movq 0x30(%rsp), %r14
movq %r12, %rdx
movq %rbx, %r12
movq %r13, %rcx
movq 0x38(%rsp), %r13
movq %r15, %r8
movq 0x48(%rsp), %r15
movq %rax, %r9
xorl %eax, %eax
callq 0x4500
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x40c0
movq %r15, %rdi
movl $0x1, %esi
callq 0xc0b6
movq %r12, %rdi
movl $0x1, %esi
callq 0xc0b6
movq %r14, %rdi
movl $0x1, %esi
callq 0xc0b6
movq %r13, %rdi
movl $0x1, %esi
callq 0xc0b6
movq %rbx, %rdi
movl $0x1, %esi
callq 0xc0b6
leaq 0x3785(%rip), %rdi      # 0xe5c3
movq 0x50(%rsp), %rsi
callq 0x5bc4
movq %rax, %rbx
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x4090
movl %eax, %ebp
movq %rbx, %rdi
callq 0x5c86
testl %ebp, %ebp
jne 0xaea7
movq 0x10(%rsp), %rdi
callq 0x4320
movq %rax, %rbx
leaq 0x375d(%rip), %rdi      # 0xe5da
movq %rax, %rsi
xorl %eax, %eax
callq 0x4240
movq %r14, %rbp
movq %rax, %r14
movq 0x10(%rsp), %rdi
callq 0x4380
movq %rbx, %rdi
callq 0x4580
movq %r14, 0x10(%rsp)
movq %rbp, %r14
movl $0x5, %edi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %r14, %r8
movq 0x18(%rsp), %r9
xorl %eax, %eax
callq 0x44b0
movq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0xc0b6
movq 0x20(%rsp), %rax
testb $0x1, 0x18(%rax)
movq 0x10(%rsp), %rbx
je 0xaf06
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq $0x0, (%rax)
movw $0x11, 0x30(%rax)
movq %rbx, 0x8(%rax)
movq %rax, %rbx
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq