// 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::term_t> const&)
ptr<formula_t> subst(
        ptr<formula_t> const& f,
        std::string const& var, ptr<term_t> const& t) {
    switch (f->kind()) {
    case formula_kind_t::Neg:
        return make<neg_formula_t>(subst(cast<neg_formula_t>(*f).inner, var, t));
    case formula_kind_t::And:
        return make<and_formula_t>(
                subst(cast<and_formula_t>(*f).lhs, var, t),
                subst(cast<and_formula_t>(*f).rhs, var, t));
    case formula_kind_t::Or:
        return make<or_formula_t>(
                subst(cast<or_formula_t>(*f).lhs, var, t),
                subst(cast<or_formula_t>(*f).rhs, var, t));
    case formula_kind_t::Impl:
        return make<impl_formula_t>(
                subst(cast<impl_formula_t>(*f).lhs, var, t),
                subst(cast<impl_formula_t>(*f).rhs, var, t));
    case formula_kind_t::Eq:
        return make<eq_formula_t>(
                subst(cast<eq_formula_t>(*f).lhs, var, t),
                subst(cast<eq_formula_t>(*f).rhs, var, t));
    case formula_kind_t::Lt:
        return make<less_formula_t>(
                subst(cast<less_formula_t>(*f).lhs, var, t),
                subst(cast<less_formula_t>(*f).rhs, var, t));
    case formula_kind_t::Leq:
        return make<leq_formula_t>(
                subst(cast<leq_formula_t>(*f).lhs, var, t),
                subst(cast<leq_formula_t>(*f).rhs, var, t));
    case formula_kind_t::Geq:
        return make<geq_formula_t>(
                subst(cast<geq_formula_t>(*f).lhs, var, t),
                subst(cast<geq_formula_t>(*f).rhs, var, t));
    case formula_kind_t::Gt:
        return make<greater_formula_t>(
                subst(cast<greater_formula_t>(*f).lhs, var, t),
                subst(cast<greater_formula_t>(*f).rhs, var, t));
    case formula_kind_t::Var:
    case formula_kind_t::Top:
    case formula_kind_t::Bot:
        return f;
    }
}

// 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 0x1f5f7
movq -0x1d8(%rbp), %rax
leaq 0x7cc98(%rip), %rcx     # 0x9ba68
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
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 0x1ed70
movq -0x1f0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x20470
jmp 0x1ee1b
movq -0x1e8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x251b0
leaq -0x30(%rbp), %rdi
callq 0x251e0
leaq -0x40(%rbp), %rdi
callq 0x16150
jmp 0x1f5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x16150
jmp 0x1f609
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 0x1ed70
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20520
movq %rax, -0x1f8(%rbp)
jmp 0x1ee9f
movq -0x1f8(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x80(%rbp), %rdi
callq 0x1ed70
jmp 0x1eebd
leaq -0x60(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x204e0
jmp 0x1eed0
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 0x1f5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1ef23
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 0x1f609
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 0x1ed70
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x205a0
movq %rax, -0x200(%rbp)
jmp 0x1ef77
movq -0x200(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xb0(%rbp), %rdi
callq 0x1ed70
jmp 0x1ef98
leaq -0x90(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x20560
jmp 0x1efb4
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 0x1f5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f016
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 0x1f609
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 0x1ed70
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20620
movq %rax, -0x208(%rbp)
jmp 0x1f06d
movq -0x208(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xe0(%rbp), %rdi
callq 0x1ed70
jmp 0x1f08e
leaq -0xc0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0xe0(%rbp), %rdx
callq 0x205e0
jmp 0x1f0aa
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 0x1f5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f10c
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 0x1f609
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 0x1e610
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x206a0
movq %rax, -0x210(%rbp)
jmp 0x1f163
movq -0x210(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x110(%rbp), %rdi
callq 0x1e610
jmp 0x1f184
leaq -0xf0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x20660
jmp 0x1f1a0
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 0x1f5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f202
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 0x1f609
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 0x1e610
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20720
movq %rax, -0x218(%rbp)
jmp 0x1f259
movq -0x218(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x140(%rbp), %rdi
callq 0x1e610
jmp 0x1f27a
leaq -0x120(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x206e0
jmp 0x1f296
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 0x1f5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f2f8
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 0x1f609
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 0x1e610
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x207a0
movq %rax, -0x220(%rbp)
jmp 0x1f34f
movq -0x220(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x170(%rbp), %rdi
callq 0x1e610
jmp 0x1f370
leaq -0x150(%rbp), %rdi
leaq -0x160(%rbp), %rsi
leaq -0x170(%rbp), %rdx
callq 0x20760
jmp 0x1f38c
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 0x1f5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f3ee
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 0x1f609
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 0x1e610
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x20820
movq %rax, -0x228(%rbp)
jmp 0x1f445
movq -0x228(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x1a0(%rbp), %rdi
callq 0x1e610
jmp 0x1f466
leaq -0x180(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x207e0
jmp 0x1f482
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 0x1f5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f4e4
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 0x1f609
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 0x1e610
movq -0x10(%rbp), %rdi
callq 0x115e0
movq %rax, %rdi
callq 0x208a0
movq %rax, -0x230(%rbp)
jmp 0x1f53b
movq -0x230(%rbp), %rsi
addq $0x18, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x1d0(%rbp), %rdi
callq 0x1e610
jmp 0x1f55c
leaq -0x1b0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
callq 0x20860
jmp 0x1f578
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 0x1f5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f5d7
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 0x1f609
movq -0x1e8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x16250
jmp 0x1f5f9
ud2
movq -0x1e0(%rbp), %rax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0xa650
nopw %cs:(%rax,%rax)