// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %rcx, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpb $0x0, 0x4(%rcx)
jne 0x102e5
movq %r9, %rbx
movq %r8, %rbp
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
testb %al, %al
je 0x102ef
movb $0x1, 0x4(%r14)
movb $0x1, %bpl
jmp 0x10338
cmpb $0x0, 0x5(%r14)
jne 0x10336
movq %r12, 0x18(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x10b16
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
shrq $0x20, %rax
movd %eax, %xmm0
subss (%r14), %xmm0
andps 0x1cd7c(%rip), %xmm0    # 0x2d0a0
movq 0x18(%rsp), %rcx
ucomiss 0x1c(%rcx), %xmm0
jbe 0x10353
movl %eax, (%r14)
incl 0x50(%r15)
xorl %ebp, %ebp
leaq 0x20(%rsp), %rdi
callq 0xe35c
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x90(%rsp), %rax
movq (%rax), %r12
movl $0x18, %edi
callq 0x6290
movq %r14, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x6060
movq 0x90(%rsp), %rax
incq 0x10(%rax)
movq (%rbx), %r12
movl $0x18, %edi
callq 0x6290
movq %r14, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x6060
incq 0x10(%rbx)
movq (%rbp), %rcx
leaq 0x1(%rcx), %rax
movq %rax, (%rbp)
movq %rcx, 0x18(%r14)
movq %rcx, 0x38(%rsp)
movq %rcx, 0x20(%r14)
movb $0x1, 0x5(%r14)
movq 0x18(%rsp), %r12
movq 0x8(%r12), %rdi
movq (%rdi), %rax
leaq 0x20(%rsp), %rcx
movq %r13, %rsi
movq 0x10(%rsp), %rdx
callq *0x60(%rax)
movq 0x28(%rsp), %rcx
subq 0x20(%rsp), %rcx
sarq $0x3, %rcx
movabsq $-0x1111111111111111, %rax # imm = 0xEEEEEEEEEEEEEEEF
imulq %rcx, %rax
testl %eax, %eax
je 0x104e5
movq %rbp, 0x50(%rsp)
movq %r13, 0x40(%rsp)
leaq 0x8(%r15), %rcx
movq %rcx, 0x48(%rsp)
movl %eax, %eax
imulq $0x78, %rax, %rax
movq %rax, 0x10(%rsp)
movb $0x1, 0xf(%rsp)
xorl %ebp, %ebp
movq 0x90(%rsp), %r13
movq 0x20(%rsp), %rsi
addq %rbp, %rsi
movq %r15, %rdi
callq 0x1020a
movq 0x20(%rax), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rcx
jne 0x104b5
movq 0x20(%rsp), %rsi
addq %rbp, %rsi
movq %r13, (%rsp)
movq %r12, %rdi
movq %r15, %rdx
movq %rax, %rcx
movq 0x50(%rsp), %r8
movq %rbx, %r9
callq 0x102a0
movl %eax, %r12d
movq 0x18(%r14), %r13
movq 0x20(%rsp), %rsi
addq %rbp, %rsi
movq 0x48(%rsp), %rdi
callq 0x1069e
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x1049a
movq 0x78(%rax), %rax
movq 0x18(%rax), %rcx
andb %r12b, 0xf(%rsp)
cmpq %rcx, %r13
cmovbq %r13, %rcx
movq 0x18(%rsp), %r12
movq 0x90(%rsp), %r13
jmp 0x104c6
cmpb $0x1, 0x5(%rax)
jne 0x104ca
movq 0x18(%r14), %rax
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rcx, 0x18(%r14)
addq $0x78, %rbp
cmpq %rbp, 0x10(%rsp)
jne 0x1042f
testb $0x1, 0xf(%rsp)
movq 0x40(%rsp), %rsi
je 0x10554
movq 0x18(%r14), %rax
cmpq 0x20(%r14), %rax
setne %cl
movq (%rbx), %rax
cmpq %rbx, %rax
sete %dl
orb %cl, %dl
movb $0x1, %bpl
jne 0x10338
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq 0x38(%rsp), %r12
movq 0x10(%rax), %rax
cmpq %r12, 0x20(%rax)
jb 0x10338
movb $0x1, 0x4(%rax)
movq %r15, 0x18(%rax)
movq (%rbx), %rax
movq 0x10(%rax), %rax
movq %r15, 0x20(%rax)
movq (%rbx), %r14
decq 0x10(%rbx)
movq %r14, %rdi
callq 0x63d0
movq %r14, %rdi
callq 0x6260
movq (%rbx), %rax
cmpq %rbx, %rax
jne 0x1050f
jmp 0x10338
movq %r15, %rdi
callq 0x10b16
shrq $0x20, %rax
movl %eax, (%r14)
incl 0x50(%r15)
movq (%rbx), %rax
cmpq %rbx, %rax
movq 0x38(%rsp), %r15
je 0x10336
xorl %ebp, %ebp
movq 0x10(%rax), %rax
cmpq %r15, 0x20(%rax)
jb 0x10336
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, 0x18(%rax)
movq (%rbx), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x20(%rax)
movq (%rbx), %r14
decq 0x10(%rbx)
movq %r14, %rdi
callq 0x63d0
movq %r14, %rdi
callq 0x6260
movq (%rbx), %rax
cmpq %rbx, %rax
jne 0x1057a
jmp 0x10338
jmp 0x105ca
jmp 0x105ca
jmp 0x105ca
jmp 0x105ca
jmp 0x105ca
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xe35c
movq %rbx, %rdi
callq 0x6410
nop