// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movq %rsi, %r13
movq %rdi, 0x60(%rsp)
leaq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
xorl %eax, %eax
movq %rax, 0x10(%rcx)
leaq 0x8(%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 0xefb2
movq %rax, %r14
cmpb $0x0, 0x4(%rax)
jne 0x1427d
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 0xc30a
leaq 0x68(%rsp), %rsi
movq %r14, 0x70(%rsi)
leaq 0x20(%rsp), %rdi
callq 0x11116
leaq 0x20(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x5060
incq 0x10(%r13)
cmpb $0x0, 0xc4(%rsp)
jne 0x14278
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x14278
callq 0x5340
movb $0x1, 0x5(%r14)
leaq 0x20(%rsp), %r13
cmpq %r13, 0x20(%rsp)
je 0x144bb
movb $0x1, %al
movl %eax, 0x4(%rsp)
leaq 0x68(%rsp), %rbp
leaq 0xe0(%rsp), %r14
movq %r14, %r12
movq 0x28(%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 %rbp, %rdi
callq 0xc30a
movq 0x80(%r15), %rax
movq %rax, 0xd8(%rsp)
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x111ae
movq %rax, %rdi
movq %r14, %rsi
callq 0x5060
incq 0x18(%rsp)
movq 0x28(%rsp), %rsi
movq %r13, %rdi
callq 0x11180
movq 0x60(%rsp), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
callq *0x20(%rax)
testb %al, %al
je 0x14337
movq %r12, %r14
jmp 0x14485
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xf8b0
movq %r12, %r14
movq %rax, %rcx
shrq $0x20, %rcx
movd %ecx, %xmm0
movq 0xd8(%rsp), %rcx
subss (%rcx), %xmm0
andps 0x16d4d(%rip), %xmm0    # 0x2b0b0
ucomiss 0x3c(%rsp), %xmm0
jbe 0x14377
movl $0x0, 0x4(%rsp)
jmp 0x14485
movq 0x60(%rsp), %rdi
movq (%rdi), %r8
movq %rbp, %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 0x14485
movl %eax, %eax
imulq $0x78, %rax, %rbp
xorl %r15d, %r15d
movq 0x40(%rsp), %rsi
addq %r15, %rsi
movq %rbx, %rdi
callq 0xefb2
movq %rax, %r13
cmpb $0x0, 0x4(%rax)
jne 0x1446e
cmpb $0x0, 0x5(%r13)
jne 0x1446e
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)
movq %r14, %rdi
callq 0xc30a
movq %r14, %rsi
movq %r13, 0x150(%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x11116
movq %rax, %rdi
movq %r14, %rsi
callq 0x5060
incq 0x30(%rsp)
cmpb $0x0, 0x13c(%rsp)
jne 0x14466
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x14466
callq 0x5340
movb $0x1, 0x5(%r13)
movq %r12, %r14
addq $0x78, %r15
cmpq %r15, %rbp
jne 0x143ba
leaq 0x20(%rsp), %r13
leaq 0x68(%rsp), %rbp
cmpb $0x0, 0xc4(%rsp)
jne 0x144a1
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x144a1
callq 0x5340
cmpq %r13, 0x20(%rsp)
jne 0x142a0
movl 0x4(%rsp), %ebp
testb $0x1, %bpl
leaq 0x8(%rsp), %r15
je 0x144df
movb $0x1, %bpl
cmpq %r15, 0x8(%rsp)
je 0x14528
movq 0x10(%rsp), %rsi
movq 0x80(%rsi), %rax
movb $0x1, 0x4(%rax)
movq %r15, %rdi
callq 0x11180
jmp 0x144be
leaq 0x8(%rsp), %r14
cmpq %r14, 0x8(%rsp)
je 0x14526
movq 0x10(%rsp), %rsi
addq $0x10, %rsi
movq %rbx, %rdi
callq 0xf8b0
shrq $0x20, %rax
movq 0x10(%rsp), %rsi
movq 0x80(%rsi), %rcx
movl %eax, (%rcx)
movb $0x0, 0x5(%rcx)
incl 0x50(%rbx)
movq %r14, %rdi
callq 0x11180
cmpq %r14, 0x8(%rsp)
jne 0x144eb
jmp 0x14528
xorl %ebp, %ebp
leaq 0x40(%rsp), %rdi
callq 0xd12e
leaq 0x8(%rsp), %rdi
callq 0x11218
leaq 0x20(%rsp), %rdi
callq 0x11218
andb $0x1, %bpl
movl %ebp, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14592
jmp 0x14568
jmp 0x14568
jmp 0x14568
jmp 0x14592
movq %rax, %rbx
jmp 0x145b1
movq %rax, %rbx
cmpb $0x0, 0x13c(%rsp)
jne 0x14595
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x14595
callq 0x5340
jmp 0x14595
jmp 0x14592
jmp 0x14592
movq %rax, %rbx
cmpb $0x0, 0xc4(%rsp)
jne 0x145b1
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x145b1
callq 0x5340
leaq 0x40(%rsp), %rdi
callq 0xd12e
leaq 0x8(%rsp), %rdi
callq 0x11218
leaq 0x20(%rsp), %rdi
callq 0x11218
movq %rbx, %rdi
callq 0x5410
nop