// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, %rbx
movl $0x0, 0x8(%rdi)
leaq 0x31dd2(%rip), %rax     # 0x616c8
movq %rax, (%rdi)
leaq 0x120(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1b30a(%rip), %rsi     # 0x4ac16
leaq 0x1b33c(%rip), %rdx     # 0x4ac4f
leaq 0x110(%rsp), %rdi
callq 0x116f8
leaq 0xb0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1b31d(%rip), %rsi     # 0x4ac50
leaq 0x1b352(%rip), %rdx     # 0x4ac8c
leaq 0xa0(%rsp), %rdi
callq 0x116f8
leaq 0x110(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
movq %rbx, %rdi
callq 0x3543e
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x2f97c
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x92e0
movq 0x110(%rsp), %rdi
cmpq %r14, %rdi
je 0x2f999
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x92e0
leaq 0x110(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x1b260(%rip), %rsi     # 0x4ac0b
leaq 0x1b25a(%rip), %rdx     # 0x4ac0c
callq 0x116f8
movl $0x0, 0x130(%rsp)
movl $0x18, %edi
callq 0x92d0
movabsq $0x100000001, %r13      # imm = 0x100000001
movq %r13, 0x8(%rax)
leaq 0x30f6f(%rip), %r14     # 0x60950
movq %r14, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
leaq 0x30fae(%rip), %r12     # 0x609a0
movq %r12, 0x10(%rax)
leaq 0x148(%rsp), %rdi
movq %rcx, -0x10(%rdi)
movq %rax, -0x8(%rdi)
leaq 0x158(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x188b9(%rip), %rsi     # 0x482d2
leaq 0x188b3(%rip), %rdx     # 0x482d3
callq 0x116f8
movl $0x0, 0x168(%rsp)
movl $0x18, %edi
callq 0x92d0
movq %r13, 0x8(%rax)
movq %r14, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
movq %r12, 0x10(%rax)
leaq 0x110(%rsp), %rsi
movq %rcx, 0x60(%rsi)
movq %rax, 0x68(%rsi)
leaq 0xa0(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0x2, %edx
callq 0x36dba
leaq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x1890a(%rip), %rsi     # 0x48398
leaq 0x18908(%rip), %rdx     # 0x4839d
callq 0x116f8
movl $0x0, 0xd8(%rsp)
movl $0x18, %edi
callq 0x92d0
movq %r13, 0x8(%rax)
movq %r14, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
movq %r12, 0x10(%rax)
movq %rcx, 0xe0(%rsp)
movq %rax, 0xe8(%rsp)
leaq 0x88(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x1b123(%rip), %rcx     # 0x4ac0b
leaq 0x80(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x36c9a
movl $0x20, %edi
callq 0x92d0
movq %r13, 0x8(%rax)
leaq 0x2ffd9(%rip), %rbp     # 0x5fae8
movq %rbp, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
leaq 0x30018(%rip), %r12     # 0x5fb38
movq %r12, 0x10(%rax)
movl $0x4, 0x18(%rax)
leaq 0x190(%rsp), %r8
movq %rax, 0x8(%r8)
movq %rcx, (%r8)
leaq 0x98(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x90(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x80(%rsp), %rcx
callq 0x36bac
leaq 0x78(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x1b115(%rip), %rcx     # 0x4ac8d
leaq 0x70(%rsp), %rsi
leaq 0x40(%rsp), %r14
movq %r14, %rdx
callq 0x3723a
movl $0x20, %edi
callq 0x92d0
movq %r13, 0x8(%rax)
movq %rbp, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
movq %r12, 0x10(%rax)
movl $0x1, 0x18(%rax)
movq %rax, 0x68(%rsp)
movq %rcx, 0x60(%rsp)
movl $0x20, %edi
callq 0x92d0
movq %r13, 0x8(%rax)
movq %rbp, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
movq %r12, 0x10(%rax)
movl $0x3, 0x18(%rax)
leaq 0x180(%rsp), %r8
movq %rax, 0x8(%r8)
movq %rcx, (%r8)
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0x3663a
movaps 0x10(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movl $0x20, %edi
callq 0x92d0
movq %r13, 0x8(%rax)
movq %rbp, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
movq %r12, 0x10(%rax)
movl $0x0, 0x18(%rax)
leaq 0x40(%rsp), %rsi
movq %rcx, 0x10(%rsi)
movq %rax, 0x18(%rsi)
leaq 0x1a0(%rsp), %rdi
leaq 0xe(%rsp), %rcx
movl $0x2, %edx
callq 0x36e02
leaq 0x108(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x100(%rsp), %r14
leaq 0x30(%rsp), %rdx
leaq 0x70(%rsp), %rcx
leaq 0x1a0(%rsp), %r8
movq %r14, %rsi
callq 0x37164
leaq 0x28(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq %r14, (%rsp)
leaq 0x1afe0(%rip), %rcx     # 0x4ac8d
leaq 0x20(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0xa0(%rsp), %r8
leaq 0x90(%rsp), %r9
callq 0x36e86
movaps 0x20(%rsp), %xmm0
movaps %xmm0, 0xf0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movl $0x20, %edi
callq 0x92d0
movq %r13, 0x8(%rax)
movq %rbp, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
movq %r12, 0x10(%rax)
movl $0x8, 0x18(%rax)
leaq 0x30(%rsp), %rdx
movq %rcx, (%rdx)
movq %rax, 0x8(%rdx)
leaq 0xf0(%rsp), %rsi
movq %rbx, %rdi
callq 0x354b8
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
leaq 0xc8(%rsp), %r14
je 0x2fd37
callq 0xa946
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2fd49
callq 0xa946
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2fd58
callq 0xa946
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x2fd6a
callq 0xa946
leaq 0x1a0(%rsp), %rdi
callq 0x24ea6
movl $0x20, %ebx
movq 0x38(%rsp,%rbx), %rdi
testq %rdi, %rdi
je 0x2fd8b
callq 0xa946
addq $-0x10, %rbx
jne 0x2fd7c
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2fda0
callq 0xa946
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x2fdb2
callq 0xa946
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2fdc1
callq 0xa946
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x2fdd0
callq 0xa946
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x2fde2
callq 0xa946
movq 0x198(%rsp), %rdi
testq %rdi, %rdi
je 0x2fdf4
callq 0xa946
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x2fe06
callq 0xa946
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x2fe18
callq 0xa946
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x2fe35
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x92e0
leaq 0xa0(%rsp), %rdi
callq 0xce82
xorl %ebx, %ebx
movq 0x178(%rsp,%rbx), %rdi
testq %rdi, %rdi
je 0x2fe56
callq 0xa946
movq 0x148(%rsp,%rbx), %rdi
leaq (%r15,%rbx), %rax
cmpq %rdi, %rax
je 0x2fe77
movq 0x158(%rsp,%rbx), %rsi
incq %rsi
callq 0x92e0
addq $-0x38, %rbx
cmpq $-0x70, %rbx
jne 0x2fe44
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x2feaa
callq 0xa946
jmp 0x2feaa
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2febc
callq 0xa946
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2fed0
callq 0xa946
jmp 0x2fed0
movq %rax, %rbx
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x2fee7
callq 0xa946
jmp 0x2fee7
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x24ea6
jmp 0x2fef9
movq %rax, %rbx
movl $0x20, %r14d
movq 0x38(%rsp,%r14), %rdi
testq %rdi, %rdi
je 0x2ff0e
callq 0xa946
addq $-0x10, %r14
jne 0x2feff
movb $0x1, %bpl
leaq 0x50(%rsp), %r14
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2ff3e
callq 0xa946
jmp 0x2ff3e
movq %rax, %rbx
xorl %ebp, %ebp
jmp 0x2ff17
movq %rax, %rbx
leaq 0x40(%rsp), %r14
xorl %ebp, %ebp
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x2ff57
callq 0xa946
jmp 0x2ff57
movq %rax, %rbx
xorl %ebp, %ebp
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2ff66
callq 0xa946
leaq 0x40(%rsp), %r15
cmpq %r14, %r15
sete %al
orb %al, %bpl
jne 0x2ff92
movq -0x8(%r14), %rdi
testq %rdi, %rdi
je 0x2ff84
callq 0xa946
addq $-0x10, %r14
cmpq %r15, %r14
jne 0x2ff76
jmp 0x2ff92
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x2ffa1
callq 0xa946
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x2ffb3
callq 0xa946
movq 0x198(%rsp), %rdi
testq %rdi, %rdi
je 0x2ffc5
callq 0xa946
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x2ffd7
callq 0xa946
leaq 0xa0(%rsp), %rdi
callq 0x24d2a
movl $0x38, %r14d
leaq (%rsp,%r14), %rdi
addq $0x110, %rdi            # imm = 0x110
callq 0x24b24
addq $-0x38, %r14
cmpq $-0x38, %r14
jne 0x2ffea
movq %rbx, %rdi
callq 0x94e0
movq %rax, %rbx
jmp 0x2ffa1
movq %rax, %rbx
jmp 0x2ffb3
movq %rax, %rbx
jmp 0x2ffc5
movq %rax, %rbx
jmp 0x2ffd7
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x30045
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0x30045
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0xce82
jmp 0x2ffe4
movq %rax, %rbx
jmp 0x2ffe4
movq %rax, %rbx
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0x3007e
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0x3007e
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x24b24
jmp 0x30004
jmp 0x300b6
jmp 0x300df
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x300b9
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0x300b9
movq %rax, %rbx
movq 0x110(%rsp), %rdi
cmpq %r14, %rdi
je 0x30004
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0x30004
movq %rax, %rbx
jmp 0x30004
nop