// File: /workspace/github_cpp_makefile_star2_O1/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, 0x70(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq %rcx, 0x20(%rsp)
cmpb $0x0, 0x4(%rcx)
jne 0x13389
movq %r9, %rbx
movq %rdx, %r15
movq %rdi, %rbp
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
movq %rsi, %r14
callq *0x20(%rax)
testb %al, %al
je 0x133b0
movq 0x20(%rsp), %rax
movb $0x1, 0x4(%rax)
movb $0x1, %bpl
leaq 0x50(%rsp), %rdi
callq 0xe35c
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%rsp), %rax
cmpb $0x0, 0x5(%rax)
jne 0x137e9
movq 0xb0(%rsp), %r13
movq (%r13), %r12
movl $0x18, %edi
callq 0x6290
movq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x6060
incq 0x10(%r13)
movq (%rbx), %r12
movl $0x18, %edi
callq 0x6290
movq 0x20(%rsp), %r13
movq %r13, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x6060
incq 0x10(%rbx)
movq 0x70(%rsp), %rcx
movq (%rcx), %rdx
leaq 0x1(%rdx), %rax
movq %rax, (%rcx)
movq %rdx, 0x18(%r13)
movq %rdx, 0x38(%rsp)
movq %rdx, 0x20(%r13)
cmpl $0x1, 0x1c(%rbp)
movq %r14, %r12
movq %r13, %r14
jne 0x13450
movq %r15, %rdi
movq %r12, %rsi
callq 0x10b16
shrq $0x20, %rax
movl %eax, (%r14)
incl 0x50(%r15)
xorl %r13d, %r13d
movss 0x19bb9(%rip), %xmm0    # 0x2d014
movss %xmm0, 0x1c(%rsp)
movl $0x0, 0x14(%rsp)
movq %r12, 0x40(%rsp)
movq %rbp, 0x30(%rsp)
movq 0x8(%rbp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *0x10(%rax)
cmpl %eax, %r13d
jge 0x13726
movq 0x8(%rbp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
movl %r13d, %edx
callq *0x30(%rax)
testb %al, %al
je 0x1371e
movq 0x8(%rbp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
movl %r13d, %edx
leaq 0x50(%rsp), %rcx
callq *0x60(%rax)
movq %r13, 0x28(%rsp)
movq 0x58(%rsp), %r12
subq 0x50(%rsp), %r12
sarq $0x3, %r12
movabsq $-0x1111111111111111, %rax # imm = 0xEEEEEEEEEEEEEEEF
imulq %rax, %r12
testl %r12d, %r12d
je 0x1352b
movl %r12d, %eax
imulq $0x78, %rax, %r13
xorps %xmm0, %xmm0
movss %xmm0, 0x18(%rsp)
xorl %ebp, %ebp
movq 0x50(%rsp), %rsi
movss 0x70(%rsi,%rbp), %xmm0
movss %xmm0, 0x4c(%rsp)
addq %rbp, %rsi
movq %r15, %rdi
callq 0x13814
mulss 0x4c(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0x18(%rsp)
addq $0x78, %rbp
cmpq %rbp, %r13
jne 0x134ee
jmp 0x13534
xorps %xmm0, %xmm0
movss %xmm0, 0x18(%rsp)
movq 0x30(%rsp), %rbp
movq 0x8(%rbp), %rdi
movq (%rdi), %rax
movq 0x40(%rsp), %rsi
movq %rsi, %r14
movq 0x28(%rsp), %r13
movl %r13d, %edx
callq *0x48(%rax)
movq 0x8(%rbp), %rax
movss 0x18(%rsp), %xmm1
mulss 0x8(%rax), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0x18(%rsp)
movaps %xmm1, %xmm0
movq 0x20(%rsp), %rax
subss (%rax), %xmm0
andps 0x19b21(%rip), %xmm0    # 0x2d0a0
movl $0x4, %edx
ucomiss 0x20(%rbp), %xmm0
ja 0x136fa
movq 0x20(%rsp), %r14
movb $0x1, 0x5(%r14)
testl %r12d, %r12d
je 0x13638
movl %r12d, %eax
imulq $0x78, %rax, %r13
movb $0x1, %al
movl %eax, 0x14(%rsp)
xorl %ebp, %ebp
movq 0x50(%rsp), %rsi
addq %rbp, %rsi
movq %r15, %rdi
callq 0x1020a
movq %rax, %r12
movq 0x20(%rax), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jne 0x13612
movq 0x50(%rsp), %rsi
addq %rbp, %rsi
movq 0xb0(%rsp), %rax
movq %rax, (%rsp)
movq 0x30(%rsp), %rdi
movq %r15, %rdx
movq %r12, %rcx
movq 0x70(%rsp), %r8
movq %rbx, %r9
callq 0x13340
movl 0x14(%rsp), %ecx
andb %al, %cl
movl %ecx, 0x14(%rsp)
movq 0x18(%r14), %rcx
movq 0x18(%r12), %rax
jmp 0x1361e
cmpb $0x1, 0x5(%r12)
jne 0x13629
movq 0x18(%r14), %rcx
cmpq %rax, %rcx
cmovbq %rcx, %rax
movq %rax, 0x18(%r14)
addq $0x78, %rbp
cmpq %rbp, %r13
jne 0x135b0
jmp 0x1363e
movb $0x1, %al
movl %eax, 0x14(%rsp)
movq 0x30(%rsp), %r12
cmpl $0x1, 0x1c(%r12)
jne 0x13686
testb $0x1, 0x14(%rsp)
movq 0x40(%rsp), %rsi
movq 0x28(%rsp), %r13
je 0x13692
movq (%r15), %rax
movq %r15, %rdi
movq %rsi, %r14
movl %r13d, %edx
callq *0x10(%rax)
movq 0x20(%rsp), %rax
subss (%rax), %xmm0
ucomiss 0x20(%r12), %xmm0
jbe 0x13695
movl $0x0, 0x14(%rsp)
jmp 0x13695
movq 0x40(%rsp), %r14
movq 0x28(%rsp), %r13
jmp 0x13695
movq %rsi, %r14
movl $0x2, %edx
testb $0x1, 0x14(%rsp)
jne 0x136fa
movq (%rbx), %rax
movq 0x10(%rax), %rax
xorl %edx, %edx
movq 0x38(%rsp), %rcx
cmpq %rcx, 0x20(%rax)
jbe 0x136fa
movq 0x38(%rsp), %rbp
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %r13, 0x18(%rax)
movq (%rbx), %rax
movq 0x10(%rax), %rax
movq %r13, 0x20(%rax)
movq (%rbx), %r12
decq 0x10(%rbx)
movq %r12, %rdi
callq 0x63d0
movq %r12, %rdi
callq 0x6260
movq (%rbx), %rax
movq 0x10(%rax), %rax
cmpq %rbp, 0x20(%rax)
ja 0x136c0
movq 0x28(%rsp), %r13
xorl %edx, %edx
movss 0x1c(%rsp), %xmm0
minss 0x18(%rsp), %xmm0
movss %xmm0, 0x1c(%rsp)
testb $0x3, %dl
movq 0x30(%rsp), %rbp
movq %r14, %r12
movq 0x20(%rsp), %r14
jne 0x13726
incl %r13d
jmp 0x13473
testb $0x1, 0x14(%rsp)
je 0x1379b
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 0x13395
movq 0x38(%rsp), %r15
movq 0x10(%rax), %rax
cmpq %r15, 0x20(%rax)
jb 0x13395
movb $0x1, 0x4(%rax)
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 0x13751
jmp 0x13395
movq %r12, %rsi
cmpb $0x1, 0x5(%r14)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jne 0x137bb
movq %r15, %rdi
callq 0x10b16
shrq $0x20, %rax
movl %eax, 0x1c(%rsp)
movss 0x1c(%rsp), %xmm0
movss %xmm0, (%r14)
incl 0x50(%r15)
movq %r12, 0x18(%r14)
movq %r12, 0x20(%r14)
movq (%rbx), %r14
decq 0x10(%rbx)
movq %r14, %rdi
callq 0x63d0
movq %r14, %rdi
callq 0x6260
xorl %ebp, %ebp
jmp 0x13395
jmp 0x137fe
jmp 0x137fe
jmp 0x137fe
jmp 0x137fe
jmp 0x137fe
jmp 0x137fe
jmp 0x137fe
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xe35c
movq %rbx, %rdi
callq 0x6410
nop