// File: /workspace/github_cpp_makefile_star2_O2/pfnet-research[P]pml/src/test.cpp
// Function: letfun_test::letfun_test()
PML_CUSTOM_TEST(letfun_test, lang_feature_test) {
    using namespace ast;
    parse_test("letfun plus4 (a:int, b:int) -> int = a+4 in plus4 (1+3) 0", "LetFun(plus4, [a, b], Add(a, 4), App(plus4, [Add(1, 3), 0]))");
    eval_test(
            make<letfun_expr_t>("plus4",
                dependent_type_t {
                    {
                        refinement_type_t{"a",
                            logic::domain_kind_t::Int,
                            make<logic::top_formula_t>()},
                        refinement_type_t{"b",
                            logic::domain_kind_t::Int,
                            make<logic::top_formula_t>()}
                    },
                    refinement_type_t {"@blah",
                        logic::domain_kind_t::Int,
                        make<logic::top_formula_t>()
                    }
                },
                make<add_expr_t>(
                    make<var_expr_t>("a"),
                    make<int_expr_t>(4)),
                make<app_expr_t>(
                    make<var_expr_t>("plus4"),
                    std::vector<ptr<expr_t>>{
                        make<add_expr_t>(
                                make<int_expr_t>(1),
                                make<int_expr_t>(3)),
                        make<int_expr_t>(0)
                        })),
            make<int_expr_t>(8));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rdi, %r13
andl $0x0, 0x8(%rdi)
leaq 0x360ed(%rip), %rax     # 0x5b6b8
movq %rax, (%rdi)
leaq 0x16cad(%rip), %rsi     # 0x3c282
leaq 0x1b8(%rsp), %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rdx
callq 0xeb2e
leaq 0x16ccb(%rip), %rsi     # 0x3c2bc
leaq 0x110(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0xeb2e
leaq 0x1b8(%rsp), %rsi
leaq 0x110(%rsp), %rdx
movq %r13, %rdi
callq 0x2983a
leaq 0x110(%rsp), %rdi
callq 0x9130
leaq 0x1b8(%rsp), %rdi
callq 0x9130
leaq 0x16c38(%rip), %rsi     # 0x3c277
leaq 0x1b8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xeb2e
andl $0x0, 0x1d8(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x1c1ff
leaq 0x68(%rsp), %rax
movaps -0x8(%rax), %xmm0
leaq 0x1f0(%rsp), %rbx
movups %xmm0, -0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rax)
leaq 0x13f6c(%rip), %rsi     # 0x395f2
leaq 0xe(%rsp), %rdx
movq %rbx, %rdi
callq 0xeb2e
andl $0x0, 0x210(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x1c1ff
leaq 0x58(%rsp), %rax
movaps -0x8(%rax), %xmm0
leaq 0x1b8(%rsp), %rsi
movups %xmm0, 0x60(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rax)
leaq 0x110(%rsp), %rdi
pushq $0x2
popq %rdx
leaq 0xd(%rsp), %rcx
callq 0x2b1c4
leaq 0x128(%rsp), %rbx
leaq 0x13fd3(%rip), %rsi     # 0x396b8
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xeb2e
andl $0x0, 0x148(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x1c1ff
leaq 0x48(%rsp), %rax
movaps -0x8(%rax), %xmm0
movups %xmm0, 0x150(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rax)
leaq 0x16b54(%rip), %rsi     # 0x3c277
leaq 0xc0(%rsp), %rdi
callq 0x2b094
leaq 0xf4(%rsp), %rsi
movl $0x4, (%rsi)
leaq 0xb0(%rsp), %rdi
callq 0xbc7c
leaq 0xd0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
callq 0x2af4d
leaq 0x16b8a(%rip), %rsi     # 0x3c2f9
leaq 0x90(%rsp), %rdi
callq 0x2b66d
leaq 0xf0(%rsp), %rsi
movl $0x1, (%rsi)
leaq 0x80(%rsp), %rdi
callq 0xbc7c
leaq 0xec(%rsp), %rsi
movl $0x3, (%rsi)
leaq 0x70(%rsp), %rdi
callq 0xbc7c
leaq 0x30(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x2a838
leaq 0x38(%rsp), %rax
movaps -0x8(%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rax)
leaq 0xe8(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x180(%rsp), %rdi
callq 0xbc7c
leaq 0x188(%rsp), %r12
movaps -0x8(%r12), %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, 0x10(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%r12)
leaq 0xf8(%rsp), %rdi
pushq $0x2
popq %rdx
leaq 0xb(%rsp), %rcx
callq 0x2b1fe
leaq 0xa0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0x2b533
leaq 0x16aad(%rip), %rsi     # 0x3c2f9
leaq 0x190(%rsp), %rdi
leaq 0x110(%rsp), %rdx
leaq 0xd0(%rsp), %rcx
leaq 0xa0(%rsp), %r8
callq 0x2b270
leaq 0x1a8(%rsp), %r14
leaq 0x198(%rsp), %rbx
movaps -0x8(%rbx), %xmm0
movaps %xmm0, -0x8(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rbx)
leaq 0xe4(%rsp), %rsi
movl $0x8, (%rsi)
leaq 0x160(%rsp), %rdi
callq 0xbc7c
leaq 0x178(%rsp), %rbp
leaq 0x168(%rsp), %r15
movaps -0x8(%r15), %xmm0
movaps %xmm0, -0x8(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%r15)
leaq 0x1a0(%rsp), %rsi
leaq 0x170(%rsp), %rdx
movq %r13, %rdi
callq 0x298b4
movq %rbp, %rdi
callq 0xa248
movq %r15, %rdi
callq 0xa248
movq %r14, %rdi
callq 0xa248
movq %rbx, %rdi
callq 0xa248
leaq 0xa8(%rsp), %rdi
callq 0xa248
leaq 0xf8(%rsp), %rdi
callq 0x1b2bc
pushq $0x18
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x10, %rdi
callq 0xa248
addq $-0x10, %rbx
cmpq $-0x8, %rbx
jne 0x25922
movq %r12, %rdi
callq 0xa248
leaq 0x38(%rsp), %rdi
callq 0xa248
leaq 0x78(%rsp), %rdi
callq 0xa248
leaq 0x88(%rsp), %rdi
callq 0xa248
leaq 0x98(%rsp), %rdi
callq 0xa248
leaq 0xd8(%rsp), %rdi
callq 0xa248
leaq 0xb8(%rsp), %rdi
callq 0xa248
leaq 0xc8(%rsp), %rdi
callq 0xa248
leaq 0x110(%rsp), %rdi
callq 0xc5c6
leaq 0x48(%rsp), %rdi
callq 0xa248
pushq $0x38
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x1b8, %rdi            # imm = 0x1B8
callq 0xc28a
addq $-0x38, %rbx
cmpq $-0x38, %rbx
jne 0x259b0
leaq 0x58(%rsp), %rdi
callq 0xa248
leaq 0x68(%rsp), %rdi
callq 0xa248
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r13
movq %rbp, %rdi
callq 0xa248
movq %r15, %rdi
callq 0xa248
jmp 0x25a08
movq %rax, %r13
movq %r14, %rdi
callq 0xa248
movq %rbx, %rdi
callq 0xa248
jmp 0x25a1d
movq %rax, %r13
leaq 0xa8(%rsp), %rdi
callq 0xa248
jmp 0x25a2f
movq %rax, %r13
leaq 0xf8(%rsp), %rdi
callq 0x1b2bc
jmp 0x25a41
movq %rax, %r13
pushq $0x18
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x10, %rdi
callq 0xa248
addq $-0x10, %rbx
cmpq $-0x8, %rbx
jne 0x25a44
movq %r12, %rdi
callq 0xa248
movb $0x1, %bpl
leaq 0x20(%rsp), %rbx
leaq 0x38(%rsp), %rdi
callq 0xa248
leaq 0x78(%rsp), %rdi
callq 0xa248
leaq 0x88(%rsp), %rdi
callq 0xa248
leaq 0x10(%rsp), %rax
cmpq %rbx, %rax
sete %al
orb %bpl, %al
jne 0x25adb
leaq 0x10(%rsp), %r14
leaq -0x10(%rbx), %r15
addq $-0x8, %rbx
movq %rbx, %rdi
callq 0xa248
movq %r15, %rbx
cmpq %r14, %r15
jne 0x25aa1
jmp 0x25adb
movq %rax, %r13
xorl %ebp, %ebp
jmp 0x25a66
movq %rax, %r13
leaq 0x10(%rsp), %rbx
xorl %ebp, %ebp
jmp 0x25a75
movq %rax, %r13
xorl %ebp, %ebp
movq %r14, %rbx
jmp 0x25a7f
movq %rax, %r13
leaq 0x98(%rsp), %rdi
callq 0xa248
leaq 0xd8(%rsp), %rdi
callq 0xa248
leaq 0xb8(%rsp), %rdi
callq 0xa248
leaq 0xc8(%rsp), %rdi
callq 0xa248
leaq 0x110(%rsp), %rdi
callq 0xc5c6
leaq 0x48(%rsp), %rdi
callq 0xa248
pushq $0x38
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x1b8, %rdi            # imm = 0x1B8
callq 0xc28a
addq $-0x38, %rbx
cmpq $-0x38, %rbx
jne 0x25b29
leaq 0x58(%rsp), %rdi
callq 0xa248
xorl %ebx, %ebx
leaq 0x68(%rsp), %rdi
callq 0xa248
testb %bl, %bl
je 0x25bff
leaq 0x1b8(%rsp), %rdi
callq 0xc28a
jmp 0x25bff
movq %rax, %r13
jmp 0x25ae8
movq %rax, %r13
jmp 0x25af5
movq %rax, %r13
jmp 0x25b02
movq %rax, %r13
jmp 0x25b0f
movq %rax, %r13
movq %rbx, %rdi
callq 0x9130
jmp 0x25ba3
movq %rax, %r13
leaq 0x110(%rsp), %rdi
callq 0xc13c
jmp 0x25b26
movq %rax, %r13
jmp 0x25b26
movq %rax, %r13
movq %rbx, %rdi
callq 0x9130
jmp 0x25bcd
movq %rax, %r13
movb $0x1, %bl
jmp 0x25b4f
jmp 0x25bea
jmp 0x25bfc
movq %rax, %r13
leaq 0x110(%rsp), %rdi
callq 0x9130
jmp 0x25bed
movq %rax, %r13
leaq 0x1b8(%rsp), %rdi
callq 0x9130
jmp 0x25bff
movq %rax, %r13
movq %r13, %rdi
callq 0x94d0
nop