// File: /workspace/github_c_makefile_star2_O2/orangeduck[P]mpc/tests/grammar.c
// Function: test_digits_file
void test_digits_file(void) {
  
  FILE *f;
  mpc_result_t r;
  mpc_parser_t *Digit = mpc_new("digit");
  mpc_parser_t *Program = mpc_new("program");
  mpc_ast_t* t0;
  
  mpc_err_t* err = mpca_lang(MPCA_LANG_DEFAULT,
    " digit   : /[0-9]/ ;"
    " program : /^/ <digit>+ /$/ ;"
    , Digit, Program, NULL);
  
  PT_ASSERT(err == NULL);

  t0 = mpc_ast_build(5, ">", 
    mpc_ast_new("regex", ""),
    mpc_ast_new("digit|regex", "1"),
    mpc_ast_new("digit|regex", "2"),
    mpc_ast_new("digit|regex", "3"),
    mpc_ast_new("regex", ""));
  
  if (mpc_parse_contents("tests/digits.txt", Program, &r)) {
    PT_ASSERT(1);
    PT_ASSERT(mpc_ast_eq(t0, r.output));
    mpc_ast_delete(r.output);
  } else {
    PT_ASSERT(0);
    mpc_err_print(r.error);
    mpc_err_delete(r.error);
  }
  
  f = fopen("tests/digits.txt", "r");
  PT_ASSERT(f != NULL);

  if (mpc_parse_file("tests/digits.txt", f, Program, &r)) {
    PT_ASSERT(1);
    PT_ASSERT(mpc_ast_eq(t0, r.output));
    mpc_ast_delete(r.output);
  } else {
    PT_ASSERT(0);
    mpc_err_print(r.error);
    mpc_err_delete(r.error);
  }
    
  fclose(f);
    
  if (mpc_parse("tests/digits.txt", "123", Program, &r)) {
    PT_ASSERT(1);
    PT_ASSERT(mpc_ast_eq(t0, r.output));
    mpc_ast_delete(r.output);
  } else {
    PT_ASSERT(0);
    mpc_err_print(r.error);
    mpc_err_delete(r.error);
  }
  
  mpc_ast_delete(t0);
    
  mpc_cleanup(2, Digit, Program);
  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0xc581(%rip), %rdi      # 0x101e3
callq 0x6a1e
movq %rax, %rbx
leaq 0xb15c(%rip), %rdi      # 0xedcd
callq 0x6a1e
movq %rax, %r12
leaq 0xb155(%rip), %rsi      # 0xedd5
xorl %edi, %edi
movq %rbx, 0x10(%rsp)
movq %rbx, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0xafa2
xorl %edi, %edi
testq %rax, %rax
sete %dil
leaq 0xa725(%rip), %rsi      # 0xe3cc
leaq 0xa08c(%rip), %rdx      # 0xdd3a
movl $0x161, %ecx            # imm = 0x161
callq 0x4040
leaq 0xabb9(%rip), %rdi      # 0xe878
leaq 0xc7cc(%rip), %r13      # 0x10492
movq %r13, %rsi
callq 0x9743
movq %rax, %r15
leaq 0xb12f(%rip), %rbp      # 0xee07
leaq 0x9fc3(%rip), %rsi      # 0xdca2
movq %rbp, %rdi
callq 0x9743
movq %rax, %rbx
leaq 0x98c9(%rip), %rsi      # 0xd5ba
movq %rbp, %rdi
callq 0x9743
movq %rax, %r14
leaq 0xb146(%rip), %rsi      # 0xee49
movq %rbp, %rdi
callq 0x9743
movq %rax, %rbp
leaq 0xab63(%rip), %rdi      # 0xe878
movq %r13, %rsi
callq 0x9743
movq %rax, (%rsp)
leaq 0xc7aa(%rip), %rsi      # 0x104d2
pushq $0x5
popq %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %r14, %r8
movq %r12, %r14
movq %rbp, %r9
xorl %eax, %eax
callq 0x97b5
movq %rax, %r15
leaq 0xb0c8(%rip), %rdi      # 0xee13
leaq 0x8(%rsp), %rdx
movq %r12, %rsi
callq 0x6817
testl %eax, %eax
je 0x3da9
leaq 0x9f3f(%rip), %rsi      # 0xdca2
leaq 0x9fd0(%rip), %rbx      # 0xdd3a
pushq $0x1
popq %rdi
movq %rbx, %rdx
movl $0x16b, %ecx            # imm = 0x16B
callq 0x4040
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x991c
leaq 0xb096(%rip), %rsi      # 0xee24
movl %eax, %edi
movq %rbx, %rdx
movl $0x16c, %ecx            # imm = 0x16C
callq 0x4040
movq 0x8(%rsp), %rdi
callq 0x96f3
jmp 0x3dd7
leaq 0x92ce(%rip), %rsi      # 0xd07e
leaq 0x9f83(%rip), %rdx      # 0xdd3a
xorl %edi, %edi
movl $0x16f, %ecx            # imm = 0x16F
callq 0x4040
movq 0x8(%rsp), %rdi
callq 0x52bb
movq 0x8(%rsp), %rdi
callq 0x5270
leaq 0xb035(%rip), %rbx      # 0xee13
leaq 0xc6c0(%rip), %rsi      # 0x104a5
movq %rbx, %rdi
callq 0x1200
movq %rax, %r12
xorl %edi, %edi
testq %rax, %rax
setne %dil
leaq 0xb03d(%rip), %rsi      # 0xee3d
leaq 0x9f33(%rip), %rdx      # 0xdd3a
movl $0x175, %ecx            # imm = 0x175
callq 0x4040
leaq 0x8(%rsp), %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x668b
testl %eax, %eax
je 0x3e75
leaq 0x9e73(%rip), %rsi      # 0xdca2
leaq 0x9f04(%rip), %rbx      # 0xdd3a
pushq $0x1
popq %rdi
movq %rbx, %rdx
movl $0x178, %ecx            # imm = 0x178
callq 0x4040
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x991c
leaq 0xafca(%rip), %rsi      # 0xee24
movl %eax, %edi
movq %rbx, %rdx
movl $0x179, %ecx            # imm = 0x179
callq 0x4040
movq 0x8(%rsp), %rdi
callq 0x96f3
jmp 0x3ea3
leaq 0x9202(%rip), %rsi      # 0xd07e
leaq 0x9eb7(%rip), %rdx      # 0xdd3a
xorl %edi, %edi
movl $0x17c, %ecx            # imm = 0x17C
callq 0x4040
movq 0x8(%rsp), %rdi
callq 0x52bb
movq 0x8(%rsp), %rdi
callq 0x5270
movq %r12, %rdi
callq 0x10a0
leaq 0xaf61(%rip), %rdi      # 0xee13
leaq 0xaf8e(%rip), %rsi      # 0xee47
leaq 0x8(%rsp), %rcx
movq %r14, %rdx
callq 0x646d
testl %eax, %eax
je 0x3f17
leaq 0x9dd1(%rip), %rsi      # 0xdca2
leaq 0x9e62(%rip), %rbx      # 0xdd3a
pushq $0x1
popq %rdi
movq %rbx, %rdx
movl $0x184, %ecx            # imm = 0x184
callq 0x4040
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x991c
leaq 0xaf28(%rip), %rsi      # 0xee24
movl %eax, %edi
movq %rbx, %rdx
movl $0x185, %ecx            # imm = 0x185
callq 0x4040
movq 0x8(%rsp), %rdi
callq 0x96f3
jmp 0x3f45
leaq 0x9160(%rip), %rsi      # 0xd07e
leaq 0x9e15(%rip), %rdx      # 0xdd3a
xorl %edi, %edi
movl $0x188, %ecx            # imm = 0x188
callq 0x4040
movq 0x8(%rsp), %rdi
callq 0x52bb
movq 0x8(%rsp), %rdi
callq 0x5270
movq %r15, %rdi
callq 0x96f3
pushq $0x2
popq %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x6e12
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq