// File: bonetblai[P]mdp-engine/ctp3/../engine/lrtdp.h
// Function: Algorithm::lrtdp_base_t<state_t>::lrtdp_trial(state_t const&, Problem::hash_t<state_t>&) const
size_t lrtdp_trial(const T &s, Problem::hash_t<T> &hash) const {
        std::list<T> states;
        std::pair<T, bool> n;

        Hash::data_t *dptr = hash.data_ptr(s);
        states.push_back(s);
        dptr->inc_count();
        T t = s;

#ifdef DEBUG
        std::cout << "debug: lrtdp-base(): trial: begin" << std::endl;
#endif

        size_t steps = 1;
        while( !problem_.terminal(t) && !dptr->solved() && (dptr->count() <= bound_) ) {

#ifdef DEBUG
            std::cout << "debug: lrtdp-base():   " << t << " = " << dptr->value() << std::endl;
#endif

            std::pair<Problem::action_t, float> p = hash.best_q_value(t);
            dptr->update(p.second);
            hash.inc_updates();

            if( Random::real() < epsilon_greedy_ ) {
                n = problem_.usample(t, p.first);
            } else {
                if( type_ == 0 ) {
                    n = problem_.sample(t, p.first);
                } else if( type_ == 1 ) {
                    n = problem_.usample(t, p.first);
                } else if( type_ == 2 ) {
                    n = problem_.nsample(t, p.first, hash);
                }
            }
            if( !n.second ) break;

            t = n.first;
            dptr = hash.data_ptr(t);
            states.push_back(t);
            dptr->inc_count();
            ++steps;
        }

#ifdef DEBUG
        std::cout << "debug: lrtdp-base(): trial: end" << std::endl;
#endif

        while( !states.empty() ) {
            hash.clear_count(states.back());
            bool solved = check_solved(problem_, states.back(), hash, epsilon_);
            states.pop_back();
            if( !solved ) break;
        }

        while( !states.empty() ) {
            hash.clear_count(states.back());
            states.pop_back();
        }
        return steps;
    }

