// File: pfnet-research[P]pml/src/logic.cpp
// Function: logic::subst(std::shared_ptr<logic::formula_t> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::shared_ptr<logic::formula_t> const&)
ptr<formula_t> subst(
        ptr<formula_t> const& f1,
        std::string const& var, ptr<formula_t> const& f2) {
    switch (f1->kind()) {
    case formula_kind_t::Var:
        if (cast<var_formula_t>(*f1).name == var)
            return f2;
        else
            return f1;
    case formula_kind_t::Neg:
        return make<neg_formula_t>(subst(cast<neg_formula_t>(*f1).inner, var, f2));
    case formula_kind_t::And:
        return make<and_formula_t>(
                subst(cast<and_formula_t>(*f1).lhs, var, f2),
                subst(cast<and_formula_t>(*f1).rhs, var, f2));
    case formula_kind_t::Or:
        return make<or_formula_t>(
                subst(cast<or_formula_t>(*f1).lhs, var, f2),
                subst(cast<or_formula_t>(*f1).rhs, var, f2));
    case formula_kind_t::Impl:
        return make<impl_formula_t>(
                subst(cast<impl_formula_t>(*f1).lhs, var, f2),
                subst(cast<impl_formula_t>(*f1).rhs, var, f2));
    case formula_kind_t::Eq:
        return make<eq_formula_t>(
                subst(cast<eq_formula_t>(*f1).lhs, var, f2),
                subst(cast<eq_formula_t>(*f1).rhs, var, f2));
    case formula_kind_t::Lt:
        return make<less_formula_t>(
                subst(cast<less_formula_t>(*f1).lhs, var, f2),
                subst(cast<less_formula_t>(*f1).rhs, var, f2));
    case formula_kind_t::Leq:
        return make<leq_formula_t>(
                subst(cast<leq_formula_t>(*f1).lhs, var, f2),
                subst(cast<leq_formula_t>(*f1).rhs, var, f2));
    case formula_kind_t::Geq:
        return make<geq_formula_t>(
                subst(cast<geq_formula_t>(*f1).lhs, var, f2),
                subst(cast<geq_formula_t>(*f1).rhs, var, f2));
    case formula_kind_t::Gt:
        return make<greater_formula_t>(
                subst(cast<greater_formula_t>(*f1).lhs, var, f2),
                subst(cast<greater_formula_t>(*f1).rhs, var, f2));
    case formula_kind_t::Top:
    case formula_kind_t::Bot:
        return f1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x1e8(%rbp)
movq %rdi, %rax
movq %rax, -0x1e0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x25190
movq %rax, %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movl %eax, %ecx
movq %rcx, -0x1d8(%rbp)
subl $0xb, %eax
ja 0x20448
movq -0x1d8(%rbp), %rax
leaq 0x7bee4(%rip), %rcx     # 0x9bab4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x208e0
movq %rax, %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
callq 0xf040
testb $0x1, %al
jne 0x1fc00
jmp 0x1fc15
movq -0x1e8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x16250
jmp 0x2044a
movq -0x1e8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x16250
jmp 0x2044a
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x204a0
movq %rax, %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x1fb70
movq -0x1f0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x20470
jmp 0x1fc6c
movq -0x1e8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x251b0
leaq -0x30(%rbp), %rdi
callq 0x251e0
leaq -0x40(%rbp), %rdi
callq 0x16150
jmp 0x2044a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x16150
jmp 0x2045a
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20520
movq %rax, %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x70(%rbp), %rdi
callq 0x1fb70
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20520
movq %rax, -0x1f8(%rbp)
jmp 0x1fcf0
movq -0x1f8(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x80(%rbp), %rdi
callq 0x1fb70
jmp 0x1fd0e
leaq -0x60(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x204e0
jmp 0x1fd21
movq -0x1e8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x25200
leaq -0x60(%rbp), %rdi
callq 0x25230
leaq -0x80(%rbp), %rdi
callq 0x16150
leaq -0x70(%rbp), %rdi
callq 0x16150
jmp 0x2044a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1fd74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x16150
leaq -0x70(%rbp), %rdi
callq 0x16150
jmp 0x2045a
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x205a0
movq %rax, %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xa0(%rbp), %rdi
callq 0x1fb70
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x205a0
movq %rax, -0x200(%rbp)
jmp 0x1fdc8
movq -0x200(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xb0(%rbp), %rdi
callq 0x1fb70
jmp 0x1fde9
leaq -0x90(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x20560
jmp 0x1fe05
movq -0x1e8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x25250
leaq -0x90(%rbp), %rdi
callq 0x25280
leaq -0xb0(%rbp), %rdi
callq 0x16150
leaq -0xa0(%rbp), %rdi
callq 0x16150
jmp 0x2044a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1fe67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x16150
leaq -0xa0(%rbp), %rdi
callq 0x16150
jmp 0x2045a
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20620
movq %rax, %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xd0(%rbp), %rdi
callq 0x1fb70
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20620
movq %rax, -0x208(%rbp)
jmp 0x1febe
movq -0x208(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xe0(%rbp), %rdi
callq 0x1fb70
jmp 0x1fedf
leaq -0xc0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0xe0(%rbp), %rdx
callq 0x205e0
jmp 0x1fefb
movq -0x1e8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x252a0
leaq -0xc0(%rbp), %rdi
callq 0x252d0
leaq -0xe0(%rbp), %rdi
callq 0x16150
leaq -0xd0(%rbp), %rdi
callq 0x16150
jmp 0x2044a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1ff5d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x16150
leaq -0xd0(%rbp), %rdi
callq 0x16150
jmp 0x2045a
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x206a0
movq %rax, %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x100(%rbp), %rdi
callq 0x1f6a0
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x206a0
movq %rax, -0x210(%rbp)
jmp 0x1ffb4
movq -0x210(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x110(%rbp), %rdi
callq 0x1f6a0
jmp 0x1ffd5
leaq -0xf0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x20660
jmp 0x1fff1
movq -0x1e8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x252f0
leaq -0xf0(%rbp), %rdi
callq 0x25320
leaq -0x110(%rbp), %rdi
callq 0x25000
leaq -0x100(%rbp), %rdi
callq 0x25000
jmp 0x2044a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20053
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x25000
leaq -0x100(%rbp), %rdi
callq 0x25000
jmp 0x2045a
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20720
movq %rax, %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x130(%rbp), %rdi
callq 0x1f6a0
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20720
movq %rax, -0x218(%rbp)
jmp 0x200aa
movq -0x218(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x140(%rbp), %rdi
callq 0x1f6a0
jmp 0x200cb
leaq -0x120(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x206e0
jmp 0x200e7
movq -0x1e8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x25340
leaq -0x120(%rbp), %rdi
callq 0x25370
leaq -0x140(%rbp), %rdi
callq 0x25000
leaq -0x130(%rbp), %rdi
callq 0x25000
jmp 0x2044a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20149
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x25000
leaq -0x130(%rbp), %rdi
callq 0x25000
jmp 0x2045a
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x207a0
movq %rax, %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x160(%rbp), %rdi
callq 0x1f6a0
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x207a0
movq %rax, -0x220(%rbp)
jmp 0x201a0
movq -0x220(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x170(%rbp), %rdi
callq 0x1f6a0
jmp 0x201c1
leaq -0x150(%rbp), %rdi
leaq -0x160(%rbp), %rsi
leaq -0x170(%rbp), %rdx
callq 0x20760
jmp 0x201dd
movq -0x1e8(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x25390
leaq -0x150(%rbp), %rdi
callq 0x253c0
leaq -0x170(%rbp), %rdi
callq 0x25000
leaq -0x160(%rbp), %rdi
callq 0x25000
jmp 0x2044a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2023f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x25000
leaq -0x160(%rbp), %rdi
callq 0x25000
jmp 0x2045a
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20820
movq %rax, %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x190(%rbp), %rdi
callq 0x1f6a0
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20820
movq %rax, -0x228(%rbp)
jmp 0x20296
movq -0x228(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x1a0(%rbp), %rdi
callq 0x1f6a0
jmp 0x202b7
leaq -0x180(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x207e0
jmp 0x202d3
movq -0x1e8(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x253e0
leaq -0x180(%rbp), %rdi
callq 0x25410
leaq -0x1a0(%rbp), %rdi
callq 0x25000
leaq -0x190(%rbp), %rdi
callq 0x25000
jmp 0x2044a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20335
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x25000
leaq -0x190(%rbp), %rdi
callq 0x25000
jmp 0x2045a
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x208a0
movq %rax, %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x1c0(%rbp), %rdi
callq 0x1f6a0
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x208a0
movq %rax, -0x230(%rbp)
jmp 0x2038c
movq -0x230(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x1d0(%rbp), %rdi
callq 0x1f6a0
jmp 0x203ad
leaq -0x1b0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
callq 0x20860
jmp 0x203c9
movq -0x1e8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x25430
leaq -0x1b0(%rbp), %rdi
callq 0x25460
leaq -0x1d0(%rbp), %rdi
callq 0x25000
leaq -0x1c0(%rbp), %rdi
callq 0x25000
jmp 0x2044a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20428
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x25000
leaq -0x1c0(%rbp), %rdi
callq 0x25000
jmp 0x2045a
movq -0x1e8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x16250
jmp 0x2044a
ud2
movq -0x1e0(%rbp), %rax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0xa650
nopw %cs:(%rax,%rax)