// File: pfnet-research[P]pml/src/logic.cpp
// Function: logic::output[abi:cxx11](logic::term_t const&, int, bool)
std::string output(term_t const& term, int accept, bool pos) {
    switch (term.kind()) {
    case term_kind_t::Var:
        return cast<var_term_t>(term).name;
    case term_kind_t::Int:
        return std::to_string(cast<int_term_t>(term).n);
    case term_kind_t::Add:
        return "(" +
            output(*cast<add_term_t>(term).lhs, accept, pos) + "+" +
            output(*cast<add_term_t>(term).rhs, accept, pos) + ")";
    case term_kind_t::Sub:
        return "(" +
            output(*cast<sub_term_t>(term).lhs, accept, pos) + "-" +
            output(*cast<sub_term_t>(term).rhs, accept, pos) + ")";
    case term_kind_t::Mul:
        return "(" +
            output(*cast<mul_term_t>(term).lhs, accept, pos) + "*" +
            output(*cast<mul_term_t>(term).rhs, accept, pos) + ")";
    case term_kind_t::Div:
        return "(" +
            output(*cast<div_term_t>(term).lhs, accept, pos) + "/" +
            output(*cast<div_term_t>(term).rhs, accept, pos) + ")";
    case term_kind_t::Prob: {
        std::string pmin =
            format("Pmin=? [F location={} & {}]",
                accept,
                output(*cast<prob_term_t>(term).inner, accept, pos));
        std::string pmax =
            format("Pmax=? [F location={} & {}]",
                accept,
                output(*cast<prob_term_t>(term).inner, accept, pos));
        if (pos)
            return pmin;
        else
            return pmax;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x400, %rsp            # imm = 0x400
movq %rdi, -0x398(%rbp)
movb %cl, %al
movq %rdi, %rcx
movq %rcx, -0x390(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
andb $0x1, %al
movb %al, -0x15(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movl %eax, %ecx
movq %rcx, -0x388(%rbp)
subl $0x6, %eax
ja 0x23147
movq -0x388(%rbp), %rax
leaq 0x793b6(%rip), %rcx     # 0x9bb30
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
callq 0x21220
movq -0x398(%rbp), %rdi
movq %rax, %rsi
addq $0x8, %rsi
callq 0xa190
jmp 0x23149
movq -0x10(%rbp), %rdi
callq 0x21260
movq -0x398(%rbp), %rdi
movl 0x8(%rax), %esi
callq 0x1e010
jmp 0x23149
movq -0x10(%rbp), %rdi
callq 0x212a0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0x98(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0x22720
movq -0x3a0(%rbp), %rdx
leaq 0x7945f(%rip), %rsi     # 0x9bc63
leaq -0x78(%rbp), %rdi
callq 0x12fb0
jmp 0x2280f
leaq 0x7695b(%rip), %rdx     # 0x99171
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1ddc0
jmp 0x22825
movq -0x10(%rbp), %rdi
callq 0x212a0
movq %rax, -0x3a8(%rbp)
jmp 0x22837
movq -0x3a8(%rbp), %rdi
addq $0x18, %rdi
callq 0x24f80
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0xc8(%rbp), %rdi
callq 0x22720
jmp 0x22862
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
callq 0x1de10
jmp 0x22878
movq -0x398(%rbp), %rdi
leaq 0x76b2c(%rip), %rdx     # 0x993b2
leaq -0x38(%rbp), %rsi
callq 0x1ddc0
jmp 0x22891
leaq -0x38(%rbp), %rdi
callq 0xa240
leaq -0xc8(%rbp), %rdi
callq 0xa240
leaq -0x58(%rbp), %rdi
callq 0xa240
leaq -0x78(%rbp), %rdi
callq 0xa240
leaq -0x98(%rbp), %rdi
callq 0xa240
jmp 0x23149
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22952
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22949
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22940
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22934
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xa240
leaq -0xc8(%rbp), %rdi
callq 0xa240
leaq -0x58(%rbp), %rdi
callq 0xa240
leaq -0x78(%rbp), %rdi
callq 0xa240
leaq -0x98(%rbp), %rdi
callq 0xa240
jmp 0x23159
movq -0x10(%rbp), %rdi
callq 0x212e0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0x148(%rbp), %rdi
movq %rdi, -0x3b0(%rbp)
callq 0x22720
movq -0x3b0(%rbp), %rdx
leaq 0x792bd(%rip), %rsi     # 0x9bc63
leaq -0x128(%rbp), %rdi
callq 0x12fb0
jmp 0x229b4
leaq 0x7925f(%rip), %rdx     # 0x9bc1a
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x1ddc0
jmp 0x229d0
movq -0x10(%rbp), %rdi
callq 0x212e0
movq %rax, -0x3b8(%rbp)
jmp 0x229e2
movq -0x3b8(%rbp), %rdi
addq $0x18, %rdi
callq 0x24f80
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0x168(%rbp), %rdi
callq 0x22720
jmp 0x22a0d
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x168(%rbp), %rdx
callq 0x1de10
jmp 0x22a29
movq -0x398(%rbp), %rdi
leaq 0x7697b(%rip), %rdx     # 0x993b2
leaq -0xe8(%rbp), %rsi
callq 0x1ddc0
jmp 0x22a45
leaq -0xe8(%rbp), %rdi
callq 0xa240
leaq -0x168(%rbp), %rdi
callq 0xa240
leaq -0x108(%rbp), %rdi
callq 0xa240
leaq -0x128(%rbp), %rdi
callq 0xa240
leaq -0x148(%rbp), %rdi
callq 0xa240
jmp 0x23149
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22b18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22b0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22b00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22af4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0xa240
leaq -0x168(%rbp), %rdi
callq 0xa240
leaq -0x108(%rbp), %rdi
callq 0xa240
leaq -0x128(%rbp), %rdi
callq 0xa240
leaq -0x148(%rbp), %rdi
callq 0xa240
jmp 0x23159
movq -0x10(%rbp), %rdi
callq 0x21320
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0x1e8(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x22720
movq -0x3c0(%rbp), %rdx
leaq 0x790f7(%rip), %rsi     # 0x9bc63
leaq -0x1c8(%rbp), %rdi
callq 0x12fb0
jmp 0x22b7a
leaq 0x7909b(%rip), %rdx     # 0x9bc1c
leaq -0x1a8(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x1ddc0
jmp 0x22b96
movq -0x10(%rbp), %rdi
callq 0x21320
movq %rax, -0x3c8(%rbp)
jmp 0x22ba8
movq -0x3c8(%rbp), %rdi
addq $0x18, %rdi
callq 0x24f80
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0x208(%rbp), %rdi
callq 0x22720
jmp 0x22bd3
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x208(%rbp), %rdx
callq 0x1de10
jmp 0x22bef
movq -0x398(%rbp), %rdi
leaq 0x767b5(%rip), %rdx     # 0x993b2
leaq -0x188(%rbp), %rsi
callq 0x1ddc0
jmp 0x22c0b
leaq -0x188(%rbp), %rdi
callq 0xa240
leaq -0x208(%rbp), %rdi
callq 0xa240
leaq -0x1a8(%rbp), %rdi
callq 0xa240
leaq -0x1c8(%rbp), %rdi
callq 0xa240
leaq -0x1e8(%rbp), %rdi
callq 0xa240
jmp 0x23149
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22cde
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22cd2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22cc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22cba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x188(%rbp), %rdi
callq 0xa240
leaq -0x208(%rbp), %rdi
callq 0xa240
leaq -0x1a8(%rbp), %rdi
callq 0xa240
leaq -0x1c8(%rbp), %rdi
callq 0xa240
leaq -0x1e8(%rbp), %rdi
callq 0xa240
jmp 0x23159
movq -0x10(%rbp), %rdi
callq 0x21360
movq %rax, %rdi
addq $0x8, %rdi
callq 0x24f80
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0x288(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x22720
movq -0x3d0(%rbp), %rdx
leaq 0x78f31(%rip), %rsi     # 0x9bc63
leaq -0x268(%rbp), %rdi
callq 0x12fb0
jmp 0x22d40
leaq 0x79cd7(%rip), %rdx     # 0x9ca1e
leaq -0x248(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x1ddc0
jmp 0x22d5c
movq -0x10(%rbp), %rdi
callq 0x21360
movq %rax, -0x3d8(%rbp)
jmp 0x22d6e
movq -0x3d8(%rbp), %rdi
addq $0x18, %rdi
callq 0x24f80
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0x2a8(%rbp), %rdi
callq 0x22720
jmp 0x22d99
leaq -0x228(%rbp), %rdi
leaq -0x248(%rbp), %rsi
leaq -0x2a8(%rbp), %rdx
callq 0x1de10
jmp 0x22db5
movq -0x398(%rbp), %rdi
leaq 0x765ef(%rip), %rdx     # 0x993b2
leaq -0x228(%rbp), %rsi
callq 0x1ddc0
jmp 0x22dd1
leaq -0x228(%rbp), %rdi
callq 0xa240
leaq -0x2a8(%rbp), %rdi
callq 0xa240
leaq -0x248(%rbp), %rdi
callq 0xa240
leaq -0x268(%rbp), %rdi
callq 0xa240
leaq -0x288(%rbp), %rdi
callq 0xa240
jmp 0x23149
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22ea4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22e98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22e8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x22e80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x228(%rbp), %rdi
callq 0xa240
leaq -0x2a8(%rbp), %rdi
callq 0xa240
leaq -0x248(%rbp), %rdi
callq 0xa240
leaq -0x268(%rbp), %rdi
callq 0xa240
leaq -0x288(%rbp), %rdi
callq 0xa240
jmp 0x23159
leaq -0x2e9(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0xa660
movq -0x3e0(%rbp), %rdx
leaq 0x78d48(%rip), %rsi     # 0x9bc1e
leaq -0x2e8(%rbp), %rdi
callq 0x1dd10
jmp 0x22ee4
movq -0x10(%rbp), %rdi
callq 0x22220
movq %rax, -0x3e8(%rbp)
jmp 0x22ef6
movq -0x3e8(%rbp), %rdi
addq $0x8, %rdi
callq 0x115e0
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0x310(%rbp), %rdi
callq 0x233f0
jmp 0x22f21
leaq -0x2c8(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
leaq -0x14(%rbp), %rdx
leaq -0x310(%rbp), %rcx
callq 0x23170
jmp 0x22f41
leaq -0x310(%rbp), %rdi
callq 0xa240
leaq -0x2e8(%rbp), %rdi
callq 0xa240
leaq -0x2e9(%rbp), %rdi
callq 0xa420
leaq -0x351(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0xa660
movq -0x3f0(%rbp), %rdx
leaq 0x78cb4(%rip), %rsi     # 0x9bc3a
leaq -0x350(%rbp), %rdi
callq 0x1dd10
jmp 0x22f94
movq -0x10(%rbp), %rdi
callq 0x22220
movq %rax, -0x3f8(%rbp)
jmp 0x22fa6
movq -0x3f8(%rbp), %rdi
addq $0x8, %rdi
callq 0x115e0
movq %rax, %rsi
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
andl $0x1, %ecx
leaq -0x378(%rbp), %rdi
callq 0x233f0
jmp 0x22fd1
leaq -0x330(%rbp), %rdi
leaq -0x350(%rbp), %rsi
leaq -0x14(%rbp), %rdx
leaq -0x378(%rbp), %rcx
callq 0x23170
jmp 0x22ff1
leaq -0x378(%rbp), %rdi
callq 0xa240
leaq -0x350(%rbp), %rdi
callq 0xa240
leaq -0x351(%rbp), %rdi
callq 0xa420
testb $0x1, -0x15(%rbp)
je 0x23110
movq -0x398(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0xa220
movl $0x1, -0x37c(%rbp)
jmp 0x2312d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x23093
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x23087
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x310(%rbp), %rdi
callq 0xa240
leaq -0x2e8(%rbp), %rdi
callq 0xa240
leaq -0x2e9(%rbp), %rdi
callq 0xa420
jmp 0x23159
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x230f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x230ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x378(%rbp), %rdi
callq 0xa240
leaq -0x350(%rbp), %rdi
callq 0xa240
leaq -0x351(%rbp), %rdi
callq 0xa420
leaq -0x2c8(%rbp), %rdi
callq 0xa240
jmp 0x23159
movq -0x398(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0xa220
movl $0x1, -0x37c(%rbp)
leaq -0x330(%rbp), %rdi
callq 0xa240
leaq -0x2c8(%rbp), %rdi
callq 0xa240
jmp 0x23149
ud2
movq -0x390(%rbp), %rax
addq $0x400, %rsp            # imm = 0x400
popq %rbp
retq
movq -0xa0(%rbp), %rdi
callq 0xa650
nopw %cs:(%rax,%rax)