// File: /workspace/github_cpp_makefile_star2_O1/bonetblai[P]mdp-engine/ctp3/../engine/plain_check.h
// Function: bool Algorithm::check_solved<state_t>(Problem::problem_t<state_t> const&, state_t const&, Problem::hash_t<state_t>&, float)
bool check_solved(const Problem::problem_t<T> &problem,
                  const T &s,
                  Problem::hash_t<T> &hash,
                  float epsilon) {
    std::list<std::pair<T, Hash::data_t*> > open, closed;

    std::vector<std::pair<T, float> > outcomes;
    Hash::data_t *dptr = hash.data_ptr(s);
    if( !dptr->solved() ) {
        open.push_back(std::make_pair(s, dptr));
        dptr->mark();
    }

    bool rv = true;
    while( !open.empty() ) {
        std::pair<T, Hash::data_t*> n = open.back();
        closed.push_back(n);
        open.pop_back();
        if( problem.terminal(n.first) ) continue;

        std::pair<Problem::action_t, float> p = hash.best_q_value(n.first);
        if( fabs(p.second - n.second->value()) > epsilon ) {
            rv = false;
            continue;
        }

        problem.next(n.first, p.first, outcomes);
        unsigned osize = outcomes.size();

        for( unsigned i = 0; i < osize; ++ i ) {
            Hash::data_t *dptr = hash.data_ptr(outcomes[i].first);
            if( !dptr->solved() && !dptr->marked() ) {
                open.push_back(std::make_pair(outcomes[i].first, dptr));
                dptr->mark();
            }
        }
    }

    if( rv ) {
        while( !closed.empty() ) {
            closed.back().second->solve();
            closed.pop_back();
        }
    } else {
        while( !closed.empty() ) {
            std::pair<Problem::action_t, float> p = hash.best_q_value(closed.back().first);
            closed.back().second->update(p.second);
            closed.back().second->unmark();
            hash.inc_updates();
            closed.pop_back();
        }
    }
    return rv;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movss %xmm0, 0x3c(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbp
leaq 0x8(%rsp), %rcx
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
xorl %eax, %eax
movq %rax, 0x10(%rcx)
leaq 0x20(%rsp), %r15
movq %r15, 0x8(%r15)
movq %r15, (%r15)
movq %rax, 0x10(%r15)
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq %rdx, %rdi
callq 0x1020a
movq %rax, %rbx
cmpb $0x0, 0x4(%rax)
jne 0x15658
xorps %xmm0, %xmm0
leaq 0x68(%rsp), %rdi
movups %xmm0, 0x34(%rdi)
movups %xmm0, 0x24(%rdi)
movups %xmm0, 0x14(%rdi)
movups %xmm0, 0x4(%rdi)
xorl %eax, %eax
movq %rax, 0x44(%rdi)
movb $0x1, 0x5c(%rdi)
movq %rax, 0x60(%rdi)
movq %r13, %rsi
callq 0xd546
leaq 0x68(%rsp), %rsi
movq %rbx, 0x70(%rsi)
leaq 0x8(%rsp), %rdi
callq 0x123c2
leaq 0x8(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x6060
incq 0x10(%r13)
cmpb $0x0, 0xc4(%rsp)
jne 0x15654
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x15654
callq 0x6340
movb $0x1, 0x5(%rbx)
leaq 0x8(%rsp), %r13
cmpq %r13, 0x8(%rsp)
je 0x1589c
movb $0x1, %al
movl %eax, 0x4(%rsp)
leaq 0x68(%rsp), %rbx
movq %rbp, 0x58(%rsp)
movq 0x10(%rsp), %r15
leaq 0x10(%r15), %rsi
leaq 0x6c(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x40(%rax)
movb $0x1, 0xc4(%rsp)
movq %rcx, 0xc8(%rsp)
movq %rbx, %rdi
callq 0xd546
movq 0x80(%r15), %rax
movq %rax, 0xd8(%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1245a
movq %rax, %rdi
movq %r14, %rsi
callq 0x6060
incq 0x30(%rsp)
movq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0x1242c
movq (%rbp), %rax
movq %rbp, %rdi
movq %rbx, %rsi
callq *0x20(%rax)
testb %al, %al
jne 0x1586a
movq %r12, %rdi
movq %rbx, %rsi
callq 0x10b16
movq %rax, %rcx
shrq $0x20, %rcx
movd %ecx, %xmm0
movq 0xd8(%rsp), %rcx
subss (%rcx), %xmm0
andps 0x17970(%rip), %xmm0    # 0x2d0a0
ucomiss 0x3c(%rsp), %xmm0
jbe 0x15744
movl $0x0, 0x4(%rsp)
jmp 0x1586a
movq (%rbp), %r8
movq %rbp, %rdi
movq %rbx, %rsi
movl %eax, %edx
leaq 0x40(%rsp), %rcx
callq *0x60(%r8)
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
sarq $0x3, %rax
movabsq $-0x1111111111111111, %rcx # imm = 0xEEEEEEEEEEEEEEEF
imulq %rcx, %rax
testl %eax, %eax
je 0x1586a
movl %eax, %eax
imulq $0x78, %rax, %r14
xorl %r15d, %r15d
movq %r14, 0x60(%rsp)
movq 0x40(%rsp), %rsi
addq %r15, %rsi
movq %r12, %rdi
callq 0x1020a
movq %rax, %rbp
cmpb $0x0, 0x4(%rax)
jne 0x15853
cmpb $0x0, 0x5(%rbp)
jne 0x15853
movq %r12, %r14
movq %rbx, %r12
movq 0x40(%rsp), %rsi
addq %r15, %rsi
xorl %eax, %eax
leaq 0xe4(%rsp), %rcx
movq %rax, 0x40(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rcx)
movups %xmm0, 0x20(%rcx)
movups %xmm0, 0x10(%rcx)
movups %xmm0, (%rcx)
movb $0x1, 0x13c(%rsp)
movq %rax, 0x140(%rsp)
leaq 0xe0(%rsp), %r13
movq %r13, %rdi
callq 0xd546
movq %rbp, 0x150(%rsp)
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x123c2
movq %rax, %rdi
movq %rbx, %rsi
callq 0x6060
incq 0x18(%rsp)
cmpb $0x0, 0x13c(%rsp)
jne 0x15844
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x15844
callq 0x6340
movb $0x1, 0x5(%rbp)
movq %r12, %rbx
movq %r14, %r12
movq 0x60(%rsp), %r14
addq $0x78, %r15
cmpq %r15, %r14
jne 0x1578b
movq 0x58(%rsp), %rbp
leaq 0x8(%rsp), %r13
cmpb $0x0, 0xc4(%rsp)
jne 0x15886
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x15886
callq 0x6340
cmpq %r13, 0x8(%rsp)
jne 0x15678
leaq 0x20(%rsp), %r15
movl 0x4(%rsp), %ebx
jmp 0x1589e
movb $0x1, %bl
movq 0x20(%rsp), %rax
testb $0x1, %bl
je 0x158ce
cmpq %r15, %rax
je 0x1590e
movq 0x28(%rsp), %rsi
movq 0x80(%rsi), %rax
movb $0x1, 0x4(%rax)
movq %r15, %rdi
callq 0x1242c
cmpq %r15, 0x20(%rsp)
jne 0x158ad
jmp 0x1590e
cmpq %r15, %rax
je 0x1590e
movq 0x28(%rsp), %rsi
addq $0x10, %rsi
movq %r12, %rdi
callq 0x10b16
shrq $0x20, %rax
movq 0x28(%rsp), %rsi
movq 0x80(%rsi), %rcx
movl %eax, (%rcx)
movb $0x0, 0x5(%rcx)
incl 0x50(%r12)
movq %r15, %rdi
callq 0x1242c
cmpq %r15, 0x20(%rsp)
jne 0x158d3
leaq 0x40(%rsp), %rdi
callq 0xe35c
leaq 0x20(%rsp), %rdi
callq 0x124c4
leaq 0x8(%rsp), %rdi
callq 0x124c4
andb $0x1, %bl
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x15977
jmp 0x1594d
jmp 0x1594d
jmp 0x1594d
jmp 0x15977
movq %rax, %rbx
jmp 0x15996
movq %rax, %rbx
cmpb $0x0, 0x13c(%rsp)
jne 0x1597a
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x1597a
callq 0x6340
jmp 0x1597a
jmp 0x15977
jmp 0x15977
movq %rax, %rbx
cmpb $0x0, 0xc4(%rsp)
jne 0x15996
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x15996
callq 0x6340
leaq 0x40(%rsp), %rdi
callq 0xe35c
leaq 0x20(%rsp), %rdi
callq 0x124c4
leaq 0x8(%rsp), %rdi
callq 0x124c4
movq %rbx, %rdi
callq 0x6410