// File: /workspace/github_cpp_makefile_star2_O3/bonetblai[P]mdp-engine/ctp3/../engine/uct.h
// Function: Online::Policy::UCT::uct_t<state_t>::search_tree(state_t const&, unsigned int) const
float search_tree(const T &s, unsigned depth) const {
#ifdef DEBUG
        std::cout << std::setw(2*depth) << "" << "search_tree(" << s << "):";
#endif

        if( (depth == horizon_) || problem_.terminal(s) ) {
#ifdef DEBUG
            std::cout << " end" << std::endl;
#endif
            return 0;
        }

        if( problem_.dead_end(s) ) {
#ifdef DEBUG
            std::cout << " dead-end" << std::endl;
#endif
            return problem_.dead_end_value();
        }

        typename hash_t<T>::iterator it = table_.find(std::make_pair(depth, s));

        if( it == table_.end() ) {
            std::vector<float> values(1 + problem_.number_actions(s), 0);
            std::vector<int> counts(1 + problem_.number_actions(s), 0);
            table_.insert(std::make_pair(std::make_pair(depth, s), data_t(values, counts)));
            float value = evaluate(s, depth);
#ifdef DEBUG
            std::cout << " insert in tree w/ value=" << value << std::endl;
#endif
            return value;
        } else {
            // select action for this node and increase counts
            Problem::action_t a = select_action(s, it->second, depth, true, random_ties_);
            ++it->second.counts_[0];
            ++it->second.counts_[1+a];

            // sample next state
            std::pair<const T, bool> p = problem_.sample(s, a);
            float cost = problem_.cost(s, a);

#ifdef DEBUG
            std::cout << " count=" << it->second.counts_[0]-1
                      << " fetch " << std::setprecision(5) << it->second.values_[1+a]
                      << " a=" << a
                      << " next=" << p.first
                      << std::endl;
#endif

            // do recursion and update value
            float &old_value = it->second.values_[1+a];
            float n = it->second.counts_[1+a];
            float new_value = cost + problem_.discount() * search_tree(p.first, 1 + depth);
            old_value += (new_value - old_value) / n;
            return new_value;
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
xorps %xmm0, %xmm0
cmpl %edx, 0x34(%rdi)
je 0x1f67d
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
xorps %xmm0, %xmm0
testb %al, %al
jne 0x1f67d
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x28(%rax)
testb %al, %al
je 0x1f2d3
movq 0x8(%r14), %rax
movss 0xc(%rax), %xmm0
jmp 0x1f67d
leaq 0x48(%r14), %r12
leaq 0x80(%rsp), %rdi
movl %ebx, -0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rdi)
movups %xmm0, 0x14(%rdi)
movups %xmm0, 0x24(%rdi)
movups %xmm0, 0x34(%rdi)
xorl %eax, %eax
movq %rax, 0x44(%rdi)
movb $0x1, 0x5c(%rdi)
movq %rax, 0x60(%rdi)
movq %r15, %rsi
callq 0xc30a
leaq 0x78(%rsp), %rsi
movq %r12, %rdi
callq 0x2041a
movq %rax, %r13
cmpb $0x0, 0xdc(%rsp)
jne 0x1f337
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f337
callq 0x5340
testq %r13, %r13
je 0x1f489
movq %r13, %rdx
subq $-0x80, %rdx
movzbl 0x3c(%r14), %r9d
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x1f756
movl %eax, %ebp
movq 0x98(%r13), %rax
incl (%rax)
movslq %ebp, %r12
incl 0x4(%rax,%r12,4)
movq 0x8(%r14), %rsi
leaq 0x120(%rsp), %rdi
movq %r15, %rdx
movl %ebp, %ecx
callq 0xcea2
xorl %eax, %eax
leaq 0x78(%rsp), %rdi
movq %rax, 0x44(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x34(%rdi)
movups %xmm0, 0x24(%rdi)
movups %xmm0, 0x14(%rdi)
movups %xmm0, 0x4(%rdi)
movb $0x1, 0x5c(%rdi)
movq %rax, 0x60(%rdi)
leaq 0x120(%rsp), %rsi
callq 0xc30a
movb 0x190(%rsp), %al
movb %al, 0xe8(%rsp)
cmpb $0x0, 0x17c(%rsp)
jne 0x1f3e5
movq 0x180(%rsp), %rdi
testq %rdi, %rdi
je 0x1f3e5
callq 0x5340
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %ebp, %edx
callq *0x48(%rax)
movss %xmm0, 0x8(%rsp)
incq %r12
movq 0x80(%r13), %r15
movq 0x98(%r13), %rax
movl (%rax,%r12,4), %ebp
movq 0x8(%r14), %rax
movss 0x8(%rax), %xmm0
movss %xmm0, 0xc(%rsp)
incl %ebx
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
movl %ebx, %edx
callq 0x1f27a
cvtsi2ss %ebp, %xmm3
mulss 0xc(%rsp), %xmm0
addss 0x8(%rsp), %xmm0
movss (%r15,%r12,4), %xmm1
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
divss %xmm3, %xmm2
addss %xmm1, %xmm2
movss %xmm2, (%r15,%r12,4)
cmpb $0x0, 0xd4(%rsp)
jne 0x1f67d
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x1f67d
movss %xmm0, 0x8(%rsp)
callq 0x5340
jmp 0x1f677
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x10(%rax)
incl %eax
movslq %eax, %rsi
leaq 0x78(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x60(%rsp), %rdi
leaq 0x120(%rsp), %rcx
callq 0x1f9d0
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x10(%rax)
incl %eax
movslq %eax, %rsi
leaq 0x78(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x48(%rsp), %rdi
leaq 0x120(%rsp), %rcx
callq 0x1fb5a
leaq 0x128(%rsp), %r13
movl %ebx, -0x8(%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%r13)
movups %xmm0, 0x14(%r13)
movups %xmm0, 0x24(%r13)
movups %xmm0, 0x34(%r13)
xorl %eax, %eax
movq %rax, 0x44(%r13)
movb $0x1, 0x5c(%r13)
movq %rax, 0x60(%r13)
movq %r13, %rdi
movq %r15, %rsi
callq 0xc30a
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x1fcd6
movl 0x120(%rsp), %eax
leaq 0x80(%rsp), %rdi
movl %eax, -0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rdi)
movups %xmm0, 0x14(%rdi)
movups %xmm0, 0x24(%rdi)
movups %xmm0, 0x34(%rdi)
xorl %eax, %eax
movq %rax, 0x44(%rdi)
movb $0x1, 0x5c(%rdi)
movq %rax, 0x60(%rdi)
movq %r13, %rsi
callq 0xc30a
movaps 0x10(%rsp), %xmm0
leaq 0x78(%rsp), %rsi
movups %xmm0, 0x78(%rsi)
movq 0x20(%rsp), %rax
movq %rax, 0x88(%rsi)
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
xorl %eax, %eax
movq %rax, 0x20(%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, 0x90(%rsi)
movq 0x38(%rsp), %rcx
movq %rcx, 0xa0(%rsi)
movups %xmm1, 0x28(%rsp)
movq %rax, 0x38(%rsp)
movq %r12, %rdi
callq 0x1fea6
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x1f5d8
callq 0x5260
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f5ea
callq 0x5260
cmpb $0x0, 0xdc(%rsp)
jne 0x1f606
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f606
callq 0x5340
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1f615
callq 0x5260
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1f624
callq 0x5260
cmpb $0x0, 0x184(%rsp)
jne 0x1f640
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x1f640
callq 0x5340
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x1fd4c
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
movss %xmm0, 0x8(%rsp)
je 0x1f668
callq 0x5260
movss 0x8(%rsp), %xmm0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1f67d
callq 0x5260
movss 0x8(%rsp), %xmm0
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f6d0
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x1fd12
jmp 0x1f6a3
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1f258
jmp 0x1f6b2
movq %rax, %rbx
cmpb $0x0, 0x184(%rsp)
jne 0x1f6d3
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x1f6d3
callq 0x5340
jmp 0x1f6d3
movq %rax, %rbx
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x1f6e9
callq 0x5260
jmp 0x1f6e9
jmp 0x1f6e6
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1f74e
callq 0x5260
jmp 0x1f74e
movq %rax, %rbx
jmp 0x1f74e
jmp 0x1f701
movq %rax, %rbx
cmpb $0x0, 0xd4(%rsp)
jne 0x1f74e
movq 0xd8(%rsp), %rdi
jmp 0x1f744
movq %rax, %rbx
cmpb $0x0, 0x17c(%rsp)
jne 0x1f74e
movq 0x180(%rsp), %rdi
jmp 0x1f744
movq %rax, %rbx
cmpb $0x0, 0xdc(%rsp)
jne 0x1f74e
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f74e
callq 0x5340
movq %rbx, %rdi
callq 0x5410