// File: /workspace/github_cpp_makefile_star2_O2/pfnet-research[P]pml/src/mdp_expr.cpp
// Function: mdp::operator<<(std::ostream&, mdp::expr_t const&)
std::ostream& operator<<(std::ostream& os, expr_t const& e) {
    switch (e.kind()) {
    case expr_kind_t::Int:
        os << cast<int_expr_t>(e).n; break;
    case expr_kind_t::Real:
        os << cast<real_expr_t>(e).d; break;
    case expr_kind_t::Bool:
        os << cast<bool_expr_t>(e).b; break;
    case expr_kind_t::Var:
        os << cast<var_expr_t>(e).name; break;
    case expr_kind_t::Neg:
        os << "!(" << *cast<neg_expr_t>(e).inner << ")";
        break;
    case expr_kind_t::BinOp:
        if (cast<binop_expr_t>(e).binop_kind != binop_kind_t::Eq) {
            os <<
                *cast<binop_expr_t>(e).lhs <<
                cast<binop_expr_t>(e).binop_kind <<
                *cast<binop_expr_t>(e).rhs;
        } else {
            os << "(" <<
                *cast<binop_expr_t>(e).lhs <<
                cast<binop_expr_t>(e).binop_kind <<
                *cast<binop_expr_t>(e).rhs << ")";
        }
        break;
    case expr_kind_t::If:
        os << "(" <<
            *cast<if_expr_t>(e).cond << "?" <<
            *cast<if_expr_t>(e).true_branch << ":" <<
            *cast<if_expr_t>(e).false_branch << ")";
        break;
    case expr_kind_t::Min: {
        auto const& args = cast<min_expr_t>(e).elems;
        os << "min(" << args[0];
        for (size_t i=1; i<args.size(); ++i)
            os << ", " << args[i];
        os << ")";
        break;
        }
    case expr_kind_t::Max: {
        auto const& args = cast<max_expr_t>(e).elems;
        os << "max(" << args[0];
        for (size_t i=1; i<args.size(); ++i)
            os << ", " << args[i];
        os << ")";
        break;
        }
    case expr_kind_t::Floor:
        os << "floor(" << *cast<floor_expr_t>(e).inner << ")";
        break;
    case expr_kind_t::Ceil:
        os << "ceil(" << *cast<ceil_expr_t>(e).inner << ")";
        break;
    case expr_kind_t::Pow:
        os << "pow(" <<
            *cast<pow_expr_t>(e).x << "" <<
            *cast<pow_expr_t>(e).y << ")";
        break;
    case expr_kind_t::Mod:
        os << "mod(" <<
            *cast<mod_expr_t>(e).i << "" <<
            *cast<mod_expr_t>(e).n << ")";
        break;
    case expr_kind_t::Log:
        os << "log(" <<
            *cast<log_expr_t>(e).x << "" <<
            *cast<log_expr_t>(e).b << ")";
        break;
    }
    return os;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x24d48(%rip), %r15     # 0x39154
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0xd, %eax
ja 0x147ad
movl %eax, %eax
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x14864
cmpl $0x8, 0x28(%rax)
je 0x14751
movq %r14, %rdi
callq 0x14864
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x143f6
movq %r14, %rdi
callq 0x14864
movl 0x28(%rax), %esi
movq %rbx, %rdi
callq 0x143d0
movq %r14, %rdi
callq 0x14864
movq 0x18(%rax), %r14
jmp 0x1440c
leaq 0x24d63(%rip), %rsi     # 0x391d9
movq %rbx, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x148ec
jmp 0x14703
leaq 0x24d56(%rip), %rsi     # 0x391eb
movq %rbx, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14952
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x143f6
leaq 0x23fde(%rip), %rsi     # 0x38499
movq %r15, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14952
jmp 0x14792
movq %r14, %rdi
callq 0x148ca
movq %rax, %r14
leaq 0x24cef(%rip), %rsi     # 0x391d4
movq %rbx, %rdi
callq 0x92d0
movq 0x8(%r14), %rsi
movq %rax, %rdi
callq 0x14e17
pushq $0x1
popq %r12
pushq $0x10
popq %r13
leaq 0x23f8f(%rip), %r15     # 0x38497
movq 0x10(%r14), %rax
subq 0x8(%r14), %rax
sarq $0x4, %rax
cmpq %rax, %r12
jae 0x1467c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x92d0
movq 0x8(%r14), %rsi
addq %r13, %rsi
movq %rax, %rdi
callq 0x14e17
incq %r12
addq $0x10, %r13
jmp 0x14508
leaq 0x24ca9(%rip), %rsi     # 0x391f0
movq %rbx, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14974
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x143f6
leaq 0x23f2c(%rip), %rsi     # 0x38499
movq %r15, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14974
jmp 0x14792
leaq 0x24c54(%rip), %rsi     # 0x391e0
movq %rbx, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x1490e
jmp 0x14703
leaq 0x24278(%rip), %rsi     # 0x38823
movq %rbx, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14886
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x143f6
leaq 0x24bfa(%rip), %rsi     # 0x391cb
movq %r15, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14886
movq 0x18(%rax), %rsi
movq %r15, %rdi
callq 0x143f6
leaq 0x24bd6(%rip), %rsi     # 0x391cd
movq %r15, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14886
movq 0x28(%rax), %rsi
jmp 0x14796
movq %r14, %rdi
callq 0x148a8
movq %rax, %r14
leaq 0x24baa(%rip), %rsi     # 0x391cf
movq %rbx, %rdi
callq 0x92d0
movq 0x8(%r14), %rsi
movq %rax, %rdi
callq 0x14e17
pushq $0x1
popq %r12
pushq $0x10
popq %r13
leaq 0x23e4f(%rip), %r15     # 0x38497
movq 0x10(%r14), %rax
subq 0x8(%r14), %rax
sarq $0x4, %rax
cmpq %rax, %r12
jae 0x1467c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x92d0
movq 0x8(%r14), %rsi
addq %r13, %rsi
movq %rax, %rdi
callq 0x14e17
incq %r12
addq $0x10, %r13
jmp 0x14648
leaq 0x21d06(%rip), %rsi     # 0x36389
movq %rbx, %rdi
jmp 0x147a8
leaq 0x24b54(%rip), %rsi     # 0x391e6
movq %rbx, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14930
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x143f6
leaq 0x23de1(%rip), %rsi     # 0x38499
movq %r15, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14930
jmp 0x14792
movq %r14, %rdi
callq 0x147fe
movzbl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0x94a0
jmp 0x147ad
leaq 0x24132(%rip), %rsi     # 0x38822
movq %rbx, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14842
movq 0x8(%rax), %rsi
jmp 0x14796
movq %r14, %rdi
callq 0x147dc
movsd 0x8(%rax), %xmm0
movq %rbx, %rdi
callq 0x9470
jmp 0x147ad
movq %r14, %rdi
callq 0x147ba
movl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0x94c0
jmp 0x147ad
movq %r14, %rdi
callq 0x14820
leaq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x9290
jmp 0x147ad
leaq 0x240cb(%rip), %rsi     # 0x38823
movq %rbx, %rdi
callq 0x92d0
movq %rax, %r15
movq %r14, %rdi
callq 0x14864
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x143f6
movq %r14, %rdi
callq 0x14864
movl 0x28(%rax), %esi
movq %r15, %rdi
callq 0x143d0
movq %r14, %rdi
callq 0x14864
movq 0x18(%rax), %rsi
movq %r15, %rdi
callq 0x143f6
leaq 0x21be4(%rip), %rsi     # 0x36389
movq %r15, %rdi
callq 0x92d0
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq