// File: /workspace/github_cpp_makefile_star2_O2/pfnet-research[P]pml/src/translate_to_mdp.cpp
// Function: create_rand_case(int, int)
mdp_with_info_t create_rand_case(int start, int end) {
    int from = translation_data::fresh_location();
    int to = translation_data::fresh_location();
    auto rand_var = translation_data::fresh_var();

    mdp::command_t command {
        make<mdp::binop_expr_t>(
                make<mdp::var_expr_t>("location"),
                make<mdp::int_expr_t>(from),
                mdp::binop_kind_t::Eq),
        {}
    };

    auto prob = make<mdp::binop_expr_t>(
            make<mdp::int_expr_t>(1),
            make<mdp::int_expr_t>(end - start + 1),
            mdp::binop_kind_t::Div);
    auto next = make<mdp::binop_expr_t>(
            make<mdp::var_expr_t>("location'"),
            make<mdp::int_expr_t>(to),
            mdp::binop_kind_t::Eq);
    for (int i=start; i<=end; ++i) {
        auto branch = make<mdp::binop_expr_t>(
                next,
                make<mdp::binop_expr_t>(
                    make<mdp::var_expr_t>(rand_var + "'"),
                    make<mdp::int_expr_t>(i),
                    mdp::binop_kind_t::Eq),
                mdp::binop_kind_t::And);
        command.branches.push_back(mdp::branch_t {prob, branch});
    }

    mdp::mdp_t mdp {
        "default",
        {
            mdp::variable_t {
                "location",
                bound_t{from, to}, from
            },
            mdp::variable_t {
                rand_var,
                bound_t{start, end}, start
            }
        },
        {}, // constants
        {command}
    };

    return mdp_with_info_t {
        mdp, from, to,
        value_info_t {
            rand_var, {bound_t{start, end}}
        }
    };
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdx, 0x20(%rsp)
movl %esi, 0x8(%rsp)
movq %rdi, %r14
movl 0x2c6d1(%rip), %eax     # 0x5c2d0
leal 0x1(%rax), %ecx
movl %eax, 0x10(%rsp)
addl $0x2, %eax
movl %eax, 0x2c6c1(%rip)     # 0x5c2d0
movl %ecx, 0xc(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x3243a
leaq 0x651d(%rip), %rsi      # 0x36144
leaq 0x120(%rsp), %rdi
callq 0x2c735
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x32736
leaq 0x68(%rsp), %rcx
movl $0x8, (%rcx)
leaq 0xb0(%rsp), %rdi
leaq 0x120(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x2c4a2
leaq 0xb8(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
movaps %xmm0, 0x1a0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rdi)
movaps %xmm0, 0x1b0(%rsp)
andq $0x0, 0x1c0(%rsp)
callq 0xa248
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0xa248
leaq 0x128(%rsp), %rdi
callq 0xa248
movl $0x1, -0x8(%rbx)
leaq 0xb0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2c961
movq 0x20(%rsp), %rax
subl 0x8(%rsp), %eax
incl %eax
leaq 0x68(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x120(%rsp), %rdi
callq 0x2c961
leaq 0x58(%rsp), %rcx
movl $0x1, (%rcx)
leaq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x2cac6
leaq 0x128(%rsp), %rdi
callq 0xa248
leaq 0xb8(%rsp), %rdi
callq 0xa248
leaq 0xc757(%rip), %rsi      # 0x3c48b
leaq 0xb0(%rsp), %rdi
callq 0x2cd81
leaq 0x120(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x32736
movq %r14, 0x88(%rsp)
leaq 0x30(%rsp), %rcx
movl $0x8, (%rcx)
leaq 0x58(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x2c4a2
leaq 0x128(%rsp), %rdi
callq 0xa248
leaq 0xb8(%rsp), %rdi
callq 0xa248
leaq 0xb0(%rsp), %r12
leaq 0x68(%rsp), %rbp
leaq 0x90(%rsp), %rbx
leaq 0x30(%rsp), %r15
leaq 0x120(%rsp), %r14
leaq 0xa0(%rsp), %r13
movl 0x8(%rsp), %eax
movl %eax, 0x28(%rsp)
cmpl 0x20(%rsp), %eax
jg 0x2feb1
movq %r12, %rdi
leaq 0x180(%rsp), %rsi
leaq 0xc6af(%rip), %rdx      # 0x3c497
callq 0x3249c
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3294b
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
callq 0x32736
movl $0x8, 0x1c(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
leaq 0x1c(%rsp), %rcx
callq 0x2c4a2
movl $0xa, 0x18(%rsp)
movq %r14, %rdi
leaq 0x58(%rsp), %rsi
movq %r15, %rdx
leaq 0x18(%rsp), %rcx
callq 0x327de
leaq 0x38(%rsp), %rdi
callq 0xa248
leaq 0x98(%rsp), %rdi
callq 0xa248
leaq 0x70(%rsp), %rdi
callq 0xa248
movq %r12, %rdi
callq 0x9130
movq %r12, %rdi
movq %r13, %rsi
callq 0x336dc
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
callq 0x336dc
leaq 0x1b0(%rsp), %rdi
movq %r12, %rsi
callq 0x336f0
movq %r12, %rdi
callq 0xa218
leaq 0x128(%rsp), %rdi
callq 0xa248
movl 0x28(%rsp), %eax
incl %eax
jmp 0x2fdc8
leaq 0xc59a(%rip), %rsi      # 0x3c452
leaq 0xb0(%rsp), %rdi
leaq 0x1c(%rsp), %rdx
callq 0xeb2e
leaq 0x6273(%rip), %rsi      # 0x36144
leaq 0x68(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0xeb2e
movl 0x10(%rsp), %ecx
leaq 0x90(%rsp), %rdx
movl %ecx, (%rdx)
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rdx)
leaq 0x120(%rsp), %r12
leaq 0x68(%rsp), %rsi
movq %r12, %rdi
callq 0x2c314
leaq 0x150(%rsp), %r15
leaq 0x28(%rsp), %rdx
movl 0x8(%rsp), %ecx
movl %ecx, (%rdx)
movq 0x20(%rsp), %rax
movl %eax, 0x4(%rdx)
leaq 0x180(%rsp), %rsi
movq %r15, %rdi
callq 0x2c314
leaq 0xd0(%rsp), %rbx
leaq 0x120(%rsp), %rsi
pushq $0x2
popq %rdx
leaq 0x17(%rsp), %rcx
movq %rbx, %rdi
callq 0x2c33c
xorps %xmm0, %xmm0
movups %xmm0, 0xe8(%rsp)
andq $0x0, 0xf8(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x2d1dc
leaq 0x100(%rsp), %rdi
leaq 0x30(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0x16(%rsp), %rcx
callq 0x2c3b0
leaq 0x30(%rsp), %rdi
callq 0xa198
pushq $0x30
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0xa3e2
addq $-0x30, %rbx
cmpq $-0x30, %rbx
jne 0x2ffa2
leaq 0x68(%rsp), %rdi
callq 0x9130
leaq 0xb0(%rsp), %rsi
movq 0x88(%rsp), %rbx
movq %rbx, %rdi
callq 0x324d4
movl 0x10(%rsp), %eax
movl %eax, 0x68(%rbx)
movl 0xc(%rsp), %eax
movl %eax, 0x6c(%rbx)
leaq 0x70(%rbx), %rdi
leaq 0x180(%rsp), %rsi
callq 0x93a0
movq 0x20(%rsp), %rcx
shlq $0x20, %rcx
movl 0x8(%rsp), %eax
orq %rcx, %rax
movq %rax, 0x90(%rbx)
movb $0x1, 0x98(%rbx)
leaq 0xb0(%rsp), %rdi
callq 0xa08a
leaq 0x60(%rsp), %rdi
callq 0xa248
leaq 0xa8(%rsp), %rdi
callq 0xa248
leaq 0x1a0(%rsp), %rdi
callq 0xa198
leaq 0x180(%rsp), %rdi
callq 0x9130
movq %rbx, %rax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0xa08a
jmp 0x3007e
movq %rax, %r14
leaq 0xb0(%rsp), %rdi
callq 0xa08a
jmp 0x30210
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0xa198
jmp 0x300a2
movq %rax, %r14
leaq 0xe8(%rsp), %rdi
callq 0xa108
movq %rbx, %rdi
callq 0xa12a
jmp 0x300bc
movq %rax, %r14
pushq $0x30
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0xa3e2
addq $-0x30, %rbx
cmpq $-0x30, %rbx
jne 0x300bf
movb $0x1, %bl
jmp 0x300ec
movq %rax, %r14
xorl %ebx, %ebx
jmp 0x300ec
movq %rax, %r14
xorl %ebx, %ebx
movq %r12, %r15
leaq 0x68(%rsp), %rdi
callq 0x9130
cmpq %r15, %r12
sete %al
orb %bl, %al
jne 0x30203
leaq 0x120(%rsp), %rbx
addq $-0x30, %r15
movq %r15, %rdi
callq 0xa3e2
cmpq %rbx, %r15
jne 0x3010c
jmp 0x30203
jmp 0x30200
jmp 0x301fb
movq %rax, %r14
leaq 0x128(%rsp), %rdi
callq 0xa248
jmp 0x30141
movq %rax, %r14
leaq 0xb8(%rsp), %rdi
jmp 0x30215
movq %rax, %r14
jmp 0x3021a
movq %rax, %r14
leaq 0x128(%rsp), %rdi
callq 0xa248
jmp 0x3016b
movq %rax, %r14
leaq 0xb8(%rsp), %rdi
jmp 0x30222
movq %rax, %r14
jmp 0x30227
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0xa248
jmp 0x30192
movq %rax, %r14
leaq 0x128(%rsp), %rdi
callq 0xa248
jmp 0x30234
movq %rax, %r14
jmp 0x30234
movq %rax, %r14
jmp 0x301d0
movq %rax, %r14
jmp 0x301c3
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0xa248
leaq 0x98(%rsp), %rdi
callq 0xa248
leaq 0x70(%rsp), %rdi
callq 0xa248
jmp 0x30203
movq %rax, %r14
leaq 0xb0(%rsp), %rdi
callq 0xa218
leaq 0x128(%rsp), %rdi
callq 0xa248
jmp 0x30210
movq %rax, %r14
jmp 0x30210
movq %rax, %r14
leaq 0xb0(%rsp), %rdi
callq 0x9130
leaq 0x60(%rsp), %rdi
callq 0xa248
leaq 0xa8(%rsp), %rdi
callq 0xa248
leaq 0x1a0(%rsp), %rdi
callq 0xa198
leaq 0x180(%rsp), %rdi
callq 0x9130
movq %r14, %rdi
callq 0x94d0