// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq (%rsi), %rdi
movq (%rdi), %rax
callq *(%rax)
movl %eax, %eax
leaq 0x29514(%rip), %rcx     # 0x38628
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movq %r12, %rsi
callq 0xc2b6
jmp 0xf428
movq (%r12), %rdi
callq 0xfb0c
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf0ec
movq (%r12), %rdi
callq 0xfb0c
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf0ec
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x12c03
jmp 0xf3fa
movq (%r12), %rdi
callq 0xfbb6
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
movq (%r12), %rdi
callq 0xfbb6
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x135ab
jmp 0xf3fa
movq (%r12), %rdi
callq 0xfaea
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf0ec
movq (%r12), %rdi
callq 0xfaea
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf0ec
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x129eb
jmp 0xf3fa
movq (%r12), %rdi
callq 0xfb72
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
movq (%r12), %rdi
callq 0xfb72
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x131ff
jmp 0xf3fa
movq (%r12), %rdi
callq 0xfaa6
leaq 0x8(%rax), %rsi
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf0ec
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x125ff
leaq 0x28(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
andq $0x0, (%rdi)
movups %xmm0, (%rbx)
andq $0x0, -0x8(%rdi)
jmp 0xf419
movq (%r12), %rdi
callq 0xfac8
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf0ec
movq (%r12), %rdi
callq 0xfac8
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf0ec
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x127d3
jmp 0xf3fa
movq (%r12), %rdi
callq 0xfb2e
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
movq (%r12), %rdi
callq 0xfb2e
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x12e1b
jmp 0xf3fa
movq (%r12), %rdi
callq 0xfb94
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
movq (%r12), %rdi
callq 0xfb94
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x133d5
jmp 0xf3fa
movq (%r12), %rdi
callq 0xfb50
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
movq (%r12), %rdi
callq 0xfb50
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xedf0
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x13028
leaq 0x28(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
andq $0x0, (%rdi)
movups %xmm0, (%rbx)
andq $0x0, -0x8(%rdi)
callq 0xa248
leaq 0x18(%rsp), %rdi
callq 0xa248
leaq 0x8(%rsp), %rdi
callq 0xa248
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0xf445
jmp 0xf445
jmp 0xf445
jmp 0xf445
jmp 0xf445
jmp 0xf445
jmp 0xf445
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xa248
jmp 0xf467
jmp 0xf464
jmp 0xf464
jmp 0xf464
jmp 0xf464
jmp 0xf464
jmp 0xf464
jmp 0xf464
jmp 0xf464
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xa248
movq %rbx, %rdi
callq 0x94d0