// File: /workspace/github_c_makefile_star2_O3/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 0xe547(%rip), %rdi      # 0x121f3
callq 0x71ca
movq %rax, %rbx
leaq 0xd112(%rip), %rdi      # 0x10dcd
callq 0x71ca
movq %rax, %r12
leaq 0xd10b(%rip), %rsi      # 0x10dd5
xorl %edi, %edi
movq %rbx, 0x10(%rsp)
movq %rbx, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0xccc2
xorl %edi, %edi
testq %rax, %rax
sete %dil
leaq 0xc6db(%rip), %rsi      # 0x103cc
leaq 0xc042(%rip), %rdx      # 0xfd3a
movl $0x161, %ecx            # imm = 0x161
callq 0x4094
leaq 0xcb6f(%rip), %rdi      # 0x10878
leaq 0xe792(%rip), %r13      # 0x124a2
movq %r13, %rsi
callq 0xaa70
movq %rax, %r15
leaq 0xd0e5(%rip), %rbp      # 0x10e07
leaq 0xbf79(%rip), %rsi      # 0xfca2
movq %rbp, %rdi
callq 0xaa70
movq %rax, %rbx
leaq 0xb87f(%rip), %rsi      # 0xf5ba
movq %rbp, %rdi
callq 0xaa70
movq %rax, %r14
leaq 0xd0fc(%rip), %rsi      # 0x10e49
movq %rbp, %rdi
callq 0xaa70
movq %rax, %rbp
leaq 0xcb19(%rip), %rdi      # 0x10878
movq %r13, %rsi
callq 0xaa70
movq %rax, (%rsp)
leaq 0xe770(%rip), %rsi      # 0x124e2
movl $0x5, %edi
movq %r15, %rdx
movq %rbx, %rcx
movq %r14, %r8
movq %r12, %r14
movq %rbp, %r9
xorl %eax, %eax
callq 0xaaea
movq %rax, %r15
leaq 0xd07c(%rip), %rdi      # 0x10e13
leaq 0x8(%rsp), %rdx
movq %r12, %rsi
callq 0x6f92
testl %eax, %eax
je 0x3df7
leaq 0xbef3(%rip), %rsi      # 0xfca2
leaq 0xbf84(%rip), %rbx      # 0xfd3a
movl $0x1, %edi
movq %rbx, %rdx
movl $0x16b, %ecx            # imm = 0x16B
callq 0x4094
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xac9a
leaq 0xd048(%rip), %rsi      # 0x10e24
movl %eax, %edi
movq %rbx, %rdx
movl $0x16c, %ecx            # imm = 0x16C
callq 0x4094
movq 0x8(%rsp), %rdi
callq 0xaa18
jmp 0x3e25
leaq 0xb280(%rip), %rsi      # 0xf07e
leaq 0xbf35(%rip), %rdx      # 0xfd3a
xorl %edi, %edi
movl $0x16f, %ecx            # imm = 0x16F
callq 0x4094
movq 0x8(%rsp), %rdi
callq 0x5703
movq 0x8(%rsp), %rdi
callq 0x56b0
leaq 0xcfe7(%rip), %rbx      # 0x10e13
leaq 0xe682(%rip), %rsi      # 0x124b5
movq %rbx, %rdi
callq 0x1200
movq %rax, %r12
xorl %edi, %edi
testq %rax, %rax
setne %dil
leaq 0xcfef(%rip), %rsi      # 0x10e3d
leaq 0xbee5(%rip), %rdx      # 0xfd3a
movl $0x175, %ecx            # imm = 0x175
callq 0x4094
leaq 0x8(%rsp), %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x6e02
testl %eax, %eax
je 0x3ec5
leaq 0xbe25(%rip), %rsi      # 0xfca2
leaq 0xbeb6(%rip), %rbx      # 0xfd3a
movl $0x1, %edi
movq %rbx, %rdx
movl $0x178, %ecx            # imm = 0x178
callq 0x4094
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xac9a
leaq 0xcf7a(%rip), %rsi      # 0x10e24
movl %eax, %edi
movq %rbx, %rdx
movl $0x179, %ecx            # imm = 0x179
callq 0x4094
movq 0x8(%rsp), %rdi
callq 0xaa18
jmp 0x3ef3
leaq 0xb1b2(%rip), %rsi      # 0xf07e
leaq 0xbe67(%rip), %rdx      # 0xfd3a
xorl %edi, %edi
movl $0x17c, %ecx            # imm = 0x17C
callq 0x4094
movq 0x8(%rsp), %rdi
callq 0x5703
movq 0x8(%rsp), %rdi
callq 0x56b0
movq %r12, %rdi
callq 0x10a0
leaq 0xcf11(%rip), %rdi      # 0x10e13
leaq 0xcf3e(%rip), %rsi      # 0x10e47
leaq 0x8(%rsp), %rcx
movq %r14, %rdx
callq 0x6bd7
testl %eax, %eax
je 0x3f69
leaq 0xbd81(%rip), %rsi      # 0xfca2
leaq 0xbe12(%rip), %rbx      # 0xfd3a
movl $0x1, %edi
movq %rbx, %rdx
movl $0x184, %ecx            # imm = 0x184
callq 0x4094
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xac9a
leaq 0xced6(%rip), %rsi      # 0x10e24
movl %eax, %edi
movq %rbx, %rdx
movl $0x185, %ecx            # imm = 0x185
callq 0x4094
movq 0x8(%rsp), %rdi
callq 0xaa18
jmp 0x3f97
leaq 0xb10e(%rip), %rsi      # 0xf07e
leaq 0xbdc3(%rip), %rdx      # 0xfd3a
xorl %edi, %edi
movl $0x188, %ecx            # imm = 0x188
callq 0x4094
movq 0x8(%rsp), %rdi
callq 0x5703
movq 0x8(%rsp), %rdi
callq 0x56b0
movq %r15, %rdi
callq 0xaa18
movl $0x2, %edi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x75de
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq