// File: bonetblai[P]mdp-engine/ctp3/../engine/aot.h
// Function: Online::Policy::AOT::aot_t<state_t>::operator()(state_t const&) const
virtual Problem::action_t operator()(const T &s) const {
        if( ((base_policy_ == 0) && (heuristic_ == 0) && (width_ > 0)) || ((base_policy_ == 0) && (width_ == 0)) ) {
            std::cout << Utils::error() << "(base) policy or heuristic must be specified for aot() policy!" << std::endl;
            exit(1);
        }

        // initialize tree and setup expansion loop for selection strategy
        ++policy_t<T>::decisions_;
        clear();
        state_node_t<T> *root = fetch_node(s, 0).first;
        (this->*setup_expansion_loop_ptr_)(root);

        // expand leaves and propagate values
        unsigned expanded = 0;
        std::vector<node_t<T>*> nodes_to_propagate;
        for( unsigned i = 0; (i < width_) && (this->*exist_nodes_to_expand_ptr_)(); ) {
            unsigned expanded_in_iteration = 0;
            while( (i < width_) &&
                   (expanded_in_iteration < expansions_per_iteration_) &&
                   (this->*exist_nodes_to_expand_ptr_)() ) {
                select_and_expand(root, nodes_to_propagate);
                for( int j = 0, jsz = nodes_to_propagate.size(); j < jsz; ++j )
                    propagate(nodes_to_propagate[j]);
                nodes_to_propagate.clear();
                ++expanded_in_iteration;
                ++i;
            }
            expanded += expanded_in_iteration;
            (this->*prepare_next_expansion_iteration_ptr_)(root);
        }
        (this->*clear_internal_state_ptr_)();

#if 0
        std::cout << "[1] value at root = " << root->value_ << std::endl;
        for( Problem::action_t a = 0; a < problem_.number_actions(root->state_); ++a ) {
            if( problem_.applicable(root->state_, a) ) {
                double value = 0;
                std::vector<std::pair<T, float> > outcomes;
                problem_.next(root->state_, a, outcomes, true);
                for( int i = 0, isz = outcomes.size(); i < isz; ++i ) {
                    const T &state = outcomes[i].first;
                    float prob = outcomes[i].second;
                    std::pair<state_node_t<T>*, bool> p = fetch_node(state, 1);
                    value += prob * p.first->value_;
                    std::cout << "    outcome " << i << ": prob = " << prob << ", value = " << p.first->value_ << std::endl;
                    p.first->print(std::cout); std::cout << std::endl;
                }
                value = problem_.cost(root->state_, a) + problem_.discount() * value;
                std::cout << "    ACTION " << a << ": value = " << value << std::endl;
            }
        }
#endif

        assert((width_ == 0) || ((root != 0) && problem_.applicable(s, root->best_action(random_ties_))));
        assert(expanded <= width_);

        // select best action
        if( width_ == 0 ) {
            float start_time = Utils::read_time_in_seconds();
            Problem::action_t action = (*base_policy_)(s);
            policy_t<T>::base_policy_time_ += Utils::read_time_in_seconds() - start_time;
            return action;
        } else {
            return root->best_action(random_ties_);
        }
    }

