// File: /workspace/github_cpp_makefile_star2_O1/pfnet-research[P]pml/src/mdp_expr.cpp
// Function: mdp::operator==(mdp::expr_t const&, mdp::expr_t const&)
bool operator==(expr_t const& lhs, expr_t const& rhs) {
    if (lhs.kind() != rhs.kind())
        return false;
    if (lhs.kind() == expr_kind_t::Int)
        return cast<int_expr_t>(lhs).n == cast<int_expr_t>(rhs).n;
    if (lhs.kind() == expr_kind_t::Real)
        return cast<real_expr_t>(lhs).d == cast<real_expr_t>(rhs).d;
    if (lhs.kind() == expr_kind_t::Bool)
        return cast<bool_expr_t>(lhs).b == cast<bool_expr_t>(rhs).b;
    if (lhs.kind() == expr_kind_t::Var)
        return cast<var_expr_t>(lhs).name == cast<var_expr_t>(rhs).name;
    if (lhs.kind() == expr_kind_t::Neg)
        return *cast<neg_expr_t>(lhs).inner == *cast<neg_expr_t>(rhs).inner;
    if (lhs.kind() == expr_kind_t::BinOp) {
        auto const& lhs_ = cast<binop_expr_t>(lhs);
        auto const& rhs_ = cast<binop_expr_t>(rhs);
        return
            *lhs_.lhs == *rhs_.lhs && *lhs_.rhs == *rhs_.rhs &&
            lhs_.binop_kind == rhs_.binop_kind;
    }
    if (lhs.kind() == expr_kind_t::If) {
        auto const& lhs_ = cast<if_expr_t>(lhs);
        auto const& rhs_ = cast<if_expr_t>(rhs);
        return
            *lhs_.cond == *rhs_.cond &&
            *lhs_.true_branch == *rhs_.true_branch &&
            *lhs_.false_branch == *rhs_.false_branch;
    }
    if (lhs.kind() == expr_kind_t::Min) {
        auto const& lhs_args = cast<min_expr_t>(lhs).elems;
        auto const& rhs_args = cast<min_expr_t>(rhs).elems;
        if (lhs_args.size() != rhs_args.size())
            return false;
        for (size_t i=0; i<lhs_args.size(); ++i) {
            if (*lhs_args[i] != *rhs_args[i])
                return false;
        }
        return true;
    }
    if (lhs.kind() == expr_kind_t::Max) {
        auto const& lhs_args = cast<max_expr_t>(lhs).elems;
        auto const& rhs_args = cast<max_expr_t>(rhs).elems;
        if (lhs_args.size() != rhs_args.size())
            return false;
        for (size_t i=0; i<lhs_args.size(); ++i) {
            if (*lhs_args[i] != *rhs_args[i])
                return false;
        }
        return true;
    }
    if (lhs.kind() == expr_kind_t::Floor)
        return *cast<floor_expr_t>(lhs).inner == *cast<floor_expr_t>(rhs).inner;
    if (lhs.kind() == expr_kind_t::Ceil)
        return *cast<ceil_expr_t>(lhs).inner == *cast<ceil_expr_t>(rhs).inner;
    if (lhs.kind() == expr_kind_t::Pow) {
        return
            *cast<pow_expr_t>(lhs).x == *cast<pow_expr_t>(rhs).x &&
            *cast<pow_expr_t>(lhs).y == *cast<pow_expr_t>(rhs).y;
    }
    if (lhs.kind() == expr_kind_t::Mod) {
        return
            *cast<mod_expr_t>(lhs).i == *cast<mod_expr_t>(rhs).i &&
            *cast<mod_expr_t>(lhs).n == *cast<mod_expr_t>(rhs).n;
    }
    if (lhs.kind() == expr_kind_t::Log) {
        return
            *cast<log_expr_t>(lhs).x == *cast<log_expr_t>(rhs).x &&
            *cast<log_expr_t>(lhs).b == *cast<log_expr_t>(rhs).b;
    }
    throw std::logic_error{"unreachable"};
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movl %eax, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
cmpl %eax, %ebp
jne 0x1b5a6
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
testl %eax, %eax
je 0x1b2c1
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x1, %eax
je 0x1b312
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x2, %eax
je 0x1b370
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x3, %eax
je 0x1b3c1
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x4, %eax
jne 0x1b0e6
movq %r14, %rdi
callq 0x1aefa
movq 0x8(%rax), %r14
movq %rbx, %rdi
callq 0x1aefa
movq 0x8(%rax), %rbx
jmp 0x1b05f
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x5, %eax
je 0x1b42e
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x6, %eax
jne 0x1b151
movq %r14, %rdi
callq 0x1af3e
movq %rax, %r14
movq %rbx, %rdi
callq 0x1af3e
movq %rax, %rbx
movq 0x8(%r14), %rdi
movq 0x8(%rax), %rsi
callq 0x1b04e
testb %al, %al
je 0x1b5a6
movq 0x18(%r14), %rdi
movq 0x18(%rbx), %rsi
callq 0x1b04e
testb %al, %al
je 0x1b5a6
movq 0x28(%r14), %r14
movq 0x28(%rbx), %rbx
jmp 0x1b05f
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x7, %eax
je 0x1b47d
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x8, %eax
je 0x1b51b
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0x9, %eax
jne 0x1b19d
movq %r14, %rdi
callq 0x1afa4
movq 0x8(%rax), %r14
movq %rbx, %rdi
callq 0x1afa4
movq 0x8(%rax), %rbx
jmp 0x1b05f
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0xa, %eax
jne 0x1b1c7
movq %r14, %rdi
callq 0x1afc6
movq 0x8(%rax), %r14
movq %rbx, %rdi
callq 0x1afc6
movq 0x8(%rax), %rbx
jmp 0x1b05f
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0xb, %eax
jne 0x1b219
movq %r14, %rdi
callq 0x1afe8
movq 0x8(%rax), %r15
movq %rbx, %rdi
callq 0x1afe8
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x1b04e
testb %al, %al
je 0x1b5a6
movq %r14, %rdi
callq 0x1afe8
movq 0x18(%rax), %r14
movq %rbx, %rdi
callq 0x1afe8
movq 0x18(%rax), %rbx
jmp 0x1b05f
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0xc, %eax
jne 0x1b26b
movq %r14, %rdi
callq 0x1b00a
movq 0x8(%rax), %r15
movq %rbx, %rdi
callq 0x1b00a
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x1b04e
testb %al, %al
je 0x1b5a6
movq %r14, %rdi
callq 0x1b00a
movq 0x18(%rax), %r14
movq %rbx, %rdi
callq 0x1b00a
movq 0x18(%rax), %rbx
jmp 0x1b05f
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
cmpl $0xd, %eax
jne 0x1b5c2
movq %r14, %rdi
callq 0x1b02c
movq 0x8(%rax), %r15
movq %rbx, %rdi
callq 0x1b02c
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x1b04e
testb %al, %al
je 0x1b5a6
movq %r14, %rdi
callq 0x1b02c
movq 0x18(%rax), %r14
movq %rbx, %rdi
callq 0x1b02c
movq 0x18(%rax), %rbx
jmp 0x1b05f
leaq 0x46400(%rip), %rsi     # 0x616c8
leaq 0x46409(%rip), %rdx     # 0x616d8
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1b5bd
movq %rax, %r14
leaq 0x463dc(%rip), %rsi     # 0x616c8
leaq 0x463e5(%rip), %rdx     # 0x616d8
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1b5bd
movl 0x8(%r14), %ecx
cmpl 0x8(%rax), %ecx
jmp 0x1b475
leaq 0x463af(%rip), %rsi     # 0x616c8
leaq 0x463d0(%rip), %rdx     # 0x616f0
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1b5bd
movq %rax, %r14
leaq 0x4638b(%rip), %rsi     # 0x616c8
leaq 0x463ac(%rip), %rdx     # 0x616f0
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1b5bd
movsd 0x8(%rax), %xmm0
cmpeqsd 0x8(%r14), %xmm0
movq %xmm0, %rbx
andl $0x1, %ebx
jmp 0x1b5a8
leaq 0x46351(%rip), %rsi     # 0x616c8
leaq 0x4638a(%rip), %rdx     # 0x61708
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1b5bd
movq %rax, %r14
leaq 0x4632d(%rip), %rsi     # 0x616c8
leaq 0x46366(%rip), %rdx     # 0x61708
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1b5bd
movb 0x8(%r14), %cl
cmpb 0x8(%rax), %cl
jmp 0x1b475
leaq 0x46300(%rip), %rsi     # 0x616c8
leaq 0x46351(%rip), %rdx     # 0x61720
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1b5bd
movq %rax, %r14
leaq 0x462dc(%rip), %rsi     # 0x616c8
leaq 0x4632d(%rip), %rdx     # 0x61720
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1b5bd
movq 0x10(%r14), %rdx
cmpq 0x10(%rax), %rdx
jne 0x1b5a6
testq %rdx, %rdx
je 0x1b5b9
movq 0x8(%rax), %rsi
movq 0x8(%r14), %rdi
callq 0x9300
testl %eax, %eax
jmp 0x1b475
movq %r14, %rdi
callq 0x1af1c
movq %rax, %r14
movq %rbx, %rdi
callq 0x1af1c
movq %rax, %rbx
movq 0x8(%r14), %rdi
movq 0x8(%rax), %rsi
callq 0x1b04e
testb %al, %al
je 0x1b5a6
movq 0x18(%r14), %rdi
movq 0x18(%rbx), %rsi
callq 0x1b04e
testb %al, %al
je 0x1b5a6
movl 0x28(%r14), %eax
cmpl 0x28(%rbx), %eax
sete %bl
jmp 0x1b5a8
movq %r14, %rdi
callq 0x1af60
movq %rax, %r14
movq %rbx, %rdi
callq 0x1af60
movq %rax, %r15
movq 0x10(%r14), %rax
subq 0x8(%r14), %rax
movq 0x10(%r15), %rcx
subq 0x8(%r15), %rcx
cmpq %rcx, %rax
jne 0x1b5a6
movq 0x8(%r14), %rax
cmpq %rax, 0x10(%r14)
sete %bl
je 0x1b5a8
movq (%rax), %rdi
movq 0x8(%r15), %rax
movq (%rax), %rsi
callq 0x1b04e
testb %al, %al
je 0x1b5a8
movl $0x10, %ecx
xorl %r12d, %r12d
incq %r12
movq 0x8(%r14), %rax
movq 0x10(%r14), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
cmpq %rdx, %r12
setae %bl
jae 0x1b5a8
leaq 0x10(%rcx), %r13
movq (%rax,%rcx), %rdi
movq 0x8(%r15), %rax
movq (%rax,%rcx), %rsi
callq 0x1b04e
movq %r13, %rcx
testb %al, %al
jne 0x1b4dc
jmp 0x1b5a8
movq %r14, %rdi
callq 0x1af82
movq %rax, %r14
movq %rbx, %rdi
callq 0x1af82
movq %rax, %r15
movq 0x10(%r14), %rax
subq 0x8(%r14), %rax
movq 0x10(%r15), %rcx
subq 0x8(%r15), %rcx
cmpq %rcx, %rax
jne 0x1b5a6
movq 0x8(%r14), %rax
cmpq %rax, 0x10(%r14)
sete %bl
je 0x1b5a8
movq (%rax), %rdi
movq 0x8(%r15), %rax
movq (%rax), %rsi
callq 0x1b04e
testb %al, %al
je 0x1b5a8
movl $0x10, %ecx
xorl %r12d, %r12d
incq %r12
movq 0x8(%r14), %rax
movq 0x10(%r14), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
cmpq %rdx, %r12
setae %bl
jae 0x1b5a8
leaq 0x10(%rcx), %r13
movq (%rax,%rcx), %rdi
movq 0x8(%r15), %rax
movq (%rax,%rcx), %rsi
callq 0x1b04e
movq %r13, %rcx
testb %al, %al
jne 0x1b56e
jmp 0x1b5a8
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %bl
jmp 0x1b5a8
callq 0x9530
movl $0x10, %edi
callq 0x9150
movq %rax, %rbx
leaq 0x2cd89(%rip), %rsi     # 0x4835f
movq %rax, %rdi
callq 0x93c0
movq 0x479eb(%rip), %rsi     # 0x62fd0
movq 0x479bc(%rip), %rdx     # 0x62fa8
movq %rbx, %rdi
callq 0x94b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x9200
movq %r14, %rdi
callq 0x94e0
nop