// File: pfnet-research[P]pml/src/test.cpp
// Function: rand_test::rand_test()
PML_CUSTOM_TEST(rand_test, lang_feature_test) {
    using namespace ast;
    using namespace evaluator;
    parse_test("rand(1, 4)", "Rand(1, 4)");

    for (int i=0; i<16; ++i) {
        auto n1 = cast<int_expr_t>(*eval(make<rand_expr_t>(1, 4))).n;
        assert_(1 <= n1 && n1 <= 4, "1 <= rand(1, 4) <= 4");
    }

    parse_test("rand(1, 4) + 42", "Add(Rand(1, 4), 42)");
    auto n2 = cast<int_expr_t>(*eval(
                make<add_expr_t>(
                    make<rand_expr_t>(1, 4),
                    make<int_expr_t>(42)))).n;
    assert_(43 <= n2 && n2 <= 46, "43 <= rand(1, 4) + 42 <= 46");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x71b80
movq -0x1b8(%rbp), %rax
leaq 0x7a83b(%rip), %rcx     # 0xe66f8
movq %rcx, (%rax)
leaq -0x29(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0xa660
movq -0x1b0(%rbp), %rdx
leaq 0x33cba(%rip), %rsi     # 0x9fb98
leaq -0x28(%rbp), %rdi
callq 0x1dd10
jmp 0x6bee9
leaq -0x61(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0xa660
movq -0x1c0(%rbp), %rdx
leaq 0x33c9c(%rip), %rsi     # 0x9fba3
leaq -0x60(%rbp), %rdi
callq 0x1dd10
jmp 0x6bf12
movq -0x1b8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x71bc0
jmp 0x6bf28
leaq -0x60(%rbp), %rdi
callq 0xa240
leaq -0x61(%rbp), %rdi
callq 0xa420
leaq -0x28(%rbp), %rdi
callq 0xa240
leaq -0x29(%rbp), %rdi
callq 0xa420
movl $0x0, -0x68(%rbp)
cmpl $0x10, -0x68(%rbp)
jge 0x6c187
movl $0x1, -0xa4(%rbp)
movl $0x4, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa4(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x68360
jmp 0x6bf8d
leaq -0x90(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x41cc0
movq -0x1c8(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x12db0
jmp 0x6bfb9
leaq -0x80(%rbp), %rdi
callq 0x13020
movq %rax, %rdi
callq 0x68320
movq %rax, -0x1d0(%rbp)
jmp 0x6bfd3
movq -0x1d0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x1d8(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x13080
leaq -0x90(%rbp), %rdi
callq 0x13080
leaq -0xa0(%rbp), %rdi
callq 0x41cf0
movl -0x1d8(%rbp), %eax
movl %eax, -0x6c(%rbp)
xorl %eax, %eax
movl $0x1, %ecx
cmpl -0x6c(%rbp), %ecx
movb %al, -0x1d1(%rbp)
jg 0x6c02c
cmpl $0x4, -0x6c(%rbp)
setle %al
movb %al, -0x1d1(%rbp)
movb -0x1d1(%rbp), %al
movb %al, -0x1e1(%rbp)
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0xa660
movq -0x1e0(%rbp), %rdx
leaq 0x33b55(%rip), %rsi     # 0x9fbae
leaq -0xc8(%rbp), %rdi
callq 0x1dd10
jmp 0x6c067
movq -0x1b8(%rbp), %rdi
movb -0x1e1(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0xc8(%rbp), %rdx
callq 0x722d0
jmp 0x6c088
leaq -0xc8(%rbp), %rdi
callq 0xa240
leaq -0xc9(%rbp), %rdi
callq 0xa420
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x6bf53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c0f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c0df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xa240
leaq -0x61(%rbp), %rdi
callq 0xa420
leaq -0x28(%rbp), %rdi
callq 0xa240
leaq -0x29(%rbp), %rdi
callq 0xa420
jmp 0x6c4e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c4e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c133
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x13080
leaq -0x90(%rbp), %rdi
callq 0x13080
leaq -0xa0(%rbp), %rdi
callq 0x41cf0
jmp 0x6c4e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c176
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0xa240
leaq -0xc9(%rbp), %rdi
callq 0xa420
jmp 0x6c4e5
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0xa660
movq -0x1f0(%rbp), %rdx
leaq 0x33a1b(%rip), %rsi     # 0x9fbc3
leaq -0xf0(%rbp), %rdi
callq 0x1dd10
jmp 0x6c1b6
leaq -0x119(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0xa660
movq -0x1f8(%rbp), %rdx
leaq 0x339fc(%rip), %rsi     # 0x9fbd3
leaq -0x118(%rbp), %rdi
callq 0x1dd10
jmp 0x6c1e5
movq -0x1b8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x71bc0
jmp 0x6c201
leaq -0x118(%rbp), %rdi
callq 0xa240
leaq -0x119(%rbp), %rdi
callq 0xa420
leaq -0xf0(%rbp), %rdi
callq 0xa240
leaq -0xf1(%rbp), %rdi
callq 0xa420
movl $0x1, -0x164(%rbp)
movl $0x4, -0x168(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x164(%rbp), %rsi
leaq -0x168(%rbp), %rdx
callq 0x68360
jmp 0x6c261
movl $0x2a, -0x17c(%rbp)
leaq -0x178(%rbp), %rdi
leaq -0x17c(%rbp), %rsi
callq 0x67db0
jmp 0x6c280
leaq -0x150(%rbp), %rdi
leaq -0x160(%rbp), %rsi
leaq -0x178(%rbp), %rdx
callq 0x683a0
jmp 0x6c29c
leaq -0x140(%rbp), %rdi
movq %rdi, -0x200(%rbp)
leaq -0x150(%rbp), %rsi
callq 0x72f10
movq -0x200(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x12db0
jmp 0x6c2cb
leaq -0x130(%rbp), %rdi
callq 0x13020
movq %rax, %rdi
callq 0x68320
movq %rax, -0x208(%rbp)
jmp 0x6c2e8
movq -0x208(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x210(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x13080
leaq -0x140(%rbp), %rdi
callq 0x13080
leaq -0x150(%rbp), %rdi
callq 0x42140
leaq -0x178(%rbp), %rdi
callq 0x12f90
leaq -0x160(%rbp), %rdi
callq 0x41cf0
movl -0x210(%rbp), %eax
movl %eax, -0x120(%rbp)
xorl %eax, %eax
movl $0x2b, %ecx
cmpl -0x120(%rbp), %ecx
movb %al, -0x209(%rbp)
jg 0x6c365
cmpl $0x2e, -0x120(%rbp)
setle %al
movb %al, -0x209(%rbp)
movb -0x209(%rbp), %al
movb %al, -0x219(%rbp)
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0xa660
movq -0x218(%rbp), %rdx
leaq 0x33855(%rip), %rsi     # 0x9fbe7
leaq -0x1a0(%rbp), %rdi
callq 0x1dd10
jmp 0x6c3a0
movq -0x1b8(%rbp), %rdi
movb -0x219(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x1a0(%rbp), %rdx
callq 0x722d0
jmp 0x6c3c1
leaq -0x1a0(%rbp), %rdi
callq 0xa240
leaq -0x1a1(%rbp), %rdi
callq 0xa420
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c42e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c416
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0xa240
leaq -0x119(%rbp), %rdi
callq 0xa420
leaq -0xf0(%rbp), %rdi
callq 0xa240
leaq -0xf1(%rbp), %rdi
callq 0xa420
jmp 0x6c4e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c4a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c499
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c481
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x13080
leaq -0x140(%rbp), %rdi
callq 0x13080
leaq -0x150(%rbp), %rdi
callq 0x42140
leaq -0x178(%rbp), %rdi
callq 0x12f90
leaq -0x160(%rbp), %rdi
callq 0x41cf0
jmp 0x6c4e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6c4d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0xa240
leaq -0x1a1(%rbp), %rdi
callq 0xa420
movq -0x1b8(%rbp), %rdi
callq 0x71f50
movq -0x38(%rbp), %rdi
callq 0xa650
nopw (%rax,%rax)