// File: /workspace/github_c_makefile_star2_O2/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 0x10(%rsp), %rax
andl $0x0, (%rax)
leaq 0x14(%rsp), %rax
movl $0xd, (%rax)
leaq 0xc(%rsp), %rax
movl $0x2, (%rax)
leaq 0xb712(%rip), %rdi      # 0xd2e9
callq 0x6a1e
movq %rax, %r15
leaq 0xb708(%rip), %rdi      # 0xd2ee
callq 0x6a1e
movq %rax, %rbx
leaq 0xb700(%rip), %rdi      # 0xd2f5
callq 0x6a1e
movq %rax, 0x20(%rsp)
leaq 0xb6f4(%rip), %rdi      # 0xd2fa
callq 0x6a1e
movq %rax, %r13
leaq 0xb6eb(%rip), %rdi      # 0xd300
callq 0x715b
movq 0x143a7(%rip), %r12     # 0x15fc8
movq %r12, (%rsp)
leaq 0x237(%rip), %rsi       # 0x1e63
pushq $0x3
popq %rdi
movq %rbx, %rdx
movq %rax, %rcx
movq %rbx, %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x773b
pushq $0x2
popq %rbp
movl %ebp, %edi
movq %rax, %rsi
movq %rbx, %rdx
movq %rbx, 0x30(%rsp)
xorl %eax, %eax
callq 0x7646
movq %r15, %rdi
movq %rax, %rsi
callq 0x6cbd
leaq 0xb698(%rip), %rdi      # 0xd303
callq 0x715b
movq %r12, (%rsp)
pushq $0x3
popq %rdi
leaq 0x1e5(%rip), %rsi       # 0x1e63
movq 0x20(%rsp), %r14
movq %r14, %rdx
movq %rax, %rcx
movq %r14, %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x773b
movl %ebp, %edi
movq %rax, %rsi
movq %r14, %rdx
movq %r14, %rbp
xorl %eax, %eax
callq 0x7646
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6cbd
callq 0x7c5c
movq %rax, %r14
movq %r15, 0x28(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x8284
pushq $0x2
popq %rdi
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x7646
movq %rbp, %rdi
movq %rax, %rsi
callq 0x6cbd
movq %r15, %rdi
movq %r12, %rsi
callq 0x8154
movq %r13, %rdi
movq %rax, %rsi
callq 0x6cbd
leaq 0xbf9f(%rip), %rsi      # 0xdca2
leaq 0x1d7(%rip), %rbx       # 0x1ee1
leaq 0x1da(%rip), %rbp       # 0x1eeb
movq %r13, %rdi
leaq 0x1c(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0x9642
leaq 0xb5d8(%rip), %rsi      # 0xd306
leaq 0xb40f(%rip), %r14      # 0xd144
pushq $0x57
popq %rcx
movl %eax, %edi
movq %r14, %rdx
callq 0x4040
leaq 0xb5f5(%rip), %rsi      # 0xd33e
movq %r13, %rdi
leaq 0x18(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0x9642
leaq 0xb5dc(%rip), %rsi      # 0xd342
pushq $0x58
popq %rcx
movl %eax, %edi
movq %r14, %rdx
callq 0x4040
leaq 0xb602(%rip), %rsi      # 0xd37c
movq %r13, %rdi
leaq 0x14(%rsp), %r15
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0x9642
leaq 0xb5ea(%rip), %rsi      # 0xd384
pushq $0x59
popq %rcx
movl %eax, %edi
movq %r14, %rdx
callq 0x4040
leaq 0xb614(%rip), %rsi      # 0xd3c2
movq %r13, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0x9642
leaq 0xb5ff(%rip), %rsi      # 0xd3c8
pushq $0x5a
popq %rcx
movl %eax, %edi
movq %r14, %rdx
callq 0x4040
leaq 0xe6bf(%rip), %rsi      # 0x1049c
movq %r13, %rdi
leaq 0x10(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0x95e0
leaq 0xb60a(%rip), %rsi      # 0xd404
pushq $0x5b
popq %rcx
movl %eax, %edi
movq %r14, %rdx
callq 0x4040
leaq 0xb62e(%rip), %rsi      # 0xd43c
movq %r13, %rdi
leaq 0xc(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0x95e0
leaq 0xb616(%rip), %rsi      # 0xd441
pushq $0x5c
popq %rcx
movl %eax, %edi
movq %r14, %rdx
callq 0x4040
pushq $0x4
popq %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x6e12
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq