// File: /workspace/github_cpp_makefile_star2_O2/bonetblai[P]mdp-engine/ctp3/../engine/aot.h
// Function: Online::Policy::AOT::aot_t<state_t>::fetch_node(state_t const&, unsigned int, bool) const
std::pair<state_node_t<T>*, bool> fetch_node(const T &state, unsigned depth, bool debug = false) const {
        typename hash_t<T>::iterator it = table_.find(std::make_pair(&state, depth));
        if( it == table_.end() ) {
            if( debug ) std::cout << "fetch_node: node was NOT-FOUND" << std::endl;
            ++num_nodes_;
            state_node_t<T> *node = new state_node_t<T>(state, depth);
            table_.insert(std::make_pair(std::make_pair(&node->state_, depth),
                                         node));
            if( problem_.terminal(state) ) {
                if( debug ) std::cout << "fetch_node: node is TERMINAL" << std::endl;
                node->value_ = 0;
                node->is_goal_ = true;
            } else if( problem_.dead_end(state) ) {
                if( debug ) std::cout << "fetch_node: node is DEAD-END" << std::endl;
                node->value_ = problem_.dead_end_value();
                node->is_dead_end_ = true;
            } else {
                if( debug ) std::cout << "fetch_node: node is REGULAR" << std::endl;
                node->value_ = evaluate(state, depth);
                node->nsamples_ = leaf_nsamples_;
            }
            return std::make_pair(node, false);
        } else {
            if( debug ) std::cout << "fetch_node: node was FOUND!" << std::endl;
            bool re_evaluated = false;
            if( it->second->is_leaf() && !it->second->is_dead_end_ && !it->second->is_goal_ && (heuristic_ == 0) ) {
                // resample: throw other rollouts to get better estimation. Only done when heuristic_ == 0
                float old_val = it->second->value_;
                float new_val = old_val * it->second->nsamples_ + evaluate(state, depth);
                it->second->nsamples_ += leaf_nsamples_;
                it->second->value_ = new_val / it->second->nsamples_;
                re_evaluated = true;
            }
            return std::make_pair(it->second, re_evaluated);
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r12d
movq %rsi, %r15
movq %rdi, %r14
leaq 0x60(%rdi), %r13
leaq 0x10(%rsp), %rsi
movq %r15, (%rsi)
movl %edx, 0x8(%rsp)
movl %edx, 0x8(%rsi)
movq %r13, %rdi
callq 0x1ba4a
testq %rax, %rax
je 0x1b63d
movq %rax, %rbp
testb %r12b, %r12b
je 0x1b5b0
movq 0x19a3c(%rip), %rdi     # 0x34fd8
leaq 0x7588(%rip), %rsi      # 0x22b2b
callq 0x5290
movq %rax, %rdi
callq 0x5130
movq 0x18(%rbp), %rbx
cmpb $0x0, 0x89(%rbx)
jne 0x1b75f
cmpb $0x0, 0x88(%rbx)
jne 0x1b75f
movq 0xa8(%rbx), %rax
xorl %edx, %edx
cmpq 0xb0(%rbx), %rax
jne 0x1b761
cmpq $0x0, 0x98(%r14)
jne 0x1b761
movl 0x10(%rbx), %eax
cvtsi2ss %rax, %xmm0
mulss 0x8(%rbx), %xmm0
movss %xmm0, 0xc(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movl 0x8(%rsp), %edx
callq 0x1b9a4
movq 0x18(%rbp), %rbx
movl 0x10(%rbx), %eax
addl 0x44(%r14), %eax
addss 0xc(%rsp), %xmm0
cvtsi2ss %rax, %xmm1
movl %eax, 0x10(%rbx)
divss %xmm1, %xmm0
movss %xmm0, 0x8(%rbx)
movb $0x1, %dl
jmp 0x1b761
testb %r12b, %r12b
je 0x1b65d
movq 0x1998f(%rip), %rdi     # 0x34fd8
leaq 0x7466(%rip), %rsi      # 0x22ab6
callq 0x5290
movq %rax, %rdi
callq 0x5130
incl 0x50(%r14)
movl $0xc0, %edi
callq 0x52a0
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
movl 0x8(%rsp), %ebp
movl %ebp, %edx
callq 0x1b952
movq %rbx, %rax
addq $0x18, %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movl %ebp, 0x8(%rsi)
movq %rbx, 0x10(%rsi)
movq %r13, %rdi
callq 0x1cd48
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x20(%rax)
testb %al, %al
je 0x1b6de
testb %r12b, %r12b
je 0x1b6ce
movq 0x1991e(%rip), %rdi     # 0x34fd8
leaq 0x7414(%rip), %rsi      # 0x22ad5
callq 0x5290
movq %rax, %rdi
callq 0x5130
andl $0x0, 0x8(%rbx)
movb $0x1, 0x88(%rbx)
jmp 0x1b75f
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x28(%rax)
testb %al, %al
je 0x1b726
testb %r12b, %r12b
je 0x1b70f
movq 0x198dd(%rip), %rdi     # 0x34fd8
leaq 0x73f0(%rip), %rsi      # 0x22af2
callq 0x5290
movq %rax, %rdi
callq 0x5130
movq 0x8(%r14), %rax
movss 0xc(%rax), %xmm0
movss %xmm0, 0x8(%rbx)
movb $0x1, 0x89(%rbx)
jmp 0x1b75f
testb %r12b, %r12b
je 0x1b746
movq 0x198a6(%rip), %rdi     # 0x34fd8
leaq 0x73d6(%rip), %rsi      # 0x22b0f
callq 0x5290
movq %rax, %rdi
callq 0x5130
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x1b9a4
movss %xmm0, 0x8(%rbx)
movl 0x44(%r14), %eax
movl %eax, 0x10(%rbx)
xorl %edx, %edx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x5270
movq %r14, %rdi
callq 0x5410