// Assembly:
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x178(%rsp)
movq %rsi, 0x170(%rsp)
movq 0x178(%rsp), %rax
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0x28(%rax)
jne 0x4362e
movq 0xd0(%rsp), %rax
cmpq $0x0, 0x98(%rax)
jne 0x4362e
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x30(%rax)
ja 0x43653
movq 0xd0(%rsp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x436f7
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x436f7
leaq 0x150(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x1e8e0
movq 0xc0(%rsp), %rsi
movq 0x3f959(%rip), %rdi     # 0x82fd0
callq 0x62f0
movq %rax, 0xc8(%rsp)
jmp 0x43686
movq 0xc8(%rsp), %rdi
leaq 0x1c353(%rip), %rsi     # 0x5f9e8
callq 0x6330
movq %rax, 0xb8(%rsp)
jmp 0x436a4
movq 0xb8(%rsp), %rdi
movq 0x3f905(%rip), %rsi     # 0x82fb8
callq 0x6370
jmp 0x436ba
leaq 0x150(%rsp), %rdi
callq 0x61f0
movl $0x1, %edi
callq 0x63e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x148(%rsp)
movl %eax, 0x144(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x61f0
jmp 0x43d17
movq 0xd0(%rsp), %rdi
movl 0x20(%rdi), %eax
incl %eax
movl %eax, 0x20(%rdi)
callq 0x4c910
movq 0xd0(%rsp), %rdi
movq 0x170(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x4c940
movq 0xd0(%rsp), %rcx
movb %dl, 0x120(%rsp)
movq %rax, 0x118(%rsp)
movb 0x120(%rsp), %al
movb %al, 0x130(%rsp)
movq 0x118(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x168(%rcx), %rax
movq %rax, 0xa8(%rsp)
movq 0x170(%rcx), %rdx
addq %rdx, %rcx
movq %rcx, 0xb0(%rsp)
andq $0x1, %rax
cmpq $0x0, %rax
je 0x437ba
movq 0xa8(%rsp), %rcx
movq 0xb0(%rsp), %rax
movq (%rax), %rax
subq $0x1, %rcx
movq (%rax,%rcx), %rax
movq %rax, 0xa0(%rsp)
jmp 0x437ca
movq 0xa8(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x138(%rsp), %rsi
callq *%rax
movl $0x0, 0x114(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x4cee0
movl $0x0, 0xf4(%rsp)
movq 0xd0(%rsp), %rdx
movl 0xf4(%rsp), %ecx
xorl %eax, %eax
cmpl 0x30(%rdx), %ecx
movb %al, 0x9f(%rsp)
jae 0x438b5
movq 0xd0(%rsp), %rcx
movq 0x188(%rcx), %rax
movq %rax, 0x88(%rsp)
movq 0x190(%rcx), %rdx
addq %rdx, %rcx
movq %rcx, 0x90(%rsp)
andq $0x1, %rax
cmpq $0x0, %rax
je 0x43880
movq 0x88(%rsp), %rcx
movq 0x90(%rsp), %rax
movq (%rax), %rax
subq $0x1, %rcx
movq (%rax,%rcx), %rax
movq %rax, 0x80(%rsp)
jmp 0x43890
movq 0x88(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x90(%rsp), %rdi
movq 0x80(%rsp), %rax
callq *%rax
movb %al, 0x7f(%rsp)
jmp 0x438a8
movb 0x7f(%rsp), %al
movb %al, 0x9f(%rsp)
jmp 0x438b5
movb 0x9f(%rsp), %al
testb $0x1, %al
jne 0x438c5
jmp 0x43af1
movl $0x0, 0xf0(%rsp)
movq 0xd0(%rsp), %rdx
movl 0xf4(%rsp), %ecx
xorl %eax, %eax
cmpl 0x30(%rdx), %ecx
movb %al, 0x7e(%rsp)
jae 0x439a1
movq 0xd0(%rsp), %rdx
movl 0xf0(%rsp), %ecx
xorl %eax, %eax
cmpl 0x40(%rdx), %ecx
movb %al, 0x7e(%rsp)
jae 0x439a1
movq 0xd0(%rsp), %rcx
movq 0x188(%rcx), %rax
movq %rax, 0x68(%rsp)
movq 0x190(%rcx), %rdx
addq %rdx, %rcx
movq %rcx, 0x70(%rsp)
andq $0x1, %rax
cmpq $0x0, %rax
je 0x4397b
movq 0x68(%rsp), %rcx
movq 0x70(%rsp), %rax
movq (%rax), %rax
subq $0x1, %rcx
movq (%rax,%rcx), %rax
movq %rax, 0x60(%rsp)
jmp 0x43985
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x148(%rsp)
movl %eax, 0x144(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x4d1c0
jmp 0x43d17
movq 0x68(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rax
callq *%rax
movb %al, 0x5f(%rsp)
jmp 0x43997
movb 0x5f(%rsp), %al
movb %al, 0x7e(%rsp)
jmp 0x439a1
movb 0x7e(%rsp), %al
testb $0x1, %al
jne 0x439ae
jmp 0x43a6c
movq 0xd0(%rsp), %rdi
movq 0x138(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0x4cef0
jmp 0x439cd
movl $0x0, 0xec(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x4cfa0
movl %eax, 0xe8(%rsp)
movl 0xec(%rsp), %eax
cmpl 0xe8(%rsp), %eax
jge 0x43a38
movslq 0xec(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x4cff0
movq 0xd0(%rsp), %rdi
movq (%rax), %rsi
callq 0x4cfc0
jmp 0x43a23
jmp 0x43a25
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x439ec
leaq 0xf8(%rsp), %rdi
callq 0x4d010
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x438d0
movq 0xd0(%rsp), %rcx
movl 0xf0(%rsp), %edx
movl 0x114(%rsp), %eax
addl %edx, %eax
movl %eax, 0x114(%rsp)
movq 0x178(%rcx), %rax
movq %rax, 0x48(%rsp)
movq 0x180(%rcx), %rdx
addq %rdx, %rcx
movq %rcx, 0x50(%rsp)
andq $0x1, %rax
cmpq $0x0, %rax
je 0x43acc
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rax
movq (%rax), %rax
subq $0x1, %rcx
movq (%rax,%rcx), %rax
movq %rax, 0x40(%rsp)
jmp 0x43ad6
movq 0x48(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rax
movq 0x138(%rsp), %rsi
callq *%rax
jmp 0x43aec
jmp 0x43807
movq 0xd0(%rsp), %rcx
movq 0x1a8(%rcx), %rax
movq %rax, 0x30(%rsp)
movq 0x1b0(%rcx), %rdx
addq %rdx, %rcx
movq %rcx, 0x38(%rsp)
andq $0x1, %rax
cmpq $0x0, %rax
je 0x43b3a
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
movq (%rax), %rax
subq $0x1, %rcx
movq (%rax,%rcx), %rax
movq %rax, 0x28(%rsp)
jmp 0x43b44
movq 0x30(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rax
callq *%rax
jmp 0x43b52
movq 0xd0(%rsp), %rcx
movb $0x1, %al
cmpl $0x0, 0x30(%rcx)
movb %al, 0x27(%rsp)
je 0x43bde
xorl %eax, %eax
cmpq $0x0, 0x138(%rsp)
movb %al, 0x26(%rsp)
je 0x43bd6
movq 0xd0(%rsp), %rax
movq 0x8(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x170(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq 0x138(%rsp), %rdi
movzbl 0x3c(%rax), %esi
andl $0x1, %esi
callq 0x4d030
movl %eax, 0x20(%rsp)
jmp 0x43baf
movl 0x20(%rsp), %edx
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
movb %al, 0xf(%rsp)
jmp 0x43bcc
movb 0xf(%rsp), %al
movb %al, 0x26(%rsp)
jmp 0x43bd6
movb 0x26(%rsp), %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x43be8
jmp 0x43bea
jmp 0x43c09
leaq 0x1be36(%rip), %rdi     # 0x5fa27
leaq 0x1ad7d(%rip), %rsi     # 0x5e975
movl $0x1e1, %edx            # imm = 0x1E1
leaq 0x1be7d(%rip), %rcx     # 0x5fa81
callq 0x6220
movq 0xd0(%rsp), %rcx
movl 0x114(%rsp), %eax
cmpl 0x30(%rcx), %eax
ja 0x43c1f
jmp 0x43c3e
leaq 0x1bec4(%rip), %rdi     # 0x5faea
leaq 0x1ad48(%rip), %rsi     # 0x5e975
movl $0x1e2, %edx            # imm = 0x1E2
leaq 0x1be48(%rip), %rcx     # 0x5fa81
callq 0x6220
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x43cc3
callq 0x84f0
movq 0xd0(%rsp), %rax
movss %xmm0, 0xe4(%rsp)
movq 0x28(%rax), %rdi
movq 0x170(%rsp), %rsi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movl %eax, 0x8(%rsp)
jmp 0x43c7d
movl 0x8(%rsp), %eax
movl %eax, 0xe0(%rsp)
callq 0x84f0
movq 0xd0(%rsp), %rax
subss 0xe4(%rsp), %xmm0
addss 0x18(%rax), %xmm0
movss %xmm0, 0x18(%rax)
movl 0xe0(%rsp), %eax
movl %eax, 0x184(%rsp)
movl $0x1, 0xdc(%rsp)
jmp 0x43cfb
movq 0xd0(%rsp), %rax
movq 0x138(%rsp), %rdi
movzbl 0x3c(%rax), %esi
andl $0x1, %esi
callq 0x4d030
movl %eax, 0x4(%rsp)
jmp 0x43ce5
movl 0x4(%rsp), %eax
movl %eax, 0x184(%rsp)
movl $0x1, 0xdc(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x4d1c0
movl 0x184(%rsp), %eax
addq $0x188, %rsp            # imm = 0x188
retq
movq 0x148(%rsp), %rdi
callq 0x6520
nopw %cs:(%rax,%rax)
nop