// 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::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 %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 0x28f7c(%rip), %rcx     # 0x38674
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movq %r12, %rsi
callq 0xc2b6
jmp 0xfa50
movq (%r12), %rdi
callq 0xfb0c
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf6d0
movq (%r12), %rdi
callq 0xfb0c
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf6d0
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x12c03
jmp 0xfa22
movq (%r12), %rdi
callq 0xfbb6
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
movq (%r12), %rdi
callq 0xfbb6
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x135ab
jmp 0xfa22
movq (%r12), %rdi
callq 0xfaea
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf6d0
movq (%r12), %rdi
callq 0xfaea
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf6d0
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x129eb
jmp 0xfa22
movq (%r12), %rdi
callq 0xfb72
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
movq (%r12), %rdi
callq 0xfb72
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x131ff
jmp 0xfa22
movq (%r12), %rdi
callq 0xfaa6
leaq 0x8(%rax), %rsi
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf6d0
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 0xfa41
movq (%r12), %rdi
leaq 0x4a7af(%rip), %rsi     # 0x5a058
leaq 0x4ac90(%rip), %rdx     # 0x5a540
xorl %ecx, %ecx
callq 0x9330
testq %rax, %rax
je 0xfa5f
addq $0x8, %rax
movq %rax, %rdi
movq %r15, %rsi
callq 0xa5de
testb %al, %al
je 0xf701
movq %rbx, %rdi
movq %r14, %rsi
jmp 0xf707
movq (%r12), %rdi
callq 0xfac8
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf6d0
movq (%r12), %rdi
callq 0xfac8
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf6d0
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x127d3
jmp 0xfa22
movq (%r12), %rdi
callq 0xfb2e
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
movq (%r12), %rdi
callq 0xfb2e
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x12e1b
jmp 0xfa22
movq (%r12), %rdi
callq 0xfb94
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
movq (%r12), %rdi
callq 0xfb94
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x133d5
jmp 0xfa22
movq (%r12), %rdi
callq 0xfb50
leaq 0x8(%rax), %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
movq (%r12), %rdi
callq 0xfb50
addq $0x18, %rax
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf49b
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
callq 0x9510
jmp 0xfa72
jmp 0xfa72
jmp 0xfa72
jmp 0xfa72
jmp 0xfa72
jmp 0xfa72
jmp 0xfa72
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xa248
jmp 0xfa94
jmp 0xfa91
jmp 0xfa91
jmp 0xfa91
jmp 0xfa91
jmp 0xfa91
jmp 0xfa91
jmp 0xfa91
jmp 0xfa91
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xa248
movq %rbx, %rdi
callq 0x94d0