// File: pfnet-research[P]pml/src/test.cpp
// Function: simple_type_arith::simple_type_arith()
PML_TEST(simple_type_arith) {
    assert_eq(
        *simty::simple_typing(ast::int_expr_t{42}).ok(),
        simty::int_type_t{});

    // 2+3*4
    assert_eq(
        *simty::simple_typing(ast::add_expr_t {
            make<ast::int_expr_t>(2),
            make<ast::mul_expr_t>(
                make<ast::int_expr_t>(3),
                make<ast::int_expr_t>(4))}).ok(),
        simty::int_type_t{});

    // 5-4/2
    assert_eq(
        *simty::simple_typing(ast::sub_expr_t {
            make<ast::int_expr_t>(5),
            make<ast::div_expr_t>(
                make<ast::int_expr_t>(4),
                make<ast::int_expr_t>(2))}).ok(),
        simty::int_type_t{});

    // if 1=3 then 1 else 2
    assert_eq(
        *simty::simple_typing(ast::if_expr_t {
            make<ast::bool_expr_t>(true),
            make<ast::int_expr_t>(1),
            make<ast::int_expr_t>(2)}).ok(),
        simty::int_type_t{});
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x71f20
movq -0x2e0(%rbp), %rax
leaq 0x7723b(%rip), %rcx     # 0xe6b08
movq %rcx, (%rax)
leaq -0x40(%rbp), %rdi
movl $0x2a, %esi
callq 0x148e0
jmp 0x6f8e0
leaq -0x30(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5f1d0
jmp 0x6f8ef
leaq -0x30(%rbp), %rdi
callq 0x5fc10
movq %rax, -0x2e8(%rbp)
jmp 0x6f901
movq -0x2e8(%rbp), %rdi
callq 0x5f9e0
movq %rax, -0x2f8(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x5fde0
movq -0x2e0(%rbp), %rdi
movq -0x2f8(%rbp), %rsi
movq -0x2f0(%rbp), %rdx
callq 0x84130
jmp 0x6f948
leaq -0x58(%rbp), %rdi
callq 0x5fe20
leaq -0x30(%rbp), %rdi
callq 0x300e0
leaq -0x40(%rbp), %rdi
callq 0x14930
movl $0x2, -0xcc(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xcc(%rbp), %rsi
callq 0x67db0
jmp 0x6f982
leaq -0xb8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x12f60
movl $0x3, -0x104(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x104(%rbp), %rsi
callq 0x67db0
jmp 0x6f9b4
movl $0x4, -0x11c(%rbp)
leaq -0x118(%rbp), %rdi
leaq -0x11c(%rbp), %rsi
callq 0x67db0
jmp 0x6f9d3
leaq -0xf0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x67e20
jmp 0x6f9ef
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x300(%rbp)
leaq -0xf0(%rbp), %rsi
callq 0x737d0
movq -0x300(%rbp), %rdx
leaq -0xa8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x520a0
jmp 0x6fa25
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x5f1d0
jmp 0x6fa37
leaq -0x80(%rbp), %rdi
callq 0x5fc10
movq %rax, -0x308(%rbp)
jmp 0x6fa49
movq -0x308(%rbp), %rdi
callq 0x5f9e0
movq %rax, -0x318(%rbp)
movq $0x0, -0x128(%rbp)
leaq -0x128(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x5fde0
movq -0x2e0(%rbp), %rdi
movq -0x318(%rbp), %rsi
movq -0x310(%rbp), %rdx
callq 0x84130
jmp 0x6fa96
leaq -0x128(%rbp), %rdi
callq 0x5fe20
leaq -0x80(%rbp), %rdi
callq 0x300e0
leaq -0xa8(%rbp), %rdi
callq 0x520f0
leaq -0xe0(%rbp), %rdi
callq 0x13080
leaq -0xf0(%rbp), %rdi
callq 0x420a0
leaq -0x118(%rbp), %rdi
callq 0x12f90
leaq -0x100(%rbp), %rdi
callq 0x12f90
leaq -0xb8(%rbp), %rdi
callq 0x13080
leaq -0xc8(%rbp), %rdi
callq 0x12f90
movl $0x5, -0x19c(%rbp)
leaq -0x198(%rbp), %rdi
leaq -0x19c(%rbp), %rsi
callq 0x67db0
jmp 0x6fb1e
leaq -0x188(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x12f60
movl $0x4, -0x1d4(%rbp)
leaq -0x1d0(%rbp), %rdi
leaq -0x1d4(%rbp), %rsi
callq 0x67db0
jmp 0x6fb50
movl $0x2, -0x1ec(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x1ec(%rbp), %rsi
callq 0x67db0
jmp 0x6fb6f
leaq -0x1c0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
leaq -0x1e8(%rbp), %rdx
callq 0x68dd0
jmp 0x6fb8b
leaq -0x1b0(%rbp), %rdi
movq %rdi, -0x320(%rbp)
leaq -0x1c0(%rbp), %rsi
callq 0x84380
movq -0x320(%rbp), %rdx
leaq -0x178(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x52be0
jmp 0x6fbc1
leaq -0x150(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x5f1d0
jmp 0x6fbd6
leaq -0x150(%rbp), %rdi
callq 0x5fc10
movq %rax, -0x328(%rbp)
jmp 0x6fbeb
movq -0x328(%rbp), %rdi
callq 0x5f9e0
movq %rax, -0x338(%rbp)
movq $0x0, -0x1f8(%rbp)
leaq -0x1f8(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x5fde0
movq -0x2e0(%rbp), %rdi
movq -0x338(%rbp), %rsi
movq -0x330(%rbp), %rdx
callq 0x84130
jmp 0x6fc38
leaq -0x1f8(%rbp), %rdi
callq 0x5fe20
leaq -0x150(%rbp), %rdi
callq 0x300e0
leaq -0x178(%rbp), %rdi
callq 0x52c30
leaq -0x1b0(%rbp), %rdi
callq 0x13080
leaq -0x1c0(%rbp), %rdi
callq 0x420f0
leaq -0x1e8(%rbp), %rdi
callq 0x12f90
leaq -0x1d0(%rbp), %rdi
callq 0x12f90
leaq -0x188(%rbp), %rdi
callq 0x13080
leaq -0x198(%rbp), %rdi
callq 0x12f90
movb $0x1, -0x279(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x279(%rbp), %rsi
callq 0x67fd0
jmp 0x6fcc0
leaq -0x268(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x12f10
movl $0x1, -0x2a4(%rbp)
leaq -0x2a0(%rbp), %rdi
leaq -0x2a4(%rbp), %rsi
callq 0x67db0
jmp 0x6fcf2
leaq -0x290(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x12f60
movl $0x2, -0x2cc(%rbp)
leaq -0x2c8(%rbp), %rdi
leaq -0x2cc(%rbp), %rsi
callq 0x67db0
jmp 0x6fd24
leaq -0x2b8(%rbp), %rdi
movq %rdi, -0x340(%rbp)
leaq -0x2c8(%rbp), %rsi
callq 0x12f60
movq -0x340(%rbp), %rcx
leaq -0x258(%rbp), %rdi
leaq -0x268(%rbp), %rsi
leaq -0x290(%rbp), %rdx
callq 0x4bd70
jmp 0x6fd61
leaq -0x220(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x5f1d0
jmp 0x6fd76
leaq -0x220(%rbp), %rdi
callq 0x5fc10
movq %rax, -0x348(%rbp)
jmp 0x6fd8b
movq -0x348(%rbp), %rdi
callq 0x5f9e0
movq %rax, -0x358(%rbp)
movq $0x0, -0x2d8(%rbp)
leaq -0x2d8(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0x5fde0
movq -0x2e0(%rbp), %rdi
movq -0x358(%rbp), %rsi
movq -0x350(%rbp), %rdx
callq 0x84130
jmp 0x6fdd8
leaq -0x2d8(%rbp), %rdi
callq 0x5fe20
leaq -0x220(%rbp), %rdi
callq 0x300e0
leaq -0x258(%rbp), %rdi
callq 0x4be00
leaq -0x2b8(%rbp), %rdi
callq 0x13080
leaq -0x2c8(%rbp), %rdi
callq 0x12f90
leaq -0x290(%rbp), %rdi
callq 0x13080
leaq -0x2a0(%rbp), %rdi
callq 0x12f90
leaq -0x268(%rbp), %rdi
callq 0x13080
leaq -0x278(%rbp), %rdi
callq 0x12f40
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x70112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6fe98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6fe8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x5fe20
leaq -0x30(%rbp), %rdi
callq 0x300e0
leaq -0x40(%rbp), %rdi
callq 0x14930
jmp 0x70112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6ff5d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6ff51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6ff45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6ff2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6ff21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6ff18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x5fe20
leaq -0x80(%rbp), %rdi
callq 0x300e0
leaq -0xa8(%rbp), %rdi
callq 0x520f0
leaq -0xe0(%rbp), %rdi
callq 0x13080
leaq -0xf0(%rbp), %rdi
callq 0x420a0
leaq -0x118(%rbp), %rdi
callq 0x12f90
leaq -0x100(%rbp), %rdi
callq 0x12f90
leaq -0xb8(%rbp), %rdi
callq 0x13080
leaq -0xc8(%rbp), %rdi
callq 0x12f90
jmp 0x70112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x70034
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x70028
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x7001c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x70004
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6fff8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6ffec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x5fe20
leaq -0x150(%rbp), %rdi
callq 0x300e0
leaq -0x178(%rbp), %rdi
callq 0x52c30
leaq -0x1b0(%rbp), %rdi
callq 0x13080
leaq -0x1c0(%rbp), %rdi
callq 0x420f0
leaq -0x1e8(%rbp), %rdi
callq 0x12f90
leaq -0x1d0(%rbp), %rdi
callq 0x12f90
leaq -0x188(%rbp), %rdi
callq 0x13080
leaq -0x198(%rbp), %rdi
callq 0x12f90
jmp 0x70112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x700fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x700e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x700ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x700be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x700b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x5fe20
leaq -0x220(%rbp), %rdi
callq 0x300e0
leaq -0x258(%rbp), %rdi
callq 0x4be00
leaq -0x2b8(%rbp), %rdi
callq 0x13080
leaq -0x2c8(%rbp), %rdi
callq 0x12f90
leaq -0x290(%rbp), %rdi
callq 0x13080
leaq -0x2a0(%rbp), %rdi
callq 0x12f90
leaq -0x268(%rbp), %rdi
callq 0x13080
leaq -0x278(%rbp), %rdi
callq 0x12f40
movq -0x2e0(%rbp), %rdi
callq 0x71f80
movq -0x48(%rbp), %rdi
callq 0xa650
nopw (%rax,%rax)