// File: /workspace/github_cpp_makefile_star2_O3/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
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x60(%rdi), %r13
leaq 0x10(%rsp), %rsi
movq %r15, (%rsi)
movl %edx, 0x8(%rsi)
movq %r13, %rdi
callq 0x25662
testq %rax, %rax
je 0x25036
movq %rax, %rbx
movq %r14, %r13
testb %r12b, %r12b
je 0x24fa4
movq 0x1806f(%rip), %r14     # 0x3cfd8
leaq 0x8bd1(%rip), %rsi      # 0x2db41
movl $0x1b, %edx
movq %r14, %rdi
callq 0x52e0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5270
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51e0
movq 0x18(%rbx), %r14
cmpb $0x0, 0x89(%r14)
jne 0x25268
cmpb $0x0, 0x88(%r14)
jne 0x25268
movq 0xa8(%r14), %rax
xorl %edx, %edx
cmpq 0xb0(%r14), %rax
jne 0x2526a
cmpq $0x0, 0x98(%r13)
jne 0x2526a
movl 0x10(%r14), %eax
cvtsi2ss %rax, %xmm0
mulss 0x8(%r14), %xmm0
movss %xmm0, 0xc(%rsp)
movq %r13, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x254ac
movq 0x18(%rbx), %r14
movl 0x10(%r14), %eax
addl 0x44(%r13), %eax
addss 0xc(%rsp), %xmm0
cvtsi2ss %rax, %xmm1
movl %eax, 0x10(%r14)
divss %xmm1, %xmm0
movss %xmm0, 0x8(%r14)
movb $0x1, %dl
jmp 0x2526a
movl %ebp, 0xc(%rsp)
testb %r12b, %r12b
je 0x25081
movq 0x17f92(%rip), %rbx     # 0x3cfd8
leaq 0x8a7f(%rip), %rsi      # 0x2dacc
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x52e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5270
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51e0
incl 0x50(%r14)
movl $0xc0, %edi
callq 0x5290
movq %r14, %rbp
movq %rax, %r14
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq %rax, 0xf(%r14)
leaq 0x17b7a(%rip), %rcx     # 0x3cc20
movq %rcx, (%r14)
leaq 0x18(%r14), %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x1c(%r14)
movups %xmm0, 0x2c(%r14)
movups %xmm0, 0x3c(%r14)
movups %xmm0, 0x4c(%r14)
movq %rax, 0x5c(%r14)
movb $0x1, 0x74(%r14)
movq %rax, 0x78(%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc30a
movw $0x0, 0x88(%r14)
movl 0xc(%rsp), %eax
movl %eax, 0x8c(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x90(%r14)
movups %xmm0, 0xa0(%r14)
movups %xmm0, 0xb0(%r14)
leaq 0x10(%rsp), %rsi
movq %rbx, (%rsi)
movl %eax, 0x8(%rsi)
movq %r14, 0x10(%rsi)
movq %r13, %rdi
callq 0x26aa0
movq 0x8(%rbp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x20(%rax)
testb %al, %al
je 0x25190
testb %r12b, %r12b
je 0x2517b
movq 0x17e98(%rip), %rbx     # 0x3cfd8
leaq 0x89a4(%rip), %rsi      # 0x2daeb
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x52e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5270
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51e0
movl $0x0, 0x8(%r14)
movb $0x1, 0x88(%r14)
jmp 0x25268
movq %rbp, %r13
movq 0x8(%rbp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x28(%rax)
testb %al, %al
je 0x25204
testb %r12b, %r12b
je 0x251eb
movq 0x17e28(%rip), %rbx     # 0x3cfd8
leaq 0x8951(%rip), %rsi      # 0x2db08
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x52e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5270
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51e0
movq 0x8(%r13), %rax
movss 0xc(%rax), %xmm0
movss %xmm0, 0x8(%r14)
movb $0x1, 0x89(%r14)
jmp 0x25268
testb %r12b, %r12b
je 0x2524b
movq 0x17dc8(%rip), %rbx     # 0x3cfd8
leaq 0x890e(%rip), %rsi      # 0x2db25
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x52e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5270
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51e0
movq %r13, %rdi
movq %r15, %rsi
movl 0xc(%rsp), %edx
callq 0x254ac
movss %xmm0, 0x8(%r14)
movl 0x44(%r13), %eax
movl %eax, 0x10(%r14)
xorl %edx, %edx
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0x5260
movq %rbx, %rdi
callq 0x5410
nop