// Assembly:
subq $0x388, %rsp            # imm = 0x388
movq %rdi, 0x380(%rsp)
movq %rsi, 0x378(%rsp)
movq %rdx, 0x370(%rsp)
movq 0x380(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x358(%rsp), %rdi
callq 0x2a7a0
leaq 0x2e0(%rsp), %rdi
callq 0x2a7b0
jmp 0x2a1b8
movq 0x370(%rsp), %rdi
movq 0x378(%rsp), %rsi
callq 0x20ca0
movq %rax, 0x50(%rsp)
jmp 0x2a1d4
movq 0x50(%rsp), %rax
movq %rax, 0x2c8(%rsp)
movq 0x378(%rsp), %rsi
leaq 0x358(%rsp), %rdi
callq 0x2a7e0
jmp 0x2a1f8
movq 0x2c8(%rsp), %rdi
callq 0x2a820
jmp 0x2a207
movq 0x378(%rsp), %rsi
leaq 0x258(%rsp), %rdi
callq 0x16650
jmp 0x2a21e
movq $0x1, 0x250(%rsp)
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
leaq 0x258(%rsp), %rsi
callq *%rax
movb %al, 0x4f(%rsp)
jmp 0x2a24a
movb 0x4f(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x4e(%rsp)
jne 0x2a2a0
jmp 0x2a25b
movq 0x2c8(%rsp), %rdi
callq 0x20d90
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x4e(%rsp)
jne 0x2a2a0
movq 0x2c8(%rsp), %rdi
callq 0x2a840
movq %rax, 0x40(%rsp)
jmp 0x2a289
movq 0x40(%rsp), %rax
movq 0x58(%rsp), %rcx
movl 0x24(%rcx), %ecx
cmpq %rcx, %rax
setbe %al
movb %al, 0x4e(%rsp)
movb 0x4e(%rsp), %al
testb $0x1, %al
jne 0x2a2ad
jmp 0x2a5ed
movq 0x370(%rsp), %rdi
leaq 0x258(%rsp), %rsi
callq 0x22eb0
movq %rax, 0x38(%rsp)
jmp 0x2a2c9
movq 0x38(%rsp), %rax
movq %rax, 0x248(%rsp)
movq 0x2c8(%rsp), %rdi
movss 0x24c(%rsp), %xmm0
callq 0x22fd0
movq 0x370(%rsp), %rdi
callq 0x22ff0
callq 0x19b50
movss %xmm0, 0x34(%rsp)
jmp 0x2a306
movss 0x34(%rsp), %xmm1
movq 0x58(%rsp), %rax
movss 0x28(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2a3e0
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rsi
movl 0x248(%rsp), %ecx
leaq 0x1d0(%rsp), %rdi
leaq 0x258(%rsp), %rdx
callq 0x2a850
jmp 0x2a346
leaq 0x2e0(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x2a930
jmp 0x2a35d
leaq 0x1d0(%rsp), %rdi
callq 0x19f70
jmp 0x2a562
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0x2a73d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0x2a730
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0x2a723
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x19f70
jmp 0x2a723
movq 0x58(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x2a461
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rsi
movl 0x248(%rsp), %ecx
leaq 0x158(%rsp), %rdi
leaq 0x258(%rsp), %rdx
callq 0x19da0
jmp 0x2a412
leaq 0x2e0(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x2a930
jmp 0x2a429
leaq 0x158(%rsp), %rdi
callq 0x19f70
jmp 0x2a560
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x19f70
jmp 0x2a723
movq 0x58(%rsp), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x2a4e2
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rsi
movl 0x248(%rsp), %ecx
leaq 0xe0(%rsp), %rdi
leaq 0x258(%rsp), %rdx
callq 0x2a850
jmp 0x2a493
leaq 0x2e0(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x2a930
jmp 0x2a4aa
leaq 0xe0(%rsp), %rdi
callq 0x19f70
jmp 0x2a55e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x19f70
jmp 0x2a723
movq 0x58(%rsp), %rax
cmpl $0x2, 0x1c(%rax)
jne 0x2a55c
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rsi
movl 0x248(%rsp), %ecx
movq 0x370(%rsp), %r8
leaq 0x68(%rsp), %rdi
leaq 0x258(%rsp), %rdx
callq 0x2a970
jmp 0x2a519
leaq 0x2e0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2a930
jmp 0x2a52d
leaq 0x68(%rsp), %rdi
callq 0x19f70
jmp 0x2a55c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x19f70
jmp 0x2a723
jmp 0x2a55e
jmp 0x2a560
jmp 0x2a562
testb $0x1, 0x350(%rsp)
jne 0x2a56e
jmp 0x2a5ed
leaq 0x258(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
callq 0x17c20
jmp 0x2a585
movq 0x370(%rsp), %rdi
leaq 0x258(%rsp), %rsi
callq 0x20ca0
movq %rax, 0x28(%rsp)
jmp 0x2a5a1
movq 0x28(%rsp), %rax
movq %rax, 0x2c8(%rsp)
leaq 0x358(%rsp), %rdi
leaq 0x258(%rsp), %rsi
callq 0x2a7e0
jmp 0x2a5c5
movq 0x2c8(%rsp), %rdi
callq 0x2a820
jmp 0x2a5d4
movq 0x250(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x250(%rsp)
jmp 0x2a22a
jmp 0x2a5ef
leaq 0x358(%rsp), %rdi
callq 0x2aec0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2a607
jmp 0x2a695
movq 0x370(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x358(%rsp), %rdi
callq 0x2af50
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x2aee0
jmp 0x2a630
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
leaq 0x358(%rsp), %rdi
callq 0x2af50
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq 0x58(%rsp), %rax
movq 0x370(%rsp), %rdx
movss 0x20(%rax), %xmm0
callq 0x2af90
movb %al, 0x1f(%rsp)
jmp 0x2a670
movb 0x1f(%rsp), %al
andb $0x1, %al
movb %al, 0x67(%rsp)
leaq 0x358(%rsp), %rdi
callq 0x2b4f0
testb $0x1, 0x67(%rsp)
jne 0x2a690
jmp 0x2a695
jmp 0x2a5ef
jmp 0x2a697
leaq 0x358(%rsp), %rdi
callq 0x2aec0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2a6ac
jmp 0x2a6e4
movq 0x370(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x358(%rsp), %rdi
callq 0x2af50
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x2aee0
jmp 0x2a6d5
leaq 0x358(%rsp), %rdi
callq 0x2b4f0
jmp 0x2a697
movq 0x250(%rsp), %rax
movq %rax, (%rsp)
leaq 0x258(%rsp), %rdi
callq 0x115b0
leaq 0x2e0(%rsp), %rdi
callq 0x19f70
leaq 0x358(%rsp), %rdi
callq 0x2b530
movq (%rsp), %rax
addq $0x388, %rsp            # imm = 0x388
retq
leaq 0x258(%rsp), %rdi
callq 0x115b0
leaq 0x2e0(%rsp), %rdi
callq 0x19f70
leaq 0x358(%rsp), %rdi
callq 0x2b530
movq 0x2d8(%rsp), %rdi
callq 0x6520
nopw (%rax,%rax)