// File: pfnet-research[P]pml/src/logic.cpp
// Function: logic::operator==(logic::term_t const&, logic::term_t const&)
bool operator==(term_t const& lhs, term_t const& rhs) {
    if (lhs.kind() != rhs.kind())
        return false;
    switch (lhs.kind()) {
    case term_kind_t::Var:
        return cast<var_term_t>(lhs).name == cast<var_term_t>(rhs).name;
    case term_kind_t::Int:
        return cast<int_term_t>(lhs).n == cast<int_term_t>(rhs).n;
    case term_kind_t::Add:
        return
            *cast<add_term_t>(lhs).lhs == *cast<add_term_t>(rhs).lhs &&
            *cast<add_term_t>(lhs).rhs == *cast<add_term_t>(rhs).rhs;
    case term_kind_t::Sub:
        return
            *cast<sub_term_t>(lhs).lhs == *cast<sub_term_t>(rhs).lhs &&
            *cast<sub_term_t>(lhs).rhs == *cast<sub_term_t>(rhs).rhs;
    case term_kind_t::Mul:
        return
            *cast<mul_term_t>(lhs).lhs == *cast<mul_term_t>(rhs).lhs &&
            *cast<mul_term_t>(lhs).rhs == *cast<mul_term_t>(rhs).rhs;
    case term_kind_t::Div:
        return
            *cast<div_term_t>(lhs).lhs == *cast<div_term_t>(rhs).lhs &&
            *cast<div_term_t>(lhs).rhs == *cast<div_term_t>(rhs).rhs;
    case term_kind_t::Prob:
        return
            *cast<prob_term_t>(lhs).inner == *cast<prob_term_t>(rhs).inner;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
movl %eax, %ecx
movl -0x1c(%rbp), %eax
cmpl %ecx, %eax
je 0x2437a
movb $0x0, -0x1(%rbp)
jmp 0x246a5
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x6, %eax
ja 0x246a3
movq -0x28(%rbp), %rax
leaq 0x777dc(%rip), %rcx     # 0x9bb7c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
callq 0x21220
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x21220
movq -0x30(%rbp), %rdi
movq %rax, %rsi
addq $0x8, %rsi
callq 0xf040
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x246a5
movq -0x10(%rbp), %rdi
callq 0x21260
movl 0x8(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rdi
callq 0x21260
movq %rax, %rcx
movl -0x34(%rbp), %eax
cmpl 0x8(%rcx), %eax
sete %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x246a5
movq -0x10(%rbp), %rdi
callq 0x212a0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x212a0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x24340
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x35(%rbp)
jne 0x24453
jmp 0x24490
movq -0x10(%rbp), %rdi
callq 0x212a0
movq %rax, %rdi
addq $0x18, %rdi
callq 0x24f80
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x212a0
movq %rax, %rdi
addq $0x18, %rdi
callq 0x24f80
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x24340
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x246a5
movq -0x10(%rbp), %rdi
callq 0x212e0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x212e0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x24340
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x49(%rbp)
jne 0x244e5
jmp 0x24522
movq -0x10(%rbp), %rdi
callq 0x212e0
movq %rax, %rdi
addq $0x18, %rdi
callq 0x24f80
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
callq 0x212e0
movq %rax, %rdi
addq $0x18, %rdi
callq 0x24f80
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x24340
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x246a5
movq -0x10(%rbp), %rdi
callq 0x21320
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rdi
callq 0x21320
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x24340
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x61(%rbp)
jne 0x24577
jmp 0x245b4
movq -0x10(%rbp), %rdi
callq 0x21320
movq %rax, %rdi
addq $0x18, %rdi
callq 0x24f80
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rdi
callq 0x21320
movq %rax, %rdi
addq $0x18, %rdi
callq 0x24f80
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x24340
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x246a5
movq -0x10(%rbp), %rdi
callq 0x21360
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0x21360
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x24340
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x79(%rbp)
jne 0x2460f
jmp 0x24652
movq -0x10(%rbp), %rdi
callq 0x21360
movq %rax, %rdi
addq $0x18, %rdi
callq 0x24f80
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
callq 0x21360
movq %rax, %rdi
addq $0x18, %rdi
callq 0x24f80
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x24340
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x246a5
movq -0x10(%rbp), %rdi
callq 0x22220
movq %rax, %rdi
addq $0x8, %rdi
callq 0x115e0
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rdi
callq 0x22220
movq %rax, %rdi
addq $0x8, %rdi
callq 0x115e0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x246c0
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x246a5
ud2
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)