// File: /workspace/github_cpp_makefile_star2_O3/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)
movq %rcx, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
cmpb $0x0, 0x4(%rcx)
jne 0x120b1
movq %r9, %rbx
movq %rdx, %r15
movq %rdi, %rbp
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
movq %rsi, %r12
callq *0x20(%rax)
testb %al, %al
je 0x120d4
movb $0x1, 0x4(%r14)
movb $0x1, %bpl
leaq 0x50(%rsp), %rdi
callq 0xd12e
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x5(%r14)
jne 0x124e1
movq 0xb0(%rsp), %r13
movq (%r13), %rax
movq %rax, 0x40(%rsp)
movl $0x18, %edi
callq 0x5290
movq %r14, 0x10(%rax)
movq %rax, %rdi
movq 0x40(%rsp), %rsi
callq 0x5060
incq 0x10(%r13)
movq (%rbx), %r13
movl $0x18, %edi
callq 0x5290
movq %r14, 0x10(%rax)
movq %rax, %rdi
movq %r13, %rsi
callq 0x5060
incq 0x10(%rbx)
movq 0x70(%rsp), %rcx
movq (%rcx), %rdx
leaq 0x1(%rdx), %rax
movq %rax, (%rcx)
movq %rdx, 0x18(%r14)
movq %rdx, 0x20(%rsp)
movq %rdx, 0x20(%r14)
cmpl $0x1, 0x1c(%rbp)
jne 0x12167
movq %r15, %rdi
movq %r12, %rsi
callq 0xf8b0
shrq $0x20, %rax
movl %eax, (%r14)
incl 0x50(%r15)
xorl %r13d, %r13d
movss 0x18ea2(%rip), %xmm0    # 0x2b014
movss %xmm0, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
movq %r12, 0x18(%rsp)
movq %rbp, 0x30(%rsp)
movq %r14, 0x10(%rsp)
movq 0x8(%rbp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *0x10(%rax)
cmpl %eax, %r13d
jge 0x1241e
movq 0x8(%rbp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
movl %r13d, %edx
callq *0x30(%rax)
testb %al, %al
je 0x12416
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), %rax
subq 0x50(%rsp), %rax
sarq $0x3, %rax
movabsq $-0x1111111111111111, %rcx # imm = 0xEEEEEEEEEEEEEEEF
imulq %rcx, %rax
movq %rax, %r12
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rcx, %r12
je 0x1224b
movl %eax, %eax
imulq $0x78, %rax, %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
xorl %ebp, %ebp
movq 0x50(%rsp), %rsi
movss 0x70(%rsi,%rbp), %xmm0
movss %xmm0, 0x3c(%rsp)
addq %rbp, %rsi
movq %r15, %rdi
callq 0x1250c
mulss 0x3c(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
addss %xmm0, %xmm1
movaps %xmm1, 0x40(%rsp)
addq $0x78, %rbp
cmpq %rbp, %r13
jne 0x12210
jmp 0x12253
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq %r12, %r14
movq 0x30(%rsp), %rbp
movq 0x8(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rsp), %rsi
movq %rsi, %r12
movq 0x28(%rsp), %r13
movl %r13d, %edx
callq *0x48(%rax)
movq 0x8(%rbp), %rax
movaps 0x40(%rsp), %xmm1
mulss 0x8(%rax), %xmm1
addss %xmm0, %xmm1
movss 0xc(%rsp), %xmm0
minss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x10(%rsp), %rax
subss (%rax), %xmm1
andps 0x18e09(%rip), %xmm1    # 0x2b0b0
ucomiss 0x20(%rbp), %xmm1
jbe 0x122b5
movq %rax, %r14
jmp 0x12416
movb $0x1, 0x5(%rax)
testq %r14, %r14
je 0x1235b
imulq $0x78, %r14, %r13
movb $0x1, %al
movl %eax, 0x8(%rsp)
xorl %ebp, %ebp
movq 0x10(%rsp), %r14
movq 0x50(%rsp), %rsi
addq %rbp, %rsi
movq %r15, %rdi
callq 0xefb2
movq %rax, %r12
movq 0x20(%rax), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jne 0x12335
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 0x1206a
movl 0x8(%rsp), %ecx
andb %al, %cl
movl %ecx, 0x8(%rsp)
movq 0x18(%r14), %rcx
movq 0x18(%r12), %rax
jmp 0x12341
cmpb $0x1, 0x5(%r12)
jne 0x1234c
movq 0x18(%r14), %rcx
cmpq %rax, %rcx
cmovbq %rcx, %rax
movq %rax, 0x18(%r14)
addq $0x78, %rbp
cmpq %rbp, %r13
jne 0x122d3
jmp 0x12366
movb $0x1, %al
movl %eax, 0x8(%rsp)
movq 0x10(%rsp), %r14
movq 0x30(%rsp), %rbp
cmpl $0x1, 0x1c(%rbp)
movq 0x18(%rsp), %r12
movq 0x28(%rsp), %r13
jne 0x123b0
testb $0x1, 0x8(%rsp)
je 0x123b0
movq (%r15), %rax
movq %r15, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq *0x10(%rax)
movq 0x10(%rsp), %r14
subss (%r14), %xmm0
ucomiss 0x20(%rbp), %xmm0
movq 0x18(%rsp), %r12
jbe 0x123b0
movl $0x0, 0x8(%rsp)
jmp 0x123b7
testb $0x1, 0x8(%rsp)
jne 0x1241e
movq (%rbx), %rax
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
cmpq %rcx, 0x20(%rax)
jbe 0x12416
movq 0x20(%rsp), %r13
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq %r14, 0x18(%rax)
movq (%rbx), %rax
movq 0x10(%rax), %rax
movq %r14, 0x20(%rax)
movq (%rbx), %r12
decq 0x10(%rbx)
movq %r12, %rdi
callq 0x53d0
movq %r12, %rdi
callq 0x5260
movq (%rbx), %rax
movq 0x10(%rax), %rax
cmpq %r13, 0x20(%rax)
ja 0x123d4
movq 0x10(%rsp), %r14
movq 0x28(%rsp), %r13
movq 0x18(%rsp), %r12
incl %r13d
jmp 0x1218f
testb $0x1, 0x8(%rsp)
je 0x12493
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 0x120b9
movq 0x20(%rsp), %r15
movq 0x10(%rax), %rax
cmpq %r15, 0x20(%rax)
jb 0x120b9
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 0x53d0
movq %r14, %rdi
callq 0x5260
movq (%rbx), %rax
cmpq %rbx, %rax
jne 0x12449
jmp 0x120b9
movq %r12, %rsi
cmpb $0x1, 0x5(%r14)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jne 0x124b3
movq %r15, %rdi
callq 0xf8b0
shrq $0x20, %rax
movl %eax, 0xc(%rsp)
movss 0xc(%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 0x53d0
movq %r14, %rdi
callq 0x5260
xorl %ebp, %ebp
jmp 0x120b9
jmp 0x124f6
jmp 0x124f6
jmp 0x124f6
jmp 0x124f6
jmp 0x124f6
jmp 0x124f6
jmp 0x124f6
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xd12e
movq %rbx, %rdi
callq 0x5410
nop