// File: /workspace/github_cpp_makefile_star2_O3/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 0x91c5(%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 0x43b87
leaq 0x220(%rsp), %rdi
movq %r14, %rsi
callq 0xa12b
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 0x917a(%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 0x43bb9
leaq 0x20(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0xb418
leaq 0x914e(%rip), %rdi      # 0x4cb9d
callq 0x9260
testl %eax, %eax
jne 0x43bd7
leaq 0x915d(%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 0x914c(%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 0x43ae6
movl $0xc, %ecx
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x94d0
cmpq $-0x1, %rax
je 0x43a97
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x43afc
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x92e0
testb $0x5, %bl
sete %bpl
leaq 0x420(%rsp), %rdi
callq 0x9090
movq 0x1e479(%rip), %rax     # 0x61f90
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 0x8fc1(%rip), %rsi      # 0x4cb5c
movq %rax, %rdi
callq 0x9100
movq 0x1e446(%rip), %rsi     # 0x61ff0
movq 0x1e3ef(%rip), %rdx     # 0x61fa0
movq %r14, %rdi
callq 0x94b0
movl $0x10, %edi
callq 0x9150
movq %rax, %r14
leaq 0x8faf(%rip), %rsi      # 0x4cb7c
movq %rax, %rdi
callq 0x9100
jmp 0x43bf3
movl $0x10, %edi
callq 0x9150
movq %rax, %r14
leaq 0x8fe2(%rip), %rsi      # 0x4cbcd
movq %rax, %rdi
callq 0x9100
movq 0x1e3f6(%rip), %rsi     # 0x61ff0
movq 0x1e39f(%rip), %rdx     # 0x61fa0
movq %r14, %rdi
callq 0x94b0
jmp 0x43c0b
movq %rax, %rbx
movq %r14, %rdi
callq 0x9200
jmp 0x43c59
movq %rax, %rbx
movq %r14, %rdi
callq 0x9200
jmp 0x43c63
jmp 0x43c29
jmp 0x43c2e
movq %rax, %rbx
jmp 0x43c59
movq %rax, %rbx
jmp 0x43c63
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x43c4c
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