// File: /workspace/github_cpp_makefile_star2_O1/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 0x3498a(%rip), %rcx     # 0x47354
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%r12), %rax
movq %rax, (%rbx)
jmp 0x12da2
movq (%r12), %rdi
leaq 0x4e656(%rip), %rsi     # 0x61040
leaq 0x4e80f(%rip), %rdx     # 0x61200
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
addq $0x8, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x129a0
movq (%r12), %rdi
leaq 0x4e61d(%rip), %rsi     # 0x61040
leaq 0x4e7d6(%rip), %rdx     # 0x61200
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x13110
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x129a0
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4e725(%rip), %rax     # 0x61198
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x190f2
jmp 0x130c0
movq (%r12), %rdi
leaq 0x4e59e(%rip), %rsi     # 0x61040
leaq 0x4ea67(%rip), %rdx     # 0x61510
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
addq $0x8, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movq (%r12), %rdi
leaq 0x4e565(%rip), %rsi     # 0x61040
leaq 0x4ea2e(%rip), %rdx     # 0x61510
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x13115
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4e97d(%rip), %rax     # 0x614a8
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19222
leaq 0x4e9a7(%rip), %rax     # 0x614f8
jmp 0x130bc
movq (%r12), %rdi
leaq 0x4e4df(%rip), %rsi     # 0x61040
leaq 0x4e608(%rip), %rdx     # 0x61170
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
addq $0x8, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x129a0
movq (%r12), %rdi
leaq 0x4e4a6(%rip), %rsi     # 0x61040
leaq 0x4e5cf(%rip), %rdx     # 0x61170
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1311a
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x129a0
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4e51e(%rip), %rax     # 0x61108
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x18fc2
jmp 0x130c0
movq (%r12), %rdi
leaq 0x4e427(%rip), %rsi     # 0x61040
leaq 0x4e7d0(%rip), %rdx     # 0x613f0
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
addq $0x8, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movq (%r12), %rdi
leaq 0x4e3ee(%rip), %rsi     # 0x61040
leaq 0x4e797(%rip), %rdx     # 0x613f0
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1311f
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4e6e6(%rip), %rax     # 0x61388
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19222
leaq 0x4e710(%rip), %rax     # 0x613d8
jmp 0x130bc
movq (%r12), %rdi
leaq 0x4e368(%rip), %rsi     # 0x61040
leaq 0x4e371(%rip), %rdx     # 0x61050
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
addq $0x8, %rax
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x129a0
leaq 0x10(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x8(%rsp), %rsi
leaq 0x2f(%rsp), %rdx
movq %r12, %rcx
callq 0x18d06
movq 0x8(%rsp), %rax
movq %rax, (%rbx)
xorl %eax, %eax
movq %rax, 0x8(%rbx)
movq 0x10(%rsp), %rcx
movq %rax, 0x10(%rsp)
movq %rcx, 0x8(%rbx)
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rdi
jmp 0x130db
movq (%r12), %r13
leaq 0x4e2e2(%rip), %rsi     # 0x61040
leaq 0x4e7c3(%rip), %rdx     # 0x61528
movq %r13, %rdi
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
movq 0x10(%rax), %rdx
cmpq 0x8(%r15), %rdx
jne 0x12d9f
testq %rdx, %rdx
je 0x130fc
movq (%r15), %rsi
movq 0x8(%rax), %rdi
callq 0x9300
testl %eax, %eax
je 0x130fc
movq %r13, (%rbx)
movq 0x8(%r12), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x130e5
movq 0x501f5(%rip), %rcx     # 0x62fb0
cmpb $0x0, (%rcx)
je 0x130f6
incl 0x8(%rax)
jmp 0x130e5
movq (%r12), %rdi
leaq 0x4e269(%rip), %rsi     # 0x61040
leaq 0x4e302(%rip), %rdx     # 0x610e0
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
addq $0x8, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x129a0
movq (%r12), %rdi
leaq 0x4e230(%rip), %rsi     # 0x61040
leaq 0x4e2c9(%rip), %rdx     # 0x610e0
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x13124
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x129a0
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4e218(%rip), %rax     # 0x61078
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x18e92
jmp 0x130c0
movq (%r12), %rdi
leaq 0x4e1b1(%rip), %rsi     # 0x61040
leaq 0x4e412(%rip), %rdx     # 0x612a8
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
addq $0x8, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movq (%r12), %rdi
leaq 0x4e178(%rip), %rsi     # 0x61040
leaq 0x4e3d9(%rip), %rdx     # 0x612a8
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x13129
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4e310(%rip), %rax     # 0x61228
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19222
leaq 0x4e33a(%rip), %rax     # 0x61278
jmp 0x130bc
movq (%r12), %rdi
leaq 0x4e0f2(%rip), %rsi     # 0x61040
leaq 0x4e52b(%rip), %rdx     # 0x61480
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
addq $0x8, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movq (%r12), %rdi
leaq 0x4e0b9(%rip), %rsi     # 0x61040
leaq 0x4e4f2(%rip), %rdx     # 0x61480
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1312e
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4e441(%rip), %rax     # 0x61418
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19222
leaq 0x4e46b(%rip), %rax     # 0x61468
jmp 0x130bc
movq (%r12), %rdi
leaq 0x4e033(%rip), %rsi     # 0x61040
leaq 0x4e34c(%rip), %rdx     # 0x61360
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x1310b
addq $0x8, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movq (%r12), %rdi
leaq 0x4dffa(%rip), %rsi     # 0x61040
leaq 0x4e313(%rip), %rdx     # 0x61360
xorl %ecx, %ecx
callq 0x9340
testq %rax, %rax
je 0x13133
addq $0x18, %rax
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1253a
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4e262(%rip), %rax     # 0x612f8
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x19222
leaq 0x4e28c(%rip), %rax     # 0x61348
movq %rax, 0x10(%r14)
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x130d6
callq 0xaa12
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x130e5
callq 0xaa12
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
lock
incl 0x8(%rax)
jmp 0x130e5
movq (%r14), %rax
movq %rax, (%rbx)
movq 0x8(%r14), %rax
jmp 0x12da7
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
callq 0x9530
jmp 0x13146
jmp 0x13146
jmp 0x13146
jmp 0x13146
jmp 0x13146
jmp 0x13146
jmp 0x13146
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x13175
callq 0xaa12
jmp 0x13175
movq %rax, %rbx
movq 0x20(%rsp), %rdi
jmp 0x1317a
jmp 0x13172
jmp 0x13172
jmp 0x13172
jmp 0x13172
jmp 0x13172
jmp 0x13172
jmp 0x13172
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x13184
callq 0xaa12
movq %rbx, %rdi
callq 0x94e0