// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x30, %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 0x34b34(%rip), %rcx     # 0x47354
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%r12), %rax
movq %rax, (%rbx)
jmp 0x12bd7
movq (%r12), %rdi
leaq 0x4d828(%rip), %rsi     # 0x60068
leaq 0x4d9e1(%rip), %rdx     # 0x60228
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
addq $0x8, %rax
movq %rsp, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x127f6
movq (%r12), %rdi
leaq 0x4d7f1(%rip), %rsi     # 0x60068
leaq 0x4d9aa(%rip), %rdx     # 0x60228
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f35
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x127f6
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4d8f9(%rip), %rax     # 0x601c0
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %rsp, %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x18ed8
jmp 0x12ee5
movq (%r12), %rdi
leaq 0x4d774(%rip), %rsi     # 0x60068
leaq 0x4dc3d(%rip), %rdx     # 0x60538
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
addq $0x8, %rax
movq %rsp, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movq (%r12), %rdi
leaq 0x4d73d(%rip), %rsi     # 0x60068
leaq 0x4dc06(%rip), %rdx     # 0x60538
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f3a
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4db55(%rip), %rax     # 0x604d0
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %rsp, %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19002
leaq 0x4db81(%rip), %rax     # 0x60520
jmp 0x12ee1
movq (%r12), %rdi
leaq 0x4d6b9(%rip), %rsi     # 0x60068
leaq 0x4d7e2(%rip), %rdx     # 0x60198
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
addq $0x8, %rax
movq %rsp, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x127f6
movq (%r12), %rdi
leaq 0x4d682(%rip), %rsi     # 0x60068
leaq 0x4d7ab(%rip), %rdx     # 0x60198
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f3f
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x127f6
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4d6fa(%rip), %rax     # 0x60130
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %rsp, %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x18dae
jmp 0x12ee5
movq (%r12), %rdi
leaq 0x4d605(%rip), %rsi     # 0x60068
leaq 0x4d9ae(%rip), %rdx     # 0x60418
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
addq $0x8, %rax
movq %rsp, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movq (%r12), %rdi
leaq 0x4d5ce(%rip), %rsi     # 0x60068
leaq 0x4d977(%rip), %rdx     # 0x60418
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f44
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4d8c6(%rip), %rax     # 0x603b0
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %rsp, %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19002
leaq 0x4d8f2(%rip), %rax     # 0x60400
jmp 0x12ee1
movq (%r12), %rdi
leaq 0x4d54a(%rip), %rsi     # 0x60068
leaq 0x4d553(%rip), %rdx     # 0x60078
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
addq $0x8, %rax
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x127f6
leaq 0x8(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq %rsp, %rsi
leaq 0x2f(%rsp), %rdx
movq %r12, %rcx
callq 0x18b04
movaps (%rsp), %xmm0
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movups %xmm0, (%rbx)
movq %rax, (%rsp)
movq 0x20(%rsp), %rdi
jmp 0x12f00
movq (%r12), %r13
leaq 0x4d4d5(%rip), %rsi     # 0x60068
leaq 0x4d9b6(%rip), %rdx     # 0x60550
movq %r13, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
movq 0x10(%rax), %rdx
cmpq 0x8(%r15), %rdx
jne 0x12bd4
testq %rdx, %rdx
je 0x12f21
movq (%r15), %rsi
movq 0x8(%rax), %rdi
callq 0x9300
testl %eax, %eax
je 0x12f21
movq %r13, (%rbx)
movq 0x8(%r12), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x12f0a
movq 0x4f3c0(%rip), %rcx     # 0x61fb0
cmpb $0x0, (%rcx)
je 0x12f1b
incl 0x8(%rax)
jmp 0x12f0a
movq (%r12), %rdi
leaq 0x4d45c(%rip), %rsi     # 0x60068
leaq 0x4d4f5(%rip), %rdx     # 0x60108
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
addq $0x8, %rax
movq %rsp, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x127f6
movq (%r12), %rdi
leaq 0x4d425(%rip), %rsi     # 0x60068
leaq 0x4d4be(%rip), %rdx     # 0x60108
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f49
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x127f6
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4d40d(%rip), %rax     # 0x600a0
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %rsp, %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x18c84
jmp 0x12ee5
movq (%r12), %rdi
leaq 0x4d3a8(%rip), %rsi     # 0x60068
leaq 0x4d609(%rip), %rdx     # 0x602d0
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
addq $0x8, %rax
movq %rsp, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movq (%r12), %rdi
leaq 0x4d371(%rip), %rsi     # 0x60068
leaq 0x4d5d2(%rip), %rdx     # 0x602d0
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f4e
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4d509(%rip), %rax     # 0x60250
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %rsp, %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19002
leaq 0x4d535(%rip), %rax     # 0x602a0
jmp 0x12ee1
movq (%r12), %rdi
leaq 0x4d2ed(%rip), %rsi     # 0x60068
leaq 0x4d726(%rip), %rdx     # 0x604a8
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
addq $0x8, %rax
movq %rsp, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movq (%r12), %rdi
leaq 0x4d2b6(%rip), %rsi     # 0x60068
leaq 0x4d6ef(%rip), %rdx     # 0x604a8
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f53
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4d63e(%rip), %rax     # 0x60440
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %rsp, %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19002
leaq 0x4d66a(%rip), %rax     # 0x60490
jmp 0x12ee1
movq (%r12), %rdi
leaq 0x4d232(%rip), %rsi     # 0x60068
leaq 0x4d54b(%rip), %rdx     # 0x60388
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f30
addq $0x8, %rax
movq %rsp, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movq (%r12), %rdi
leaq 0x4d1fb(%rip), %rsi     # 0x60068
leaq 0x4d514(%rip), %rdx     # 0x60388
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x12f58
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1239d
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4d463(%rip), %rax     # 0x60320
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %rsp, %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19002
leaq 0x4d48f(%rip), %rax     # 0x60370
movq %rax, 0x10(%r14)
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x12efb
callq 0xa946
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x12f0a
callq 0xa946
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
lock
incl 0x8(%rax)
jmp 0x12f0a
movq (%r14), %rax
movq %rax, (%rbx)
movq 0x8(%r14), %rax
jmp 0x12bdc
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
jmp 0x12f6b
jmp 0x12f6b
jmp 0x12f6b
jmp 0x12f6b
jmp 0x12f6b
jmp 0x12f6b
jmp 0x12f6b
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x12f9a
callq 0xa946
jmp 0x12f9a
movq %rax, %rbx
movq 0x20(%rsp), %rdi
jmp 0x12f9f
jmp 0x12f97
jmp 0x12f97
jmp 0x12f97
jmp 0x12f97
jmp 0x12f97
jmp 0x12f97
jmp 0x12f97
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x12fa9
callq 0xa946
movq %rbx, %rdi
callq 0x94e0