// File: 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:
subq $0x198, %rsp            # imm = 0x198
movq 0x1a0(%rsp), %rax
movq %rdi, 0x188(%rsp)
movq %rsi, 0x180(%rsp)
movq %rdx, 0x178(%rsp)
movq %rcx, 0x170(%rsp)
movq %r8, 0x168(%rsp)
movq %r9, 0x160(%rsp)
movq 0x188(%rsp), %rax
movq %rax, 0xe8(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x1a4a0
movq 0x170(%rsp), %rdi
callq 0x20d90
testb $0x1, %al
jne 0x27fb0
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x180(%rsp), %rsi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movb %al, 0xe7(%rsp)
jmp 0x27fa3
movb 0xe7(%rsp), %al
testb $0x1, %al
jne 0x27fb0
jmp 0x27ffb
movq 0x170(%rsp), %rdi
callq 0x22e90
movb $0x1, 0x197(%rsp)
movl $0x1, 0x138(%rsp)
jmp 0x288b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x1a510
jmp 0x288d7
movq 0x170(%rsp), %rdi
callq 0x22ea0
testb $0x1, %al
jne 0x2800e
jmp 0x28026
movb $0x0, 0x197(%rsp)
movl $0x1, 0x138(%rsp)
jmp 0x288b9
jmp 0x28028
movq 0x1a0(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x23010
jmp 0x2803f
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x23010
jmp 0x28056
movq 0x168(%rsp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
movq %rax, 0x130(%rsp)
movq 0x170(%rsp), %rdi
movq 0x130(%rsp), %rsi
callq 0x23050
movq 0x170(%rsp), %rdi
movq 0x130(%rsp), %rsi
callq 0x23070
movq 0xe8(%rsp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x280fd
movq 0x178(%rsp), %rdi
movq 0x180(%rsp), %rsi
callq 0x22eb0
movq %rax, 0xd8(%rsp)
jmp 0x280ca
movq 0xd8(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x170(%rsp), %rdi
movss 0x12c(%rsp), %xmm0
callq 0x22fd0
movq 0x178(%rsp), %rdi
callq 0x22ff0
movb $0x0, 0x127(%rsp)
callq 0x23160
movss %xmm0, 0x120(%rsp)
movl $0x0, 0x11c(%rsp)
movq 0xe8(%rsp), %rax
movl 0x11c(%rsp), %ecx
movl %ecx, 0xd0(%rsp)
movq 0x8(%rax), %rdi
movq 0x180(%rsp), %rsi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, 0xd4(%rsp)
jmp 0x28152
movl 0xd0(%rsp), %eax
movl 0xd4(%rsp), %ecx
cmpl %ecx, %eax
jge 0x286d4
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x180(%rsp), %rsi
movl 0x11c(%rsp), %edx
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
movb %al, 0xcf(%rsp)
jmp 0x28195
movb 0xcf(%rsp), %al
testb $0x1, %al
jne 0x281a5
jmp 0x286bc
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x180(%rsp), %rsi
movl 0x11c(%rsp), %edx
movq (%rdi), %rax
movq 0x60(%rax), %rax
leaq 0x148(%rsp), %rcx
callq *%rax
jmp 0x281d3
leaq 0x148(%rsp), %rdi
callq 0x17030
movl %eax, 0x118(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x114(%rsp)
movl $0x0, 0x110(%rsp)
movl 0x110(%rsp), %eax
cmpl 0x118(%rsp), %eax
jae 0x282bd
movl 0x110(%rsp), %eax
movl %eax, %esi
leaq 0x148(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x1a4b0
movq 0xb0(%rsp), %rdi
movss 0x70(%rax), %xmm0
movss %xmm0, 0xbc(%rsp)
movq 0x178(%rsp), %rax
movq %rax, 0xc0(%rsp)
movl 0x110(%rsp), %eax
movl %eax, %esi
callq 0x1a4b0
movq 0xc0(%rsp), %rdi
movq %rax, %rsi
callq 0x288f0
movss %xmm0, 0xc8(%rsp)
jmp 0x2827f
movss 0xc8(%rsp), %xmm1
movss 0xbc(%rsp), %xmm0
mulss %xmm1, %xmm0
addss 0x114(%rsp), %xmm0
movss %xmm0, 0x114(%rsp)
movl 0x110(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x110(%rsp)
jmp 0x281fe
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x180(%rsp), %rsi
movl 0x11c(%rsp), %edx
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
movss %xmm0, 0xac(%rsp)
jmp 0x282ec
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x28980
movss %xmm0, 0xa8(%rsp)
jmp 0x28308
movss 0xac(%rsp), %xmm0
movss 0xa8(%rsp), %xmm1
movss 0x114(%rsp), %xmm2
mulss %xmm2, %xmm1
addss %xmm1, %xmm0
movss %xmm0, 0x114(%rsp)
movss 0x120(%rsp), %xmm0
movss 0x114(%rsp), %xmm1
callq 0x28990
movss %xmm0, 0xa4(%rsp)
jmp 0x28356
movss 0xa4(%rsp), %xmm0
movss %xmm0, 0x120(%rsp)
movss 0x114(%rsp), %xmm0
movss %xmm0, 0xa0(%rsp)
movq 0x170(%rsp), %rdi
callq 0x22fc0
movaps %xmm0, %xmm1
movss 0xa0(%rsp), %xmm0
subss %xmm1, %xmm0
callq 0x22fa0
movq 0xe8(%rsp), %rax
ucomiss 0x20(%rax), %xmm0
jbe 0x283af
jmp 0x286be
movq 0x170(%rsp), %rdi
callq 0x23090
movb $0x1, 0x127(%rsp)
movl $0x0, 0x10c(%rsp)
movl 0x10c(%rsp), %eax
cmpl 0x118(%rsp), %eax
jae 0x285bb
movq 0x178(%rsp), %rax
movq %rax, 0x90(%rsp)
movl 0x10c(%rsp), %eax
movl %eax, %esi
leaq 0x148(%rsp), %rdi
callq 0x1a4b0
movq 0x90(%rsp), %rdi
movq %rax, %rsi
callq 0x20ca0
movq %rax, 0x98(%rsp)
jmp 0x28423
movq 0x98(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rdi
callq 0x215e0
movq %rax, 0x88(%rsp)
callq 0x215d0
movl %eax, %ecx
movq 0x88(%rsp), %rax
movl %ecx, %ecx
cmpq %rcx, %rax
jne 0x28548
movl 0x10c(%rsp), %eax
movl %eax, %esi
leaq 0x148(%rsp), %rdi
callq 0x1a4b0
movq 0xe8(%rsp), %rdi
movq %rax, %rsi
movq 0x178(%rsp), %rdx
movq 0x100(%rsp), %rcx
movq 0x168(%rsp), %r8
movq 0x160(%rsp), %r9
movq 0x1a0(%rsp), %r10
movq %rsp, %rax
movq %r10, (%rax)
callq 0x27f10
movb %al, 0x87(%rsp)
jmp 0x284bf
movb 0x87(%rsp), %al
andb $0x1, %al
movb %al, 0xff(%rsp)
xorl %eax, %eax
testb $0x1, 0x127(%rsp)
movb %al, 0x86(%rsp)
je 0x284f0
movb 0xff(%rsp), %al
movb %al, 0x86(%rsp)
movb 0x86(%rsp), %al
andb $0x1, %al
movb %al, 0x127(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x170(%rsp), %rdi
callq 0x215c0
movq %rax, 0x70(%rsp)
movq 0x100(%rsp), %rdi
callq 0x215c0
movq 0x70(%rsp), %rdi
movq %rax, %rsi
callq 0x230a0
movq 0x78(%rsp), %rdi
movq %rax, %rsi
callq 0x23050
jmp 0x285a3
movq 0x100(%rsp), %rdi
callq 0x22ea0
testb $0x1, %al
jne 0x2855b
jmp 0x285a1
movq 0x170(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x170(%rsp), %rdi
callq 0x215c0
movq %rax, 0x60(%rsp)
movq 0x100(%rsp), %rdi
callq 0x215e0
movq 0x60(%rsp), %rdi
movq %rax, %rsi
callq 0x230a0
movq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x23050
jmp 0x285a3
jmp 0x285a5
movl 0x10c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10c(%rsp)
jmp 0x283cf
movq 0xe8(%rsp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x2862b
testb $0x1, 0x127(%rsp)
je 0x2862b
movq 0x178(%rsp), %rdi
movq 0x180(%rsp), %rsi
movl 0x11c(%rsp), %edx
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movss %xmm0, 0x5c(%rsp)
jmp 0x285fb
movq 0x170(%rsp), %rdi
callq 0x22fc0
movq 0xe8(%rsp), %rax
movaps %xmm0, %xmm1
movss 0x5c(%rsp), %xmm0
subss %xmm1, %xmm0
ucomiss 0x20(%rax), %xmm0
jbe 0x2862b
movb $0x0, 0x127(%rsp)
testb $0x1, 0x127(%rsp)
je 0x2863a
jmp 0x286d4
jmp 0x2863c
movq 0x160(%rsp), %rdi
callq 0x21580
movq (%rax), %rdi
callq 0x215e0
cmpq 0x130(%rsp), %rax
jbe 0x286ba
movq 0x160(%rsp), %rdi
callq 0x21580
movq (%rax), %rax
movq %rax, 0x48(%rsp)
callq 0x215d0
movq 0x48(%rsp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x23050
movq 0x160(%rsp), %rdi
callq 0x21580
movq (%rax), %rax
movq %rax, 0x50(%rsp)
callq 0x215d0
movq 0x50(%rsp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x23070
movq 0x160(%rsp), %rdi
callq 0x215f0
jmp 0x2863c
jmp 0x286bc
jmp 0x286be
movl 0x11c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x11c(%rsp)
jmp 0x2811e
testb $0x1, 0x127(%rsp)
jne 0x287a9
movq 0x170(%rsp), %rdi
callq 0x22ea0
testb $0x1, %al
jne 0x2870b
movq 0x170(%rsp), %rdi
movss 0x120(%rsp), %xmm0
callq 0x22fd0
jmp 0x2874a
movq 0x178(%rsp), %rdi
movq 0x180(%rsp), %rsi
callq 0x22eb0
movq %rax, 0x40(%rsp)
jmp 0x28727
movq 0x40(%rsp), %rax
movq %rax, 0xf4(%rsp)
movq 0x170(%rsp), %rdi
movss 0xf8(%rsp), %xmm0
callq 0x22fd0
movq 0x178(%rsp), %rdi
callq 0x22ff0
movq 0x170(%rsp), %rax
movq %rax, 0x30(%rsp)
callq 0x215d0
movq 0x30(%rsp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x23050
movq 0x170(%rsp), %rax
movq %rax, 0x38(%rsp)
callq 0x215d0
movq 0x38(%rsp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x23070
movq 0x160(%rsp), %rdi
callq 0x215f0
jmp 0x2889e
movq 0x170(%rsp), %rdi
callq 0x215c0
movq %rax, 0x28(%rsp)
movq 0x170(%rsp), %rdi
callq 0x215e0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jne 0x2889c
jmp 0x287db
movq 0x160(%rsp), %rdi
callq 0x21560
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x27(%rsp)
jne 0x28819
movq 0x160(%rsp), %rdi
callq 0x21580
movq (%rax), %rdi
callq 0x215e0
cmpq 0x130(%rsp), %rax
setae %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x28823
jmp 0x2889a
movq 0x160(%rsp), %rdi
callq 0x21580
movq (%rax), %rdi
callq 0x22e90
movq 0x160(%rsp), %rdi
callq 0x21580
movq (%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x215d0
movq 0x10(%rsp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x23050
movq 0x160(%rsp), %rdi
callq 0x21580
movq (%rax), %rax
movq %rax, 0x18(%rsp)
callq 0x215d0
movq 0x18(%rsp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x23070
movq 0x160(%rsp), %rdi
callq 0x215f0
jmp 0x287db
jmp 0x2889c
jmp 0x2889e
movb 0x127(%rsp), %al
andb $0x1, %al
movb %al, 0x197(%rsp)
movl $0x1, 0x138(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x1a510
movb 0x197(%rsp), %al
andb $0x1, %al
addq $0x198, %rsp            # imm = 0x198
retq
movq 0x140(%rsp), %rdi
callq 0x6520
nopw %cs:(%rax,%rax)
nop