// File: /workspace/github_cpp_makefile_star2_O1/pfnet-research[P]pml/src/translate_to_mdp.cpp
// Function: calc_binop_bound(value_info_t const&, value_info_t const&, ast::expr_kind_t)
value_info_t calc_binop_bound(
        value_info_t const& lhs,
        value_info_t const& rhs,
        ast::expr_kind_t op) {
    switch (op) {
    case ast::expr_kind_t::Add:
        return value_info_t {
            format("({}+{})", lhs.name, rhs.name),
            *lhs.bound + *rhs.bound
        };
    case ast::expr_kind_t::Sub:
        return value_info_t {
            format("({}-{})", lhs.name, rhs.name),
            *lhs.bound - *rhs.bound
        };
    case ast::expr_kind_t::Mul:
        return value_info_t {
            format("({}*{})", lhs.name, rhs.name),
            *lhs.bound * *rhs.bound
        };
    case ast::expr_kind_t::Div:
        return value_info_t {
            format("({}/{})", lhs.name, rhs.name),
            *lhs.bound / *rhs.bound
        };
    case ast::expr_kind_t::Eq:
        return value_info_t {
            format("{}={}", lhs.name, rhs.name),
            util::nullopt
        };
    case ast::expr_kind_t::Neq:
        return value_info_t {
            format("({}!={})", lhs.name, rhs.name),
            util::nullopt
        };
    case ast::expr_kind_t::Leq:
        return value_info_t {
            format("({}<={})", lhs.name, rhs.name),
            util::nullopt
        };
    case ast::expr_kind_t::Geq:
        return value_info_t {
            format("({}>={})", lhs.name, rhs.name),
            util::nullopt
        };
    case ast::expr_kind_t::And:
        return value_info_t {
            format("({}&{})", lhs.name, rhs.name),
            util::nullopt
        };
    case ast::expr_kind_t::Or:
        return value_info_t {
            format("({}|{})", lhs.name, rhs.name),
            util::nullopt
        };
    default:
        throw std::logic_error{"invalid binop"};
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
addl $-0x6, %ecx
cmpl $0xa, %ecx
ja 0x3f254
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xc461(%rip), %rax      # 0x4b3e4
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc529(%rip), %rsi      # 0x4b4c6
leaq 0xc529(%rip), %rdx      # 0x4b4cd
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
movl 0x20(%r14), %eax
movl 0x24(%r14), %ecx
addl 0x20(%r15), %eax
addl 0x24(%r15), %ecx
jmp 0x3f14f
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc528(%rip), %rsi      # 0x4b50f
leaq 0xc528(%rip), %rdx      # 0x4b516
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
jmp 0x3f22a
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc4e6(%rip), %rsi      # 0x4b507
leaq 0xc4e6(%rip), %rdx      # 0x4b50e
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
jmp 0x3f22a
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc48b(%rip), %rsi      # 0x4b4e6
leaq 0xc489(%rip), %rdx      # 0x4b4eb
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
jmp 0x3f22a
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc439(%rip), %rsi      # 0x4b4ce
leaq 0xc439(%rip), %rdx      # 0x4b4d5
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
movl 0x20(%r15), %eax
movl 0x24(%r15), %ecx
subl 0x24(%r14), %eax
subl 0x20(%r14), %ecx
jmp 0x3f14f
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc40d(%rip), %rsi      # 0x4b4ec
leaq 0xc40e(%rip), %rdx      # 0x4b4f4
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
jmp 0x3f22a
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc3bd(%rip), %rsi      # 0x4b4d6
leaq 0xc3bd(%rip), %rdx      # 0x4b4dd
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
movl 0x20(%r14), %eax
movl 0x24(%r14), %ecx
imull 0x20(%r15), %eax
imull 0x24(%r15), %ecx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x20(%rbx)
jmp 0x3f1ef
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc38e(%rip), %rsi      # 0x4b4fe
leaq 0xc38f(%rip), %rdx      # 0x4b506
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
jmp 0x3f22a
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc334(%rip), %rsi      # 0x4b4de
leaq 0xc334(%rip), %rdx      # 0x4b4e5
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
movl 0x24(%r14), %edi
movl 0x20(%r15), %eax
movl 0x24(%r15), %ecx
cltd
idivl %edi
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %edi
shlq $0x20, %rax
orq %rax, %rsi
movq %rsi, 0x20(%rbx)
movb $0x1, 0x28(%rbx)
jmp 0x3f22e
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc2ef(%rip), %rsi      # 0x4b4f5
leaq 0xc2f0(%rip), %rdx      # 0x4b4fd
leaq 0x8(%rsp), %rdi
callq 0x11866
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3f2de
movb $0x0, 0x28(%rbx)
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3f245
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x92e0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl $0x10, %edi
callq 0x9150
movq %rax, %r14
leaq 0xc2af(%rip), %rsi      # 0x4b517
movq %rax, %rdi
callq 0x93c0
movq 0x23d59(%rip), %rsi     # 0x62fd0
movq 0x23d2a(%rip), %rdx     # 0x62fa8
movq %r14, %rdi
callq 0x94b0
movq %rax, %rbx
movq %r14, %rdi
callq 0x9200
jmp 0x3f2d6
jmp 0x3f2a5
jmp 0x3f2a5
jmp 0x3f2a5
jmp 0x3f2a5
jmp 0x3f2a5
jmp 0x3f2a5
jmp 0x3f2a5
jmp 0x3f2a5
jmp 0x3f2a5
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3f2d6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0x3f2d6
jmp 0x3f2d3
jmp 0x3f2d3
jmp 0x3f2d3
jmp 0x3f2d3
jmp 0x3f2d3
jmp 0x3f2d3
jmp 0x3f2d3
jmp 0x3f2d3
jmp 0x3f2d3
movq %rax, %rbx
movq %rbx, %rdi
callq 0x94e0