// File: /workspace/github_cpp_makefile_star2_O1/pfnet-research[P]pml/src/typechecker.cpp
// Function: check_by_PRISM(mdp::mdp_t const&, pctl::pctl_t const&)
bool check_by_PRISM(mdp::mdp_t const& mdp, pctl::pctl_t const& pctl) {
    std::ofstream mdp_output{"./output.mdp"};
    if (mdp_output.fail())
        throw std::runtime_error{"can not open file: ./output.mdp"};
    mdp_output << mdp << std::endl;

    std::ofstream pctl_output{"./output.pctl"};
    if (pctl_output.fail())
        throw std::runtime_error{"can not open file: ./output.pctl"};
    pctl.output(pctl_output);

    if (std::system("prism ./output.mdp ./output.pctl > prism_output") != 0)
        throw std::runtime_error{"can not execute prism"};

    std::ifstream prism{"prism_output"};

    std::string line;
    while (std::getline(prism, line)) {
        if (line.find("Result: true") != std::string::npos)
            return true;
    }
    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x628, %rsp            # imm = 0x628
movq %rsi, %r15
movq %rdi, %r14
leaq 0x8775(%rip), %rsi      # 0x4cb6f
leaq 0x220(%rsp), %rbx
movq %rbx, %rdi
movl $0x10, %edx
callq 0x9320
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x240(%rsp,%rax)
jne 0x445d7
leaq 0x220(%rsp), %rdi
movq %r14, %rsi
callq 0xa1b7
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x92c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x9030
movq %rax, %rdi
callq 0x91c0
leaq 0x872a(%rip), %rsi      # 0x4cb8f
leaq 0x20(%rsp), %rdi
movl $0x10, %edx
callq 0x9320
movq 0x20(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x40(%rsp,%rax)
jne 0x44609
leaq 0x20(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0xb4ec
leaq 0x86fe(%rip), %rdi      # 0x4cb9d
callq 0x9260
testl %eax, %eax
jne 0x44627
leaq 0x870d(%rip), %rsi      # 0x4cbc0
leaq 0x420(%rsp), %r15
movq %r15, %rdi
movl $0x8, %edx
callq 0x9500
leaq 0x10(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq $0x0, -0x8(%rbp)
movb $0x0, (%rbp)
movq %rsp, %r12
leaq 0x86fc(%rip), %r13      # 0x4cbe3
movq 0x420(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x92c0
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x9520
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x20(%rax,%rcx), %ebx
testb $0x5, %bl
jne 0x44536
movl $0xc, %ecx
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x94d0
cmpq $-0x1, %rax
je 0x444e7
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x4454c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x92e0
testb $0x5, %bl
sete %bpl
leaq 0x420(%rsp), %rdi
callq 0x9090
movq 0x1ea29(%rip), %rax     # 0x62f90
movq (%rax), %rbx
movq 0x18(%rax), %r15
leaq 0x28(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r15, 0x20(%rsp,%rax)
callq 0x9250
movl $0xf8, %r12d
addq %r12, %r14
movq %r14, %rdi
callq 0x90e0
leaq 0x228(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r15, 0x220(%rsp,%rax)
callq 0x9250
leaq 0x220(%rsp), %rdi
addq %r12, %rdi
callq 0x90e0
movl %ebp, %eax
addq $0x628, %rsp            # imm = 0x628
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x9150
movq %rax, %r14
leaq 0x8571(%rip), %rsi      # 0x4cb5c
movq %rax, %rdi
callq 0x9100
movq 0x1e9f6(%rip), %rsi     # 0x62ff0
movq 0x1e99f(%rip), %rdx     # 0x62fa0
movq %r14, %rdi
callq 0x94b0
movl $0x10, %edi
callq 0x9150
movq %rax, %r14
leaq 0x855f(%rip), %rsi      # 0x4cb7c
movq %rax, %rdi
callq 0x9100
jmp 0x44643
movl $0x10, %edi
callq 0x9150
movq %rax, %r14
leaq 0x8592(%rip), %rsi      # 0x4cbcd
movq %rax, %rdi
callq 0x9100
movq 0x1e9a6(%rip), %rsi     # 0x62ff0
movq 0x1e94f(%rip), %rdx     # 0x62fa0
movq %r14, %rdi
callq 0x94b0
jmp 0x4465b
movq %rax, %rbx
movq %r14, %rdi
callq 0x9200
jmp 0x446a9
movq %rax, %rbx
movq %r14, %rdi
callq 0x9200
jmp 0x446b3
jmp 0x44679
jmp 0x4467e
movq %rax, %rbx
jmp 0x446a9
movq %rax, %rbx
jmp 0x446b3
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x4469c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x92e0
leaq 0x420(%rsp), %rdi
callq 0x9090
leaq 0x20(%rsp), %rdi
callq 0x9400
leaq 0x220(%rsp), %rdi
callq 0x9400
movq %rbx, %rdi
callq 0x94e0