// File: /workspace/github_cpp_makefile_star2_O2/bonetblai[P]mdp-engine/ctp3/../engine/ldfs.h
// Function: Algorithm::ldfs_base_t<state_t>::ldfs(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 ldfs(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;
        }

        // 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();

        if( type_ == 1 ) {
            std::pair<Problem::action_t, float> p = hash.best_q_value(s);
            dptr->update(p.second);
            hash.inc_updates();
        }

        // expansion
        bool flag = false;
        float bqv = std::numeric_limits<float>::max();
        for( Problem::action_t a = 0; a < problem_.number_actions(s); ++a ) {
            if( problem_.applicable(s, a) ) {
                problem_.next(s, a, outcomes);
                unsigned osize = outcomes.size();

                float qv = 0.0;
                for( unsigned i = 0; i < osize; ++i )
                    qv += outcomes[i].second * hash.value(outcomes[i].first);
                qv = problem_.cost(s, a) + problem_.discount() * qv;
                bqv = Utils::min(bqv, qv);
                if( fabs(qv - dptr->value()) > epsilon_ ) continue;
                dptr->mark();
                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 = ldfs(outcomes[i].first, hash, ptr, index, stack, visited);
                        flag = flag && rv;
                        dptr->set_scc_low(Utils::min(dptr->scc_low(), ptr->scc_low()));
                    } else if( ptr->marked() ) {
                        dptr->set_scc_low(Utils::min(dptr->scc_low(), ptr->scc_idx()));
                    }
                }
                if( (type_ == 1) && flag && (hash.q_value(s, a) - dptr->value() > epsilon_) ) flag = false;
                if( flag ) break;
                while( 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();
                }
            }
        }

        // update
        if( !flag ) {
            if( !dptr->marked() ) {
                dptr->update(bqv);
            } else {
                std::pair<Problem::action_t, float> p = hash.best_q_value(s);
                dptr->update(p.second);
            }
            hash.inc_updates();
            dptr->set_scc_low(std::numeric_limits<unsigned>::max());
            dptr->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 $0x78, %rsp
movq %r8, 0x58(%rsp)
movq %rcx, 0x10(%rsp)
andq $0x0, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
cmpb $0x0, 0x4(%rcx)
jne 0xf105
movq %r9, %rbx
movq %rdx, %r14
movq %rsi, %rbp
movq %rdi, %r15
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x10(%rsp), %rcx
testb %al, %al
je 0xf128
movb $0x1, 0x4(%rcx)
movb $0x1, %r14b
leaq 0x40(%rsp), %rdi
callq 0xb53c
movl %r14d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x5(%rcx)
jne 0xf485
movq 0xb0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd7d2
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0xd7d2
movq 0x58(%rsp), %rcx
movq (%rcx), %r13
leaq 0x1(%r13), %rax
movq %rax, (%rcx)
movq 0x10(%rsp), %rax
movq %r13, 0x18(%rax)
movq %r13, 0x20(%rax)
cmpl $0x1, 0x1c(%r15)
jne 0xf18e
movq %r14, %rdi
movq %rbp, %rsi
callq 0xd74c
shrq $0x20, %rax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
incl 0x50(%r14)
movq $0x0, 0x18(%rsp)
movss 0x10e75(%rip), %xmm0    # 0x20014
movss %xmm0, 0x24(%rsp)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0x0, 0xc(%rsp)
movq %rbp, 0x70(%rsp)
movq %r15, 0x28(%rsp)
movq %r13, 0x30(%rsp)
movq 0x8(%r15), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
callq *0x10(%rax)
movq 0x18(%rsp), %rdx
cmpl %eax, %edx
jge 0xf3f5
movq 0x8(%r15), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
callq *0x30(%rax)
testb %al, %al
je 0xf2c1
movq 0x8(%r15), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
movq 0x18(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq *0x60(%rax)
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
cqto
pushq $0x78
popq %rcx
idivq %rcx
movl %eax, %eax
imulq $0x78, %rax, %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
xorl %r15d, %r15d
cmpq %r15, %r13
je 0xf267
movq 0x40(%rsp), %rsi
movss 0x70(%rsi,%r15), %xmm0
movss %xmm0, 0x3c(%rsp)
addq %r15, %rsi
movq %r14, %rdi
callq 0xf4b0
mulss 0x3c(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
addss %xmm0, %xmm1
movaps %xmm1, 0x60(%rsp)
addq $0x78, %r15
jmp 0xf22b
movq 0x28(%rsp), %r15
movq 0x8(%r15), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
movq 0x18(%rsp), %rdx
callq *0x48(%rax)
movq 0x8(%r15), %rax
movaps 0x60(%rsp), %xmm1
mulss 0x8(%rax), %xmm1
addss %xmm0, %xmm1
movss 0x24(%rsp), %xmm0
minss %xmm1, %xmm0
movss %xmm0, 0x24(%rsp)
movq 0x10(%rsp), %rax
subss (%rax), %xmm1
andps 0x10db0(%rip), %xmm1    # 0x20060
ucomiss 0x20(%r15), %xmm1
jbe 0xf2d2
movq 0x28(%rsp), %r15
movq 0x30(%rsp), %r13
movq 0x18(%rsp), %rax
incl %eax
movq %rax, 0x18(%rsp)
jmp 0xf1c2
movb $0x1, 0x5(%rax)
movb $0x1, %al
movl %eax, 0xc(%rsp)
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0xf377
movq 0x40(%rsp), %rsi
addq %rbp, %rsi
movq %r14, %rdi
callq 0xcf18
movq %rax, %r15
movq 0x20(%rax), %rax
cmpq %r12, %rax
jne 0xf353
movq 0x40(%rsp), %rsi
addq %rbp, %rsi
movq 0xb0(%rsp), %rax
movq %rax, (%rsp)
movq 0x28(%rsp), %rdi
movq %r14, %rdx
movq %r15, %rcx
movq 0x58(%rsp), %r8
movq %rbx, %r9
callq 0xf0ba
movl 0xc(%rsp), %ecx
andb %al, %cl
movl %ecx, 0xc(%rsp)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x18(%r15), %rdx
cmpq %rdx, %rcx
cmovbq %rcx, %rdx
movq %rdx, 0x18(%rax)
jmp 0xf36e
cmpb $0x1, 0x5(%r15)
jne 0xf36e
movq 0x10(%rsp), %rcx
movq 0x18(%rcx), %rdx
cmpq %rax, %rdx
cmovbq %rdx, %rax
movq %rax, 0x18(%rcx)
addq $0x78, %rbp
jmp 0xf2de
movq 0x28(%rsp), %r15
cmpl $0x1, 0x1c(%r15)
movq 0x70(%rsp), %rbp
jne 0xf3ba
testb $0x1, 0xc(%rsp)
je 0xf3ba
movq (%r14), %rax
movq %r14, %rdi
movq %rbp, %rsi
movq 0x18(%rsp), %rdx
callq *0x10(%rax)
movq 0x10(%rsp), %rax
subss (%rax), %xmm0
ucomiss 0x20(%r15), %xmm0
jbe 0xf3ba
movl $0x0, 0xc(%rsp)
jmp 0xf3c1
testb $0x1, 0xc(%rsp)
jne 0xf3f0
movq 0x30(%rsp), %r13
movq (%rbx), %rax
movq 0x10(%rax), %rax
cmpq %r13, 0x20(%rax)
jbe 0xf2c1
movq %r12, 0x18(%rax)
movq (%rbx), %rax
movq 0x10(%rax), %rax
movq %r12, 0x20(%rax)
movq %rbx, %rdi
callq 0xd26a
jmp 0xf3c6
movq 0x30(%rsp), %r13
movq 0x10(%rsp), %rcx
testb $0x1, 0xc(%rsp)
je 0xf449
movq 0x18(%rcx), %rax
movb $0x1, %r14b
cmpq 0x20(%rcx), %rax
jne 0xf10c
movq (%rbx), %rax
cmpq %rbx, %rax
je 0xf10c
movq 0x10(%rax), %rax
cmpq %r13, 0x20(%rax)
jb 0xf10c
movb $0x1, 0x4(%rax)
movq %r12, 0x18(%rax)
movq (%rbx), %rax
movq 0x10(%rax), %rax
movq %r12, 0x20(%rax)
movq %rbx, %rdi
callq 0xd26a
jmp 0xf412
cmpb $0x0, 0x5(%rcx)
je 0xf467
movq %r14, %rdi
movq %rbp, %rsi
callq 0xd74c
shrq $0x20, %rax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
jmp 0xf471
movss 0x24(%rsp), %xmm0
movss %xmm0, (%rcx)
incl 0x50(%r14)
movq %r12, 0x18(%rcx)
movq %r12, 0x20(%rcx)
movq %rbx, %rdi
callq 0xd26a
xorl %r14d, %r14d
jmp 0xf10c
jmp 0xf49b
jmp 0xf49b
jmp 0xf49b
jmp 0xf49b
jmp 0xf49b
jmp 0xf49b
jmp 0xf49b
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xb53c
movq %rbx, %rdi
callq 0x5410