// File: /workspace/github_c_makefile_star2_O3/orangeduck[P]mpc/tests/core.c
// Function: test_maths
void test_maths(void) {

  mpc_parser_t *Expr, *Factor, *Term, *Maths;
  int r0 = 1, r1 = 5, r2 = 13, r3 = 0, r4 = 2;

  Expr   = mpc_new("expr");
  Factor = mpc_new("factor");
  Term   = mpc_new("term");
  Maths  = mpc_new("maths");

  mpc_define(Expr, mpc_or(2,
    mpc_and(3, mpcf_maths, Factor, mpc_oneof("+-"), Factor, free, free),
    Factor
  ));

  mpc_define(Factor, mpc_or(2,
    mpc_and(3, mpcf_maths, Term, mpc_oneof("*/"), Term, free, free),
    Term
  ));

  mpc_define(Term, mpc_or(2,
    mpc_int(),
    mpc_parens(Expr, free)
  ));

  mpc_define(Maths, mpc_whole(Expr, free));

  PT_ASSERT(mpc_test_pass(Maths, "1", &r0, int_eq, free, int_print));
  PT_ASSERT(mpc_test_pass(Maths, "(5)", &r1, int_eq, free, int_print));
  PT_ASSERT(mpc_test_pass(Maths, "(4*2)+5", &r2, int_eq, free, int_print));
  PT_ASSERT(mpc_test_pass(Maths, "4*2+5", &r2, int_eq, free, int_print));
  PT_ASSERT(mpc_test_fail(Maths, "a", &r3, int_eq, free, int_print));
  PT_ASSERT(mpc_test_fail(Maths, "2b+4", &r4, int_eq, free, int_print));

  mpc_cleanup(4, Expr, Factor, Term, Maths);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
leaq 0x1c(%rsp), %rax
movl $0x1, (%rax)
leaq 0x18(%rsp), %rax
movl $0x5, (%rax)
leaq 0x14(%rsp), %rax
movl $0xd, (%rax)
leaq 0x10(%rsp), %rax
movl $0x0, (%rax)
leaq 0xc(%rsp), %rax
movl $0x2, (%rax)
leaq 0xd6c4(%rip), %rdi      # 0xf2e9
callq 0x71ca
movq %rax, %r14
leaq 0xd6ba(%rip), %rdi      # 0xf2ee
callq 0x71ca
movq %rax, %rbp
leaq 0xd6b2(%rip), %rdi      # 0xf2f5
callq 0x71ca
movq %rax, %r15
leaq 0xd6a8(%rip), %rdi      # 0xf2fa
callq 0x71ca
movq %rax, %r13
leaq 0xd69f(%rip), %rdi      # 0xf300
callq 0x79b7
movq 0x1635b(%rip), %r12     # 0x17fc8
movq %r12, (%rsp)
leaq 0x24a(%rip), %rbx       # 0x1ec2
movl $0x3, %edi
movq %rbx, %rsi
movq %rbp, %rdx
movq %rax, %rcx
movq %rbp, %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x8088
movl $0x2, %edi
movq %rax, %rsi
movq %rbp, %rdx
movq %rbp, 0x30(%rsp)
xorl %eax, %eax
callq 0x7f80
movq %r14, %rdi
movq %rax, %rsi
callq 0x747f
leaq 0xd647(%rip), %rdi      # 0xf303
callq 0x79b7
movq %r12, (%rsp)
movl $0x3, %edi
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
movq %r15, %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x8088
movl $0x2, %edi
movq %rax, %rsi
movq %r15, %rdx
movq %r15, 0x28(%rsp)
xorl %eax, %eax
callq 0x7f80
movq %rbp, %rdi
movq %rax, %rsi
callq 0x747f
callq 0x87d6
movq %rax, %rbx
movq %r14, 0x20(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x903c
movl $0x2, %edi
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x7f80
movq %r15, %rdi
movq %rax, %rsi
callq 0x747f
movq %r14, %rdi
movq %r12, %rsi
callq 0x8e7d
movq %r13, %rdi
movq %rax, %rsi
callq 0x747f
leaq 0xdf4e(%rip), %rsi      # 0xfca2
leaq 0x1e5(%rip), %rbx       # 0x1f40
leaq 0x1e8(%rip), %rbp       # 0x1f4a
movq %r13, %rdi
leaq 0x1c(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xa93d
leaq 0xd587(%rip), %rsi      # 0xf306
leaq 0xd3be(%rip), %r14      # 0xf144
movl %eax, %edi
movq %r14, %rdx
movl $0x57, %ecx
callq 0x4094
leaq 0xd5a2(%rip), %rsi      # 0xf33e
movq %r13, %rdi
leaq 0x18(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xa93d
leaq 0xd589(%rip), %rsi      # 0xf342
movl %eax, %edi
movq %r14, %rdx
movl $0x58, %ecx
callq 0x4094
leaq 0xd5ad(%rip), %rsi      # 0xf37c
movq %r13, %rdi
leaq 0x14(%rsp), %r15
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xa93d
leaq 0xd595(%rip), %rsi      # 0xf384
movl %eax, %edi
movq %r14, %rdx
movl $0x59, %ecx
callq 0x4094
leaq 0xd5bd(%rip), %rsi      # 0xf3c2
movq %r13, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xa93d
leaq 0xd5a8(%rip), %rsi      # 0xf3c8
movl %eax, %edi
movq %r14, %rdx
movl $0x5a, %ecx
callq 0x4094
leaq 0x10676(%rip), %rsi     # 0x124ac
movq %r13, %rdi
leaq 0x10(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xa8c1
leaq 0xd5b1(%rip), %rsi      # 0xf404
movl %eax, %edi
movq %r14, %rdx
movl $0x5b, %ecx
callq 0x4094
leaq 0xd5d3(%rip), %rsi      # 0xf43c
movq %r13, %rdi
leaq 0xc(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xa8c1
leaq 0xd5bb(%rip), %rsi      # 0xf441
movl %eax, %edi
movq %r14, %rdx
movl $0x5c, %ecx
callq 0x4094
movl $0x4, %edi
movq 0x20(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x75de
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq