// File: /workspace/github_c_makefile_star2_O1/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 0xd6b4(%rip), %rdi      # 0xf2e9
callq 0x7191
movq %rax, %r14
leaq 0xd6aa(%rip), %rdi      # 0xf2ee
callq 0x7191
movq %rax, %rbp
leaq 0xd6a2(%rip), %rdi      # 0xf2f5
callq 0x7191
movq %rax, %r15
leaq 0xd698(%rip), %rdi      # 0xf2fa
callq 0x7191
movq %rax, %r13
leaq 0xd68f(%rip), %rdi      # 0xf300
callq 0x7a1c
movq 0x1634b(%rip), %r12     # 0x17fc8
movq %r12, (%rsp)
leaq 0x24a(%rip), %rbx       # 0x1ed2
movl $0x3, %edi
movq %rbx, %rsi
movq %rbp, %rdx
movq %rax, %rcx
movq %rbp, %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x818f
movl $0x2, %edi
movq %rax, %rsi
movq %rbp, %rdx
movq %rbp, 0x30(%rsp)
xorl %eax, %eax
callq 0x807e
movq %r14, %rdi
movq %rax, %rsi
callq 0x7478
leaq 0xd637(%rip), %rdi      # 0xf303
callq 0x7a1c
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 0x818f
movl $0x2, %edi
movq %rax, %rsi
movq %r15, %rdx
movq %r15, 0x28(%rsp)
xorl %eax, %eax
callq 0x807e
movq %rbp, %rdi
movq %rax, %rsi
callq 0x7478
callq 0x88b6
movq %rax, %rbx
movq %r14, 0x20(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x919f
movl $0x2, %edi
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x807e
movq %r15, %rdi
movq %rax, %rsi
callq 0x7478
movq %r14, %rdi
movq %r12, %rsi
callq 0x8fd2
movq %r13, %rdi
movq %rax, %rsi
callq 0x7478
leaq 0xdf3e(%rip), %rsi      # 0xfca2
leaq 0x1e5(%rip), %rbx       # 0x1f50
leaq 0x1e8(%rip), %rbp       # 0x1f5a
movq %r13, %rdi
leaq 0x1c(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xaa3c
leaq 0xd577(%rip), %rsi      # 0xf306
leaq 0xd3ae(%rip), %r14      # 0xf144
movl %eax, %edi
movq %r14, %rdx
movl $0x57, %ecx
callq 0x4050
leaq 0xd592(%rip), %rsi      # 0xf33e
movq %r13, %rdi
leaq 0x18(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xaa3c
leaq 0xd579(%rip), %rsi      # 0xf342
movl %eax, %edi
movq %r14, %rdx
movl $0x58, %ecx
callq 0x4050
leaq 0xd59d(%rip), %rsi      # 0xf37c
movq %r13, %rdi
leaq 0x14(%rsp), %r15
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xaa3c
leaq 0xd585(%rip), %rsi      # 0xf384
movl %eax, %edi
movq %r14, %rdx
movl $0x59, %ecx
callq 0x4050
leaq 0xd5ad(%rip), %rsi      # 0xf3c2
movq %r13, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xaa3c
leaq 0xd598(%rip), %rsi      # 0xf3c8
movl %eax, %edi
movq %r14, %rdx
movl $0x5a, %ecx
callq 0x4050
leaq 0x10636(%rip), %rsi     # 0x1247c
movq %r13, %rdi
leaq 0x10(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xa9c0
leaq 0xd5a1(%rip), %rsi      # 0xf404
movl %eax, %edi
movq %r14, %rdx
movl $0x5b, %ecx
callq 0x4050
leaq 0xd5c3(%rip), %rsi      # 0xf43c
movq %r13, %rdi
leaq 0xc(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0xa9c0
leaq 0xd5ab(%rip), %rsi      # 0xf441
movl %eax, %edi
movq %r14, %rdx
movl $0x5c, %ecx
callq 0x4050
movl $0x4, %edi
movq 0x20(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x75e0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq