// File: /workspace/github_cpp_makefile_star2_O2/bonetblai[P]mdp-engine/ctp3/../engine/hdp.h
// Function: Algorithm::hdp_t<state_t>::hdp(state_t const&, Problem::hash_t<state_t>&, Hash::data_t*, unsigned long&, std::__cxx11::list<Hash::data_t*, std::allocator<Hash::data_t*>>&, std::__cxx11::list<Hash::data_t*, std::allocator<Hash::data_t*>>&) const
bool hdp(const T &s,
             Problem::hash_t<T> &hash,
             Hash::data_t* dptr,
             size_t &index,
             std::list<Hash::data_t*> &stack,
             std::list<Hash::data_t*> &visited) const {
        std::vector<std::pair<T, float> > outcomes;

        // base cases
        if( dptr->solved() || problem_.terminal(s) ) {
            dptr->solve();
            return true;
        } else if( dptr->marked() ) {
            return false;
        }

        // if residual > epsilon, update and return
        std::pair<Problem::action_t, float> p = hash.best_q_value(s);
        if( fabs(p.second - dptr->value()) > epsilon_ ) {
            dptr->update(p.second);
            hash.inc_updates();
            return false;
        }

        // Tarjan's
        visited.push_front(dptr);
        stack.push_front(dptr);
        size_t idx = index++;
        dptr->set_scc_low(idx);
        dptr->set_scc_idx(idx);
        dptr->mark();

        // expansion
        problem_.next(s, p.first, outcomes);
        unsigned osize = outcomes.size();

        bool flag = true;
        for( unsigned i = 0; i < osize; ++i ) {
            Hash::data_t *ptr = hash.data_ptr(outcomes[i].first);
            if( ptr->scc_idx() == std::numeric_limits<unsigned>::max() ) {
                bool rv = hdp(outcomes[i].first, hash, ptr, index, stack, visited);
                flag = flag && rv;
                dptr->set_scc_low(Utils::min(dptr->scc_low(), hash.scc_low(outcomes[i].first)));
            } else if( ptr->marked() ) {
                dptr->set_scc_low(Utils::min(dptr->scc_low(), ptr->scc_idx()));
            }
        }

        // update
        if( !flag ) {
            std::pair<Problem::action_t, float> p = hash.best_q_value(s);
            dptr->update(p.second);
            hash.inc_updates();
            while( !stack.empty() && (stack.front()->scc_idx() >= idx) ) {
                stack.front()->set_scc_low(std::numeric_limits<unsigned>::max());
                stack.front()->set_scc_idx(std::numeric_limits<unsigned>::max());
                stack.pop_front();
            }
        } else if( dptr->scc_low() == dptr->scc_idx() ) {
            while( !stack.empty() && (stack.front()->scc_idx() >= idx) ) {
                stack.front()->solve();
                stack.front()->set_scc_low(std::numeric_limits<unsigned>::max());
                stack.front()->set_scc_idx(std::numeric_limits<unsigned>::max());
                stack.pop_front();
            }
        }
        return flag;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, 0x10(%rsp)
andq $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
cmpb $0x0, 0x4(%rcx)
jne 0xcfef
movq %r9, %rbx
movq %r8, %r12
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r13
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x10(%rsp), %rcx
testb %al, %al
je 0xcff8
movb $0x1, 0x4(%rcx)
movb $0x1, %bpl
jmp 0xd033
cmpb $0x0, 0x5(%rcx)
jne 0xd031
movq %r14, %rdi
movq %r15, %rsi
callq 0xd74c
movq %rax, %rbp
shrq $0x20, %rax
movd %eax, %xmm0
movq 0x10(%rsp), %rcx
subss (%rcx), %xmm0
andps 0x1303c(%rip), %xmm0    # 0x20060
ucomiss 0x1c(%r13), %xmm0
jbe 0xd04e
movl %eax, (%rcx)
incl 0x50(%r14)
xorl %ebp, %ebp
leaq 0x20(%rsp), %rdi
callq 0xb53c
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd7d2
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0xd7d2
movq %rbx, 0x18(%rsp)
movq (%r12), %rcx
leaq 0x1(%rcx), %rax
movq %r12, 0x60(%rsp)
movq %rax, (%r12)
movq 0x10(%rsp), %rax
movq %rcx, 0x18(%rax)
movq %rcx, 0x40(%rsp)
movq %rcx, 0x20(%rax)
movb $0x1, 0x5(%rax)
movq %r13, 0x58(%rsp)
movq 0x8(%r13), %rdi
movq (%rdi), %rax
leaq 0x20(%rsp), %rcx
movq %r15, 0x48(%rsp)
movq %r15, %rsi
movl %ebp, %edx
callq *0x60(%rax)
movq 0x28(%rsp), %rax
subq 0x20(%rsp), %rax
pushq $0x78
popq %rcx
cqto
idivq %rcx
movl %eax, %eax
imulq $0x78, %rax, %rbx
movb $0x1, %r12b
xorl %r13d, %r13d
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rbx, 0x50(%rsp)
cmpq %r13, %rbx
je 0xd189
movq 0x20(%rsp), %rsi
addq %r13, %rsi
movq %r14, %rdi
callq 0xcf18
movq 0x20(%rax), %rcx
cmpq %r15, %rcx
jne 0xd166
movq 0x20(%rsp), %rsi
addq %r13, %rsi
movq 0xa0(%rsp), %rcx
movq %rcx, (%rsp)
movq 0x58(%rsp), %rdi
movq %r14, %rdx
movq %rax, %rcx
movq 0x60(%rsp), %r8
movq 0x18(%rsp), %r9
callq 0xcfa6
movl %eax, %ebp
movq 0x10(%rsp), %rbx
movq 0x18(%rbx), %r15
movq 0x20(%rsp), %rsi
addq %r13, %rsi
movq %r14, %rdi
callq 0xd7de
andb %bpl, %r12b
cmpq %rax, %r15
cmovbq %r15, %rax
movq %rax, 0x18(%rbx)
movq 0x50(%rsp), %rbx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0xd180
cmpb $0x1, 0x5(%rax)
jne 0xd180
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdx
cmpq %rcx, %rdx
cmovbq %rdx, %rcx
movq %rcx, 0x18(%rax)
addq $0x78, %r13
jmp 0xd0e0
testb $0x1, %r12b
je 0xd1eb
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rcx
movb $0x1, %bpl
cmpq 0x20(%rax), %rcx
movq 0x18(%rsp), %r14
movq 0x40(%rsp), %r15
jne 0xd033
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq (%r14), %rax
cmpq %r14, %rax
je 0xd033
movq 0x10(%rax), %rax
cmpq %r15, 0x20(%rax)
jb 0xd033
movb $0x1, 0x4(%rax)
movq %rbx, 0x18(%rax)
movq (%r14), %rax
movq 0x10(%rax), %rax
movq %rbx, 0x20(%rax)
movq %r14, %rdi
callq 0xd26a
jmp 0xd1b4
movq %r14, %rdi
movq 0x48(%rsp), %rsi
callq 0xd74c
movq 0x18(%rsp), %rbx
movq 0x40(%rsp), %r12
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
shrq $0x20, %rax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
incl 0x50(%r14)
movq (%rbx), %rax
cmpq %rbx, %rax
je 0xd031
movq 0x10(%rax), %rax
cmpq %r12, 0x20(%rax)
jb 0xd031
movq %r15, 0x18(%rax)
movq (%rbx), %rax
movq 0x10(%rax), %rax
movq %r15, 0x20(%rax)
movq %rbx, %rdi
callq 0xd26a
jmp 0xd217
jmp 0xd254
jmp 0xd254
jmp 0xd254
jmp 0xd254
jmp 0xd254
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xb53c
movq %rbx, %rdi
callq 0x5410
nop