// File: bonetblai[P]mdp-engine/ctp3/../engine/aot.h
// Function: Online::Policy::AOT::aot_t<state_t>::expand(Online::Policy::AOT::action_node_t<state_t>*, std::vector<Online::Policy::AOT::node_t<state_t>*, std::allocator<Online::Policy::AOT::node_t<state_t>*>>&, bool) const
void expand(action_node_t<T> *a_node,
                std::vector<node_t<T>*> &nodes_to_propagate,
                bool picked_from_queue = true) const {
        assert(a_node->is_leaf());
        assert(!a_node->parent_->is_goal_);
        assert(!a_node->parent_->is_dead_end_);
        a_node->value_ = 0;
        std::vector<std::pair<T, float> > outcomes;
        problem_.next(a_node->parent_->state_, a_node->action_, outcomes);
        a_node->children_.reserve(outcomes.size());
        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 + a_node->parent_->depth_);
            if( p.second ) {
                assert(p.first->is_leaf());
                nodes_to_propagate.push_back(p.first);
            }
            p.first->parents_.push_back(std::make_pair(i, a_node));
            a_node->children_.push_back(std::make_pair(prob, p.first));
            a_node->value_ += prob * p.first->value_;
        }
        a_node->value_ = a_node->action_cost_ + problem_.discount() * a_node->value_;
        nodes_to_propagate.push_back(a_node);

        // re-sample sibling action nodes that are still leaves.
        if( picked_from_queue && (heuristic_ == 0)) {
            state_node_t<T> *parent = a_node->parent_;
            const T &state = parent->state_;
            unsigned depth = 1 + parent->depth_;
            for( int i = 0, isz = parent->children_.size(); i < isz; ++i ) {
                action_node_t<T> *sibling = parent->children_[i];
                if( sibling->is_leaf() ) {
                    float old_val = (sibling->value_ - sibling->action_cost_) / problem_.discount();
                    float eval = evaluate(state, sibling->action_, depth);
                    float new_val = old_val * sibling->nsamples_ + eval;
                    sibling->nsamples_ +=
                      delayed_evaluation_nsamples_ * leaf_nsamples_;
                    sibling->value_ = sibling->action_cost_ +
                      problem_.discount() * new_val/sibling->nsamples_;

#ifdef DEBUG
                    std::cout << "sibling re-sampled: "
                              << "num=" << sibling->nsamples_
                              << std::endl;
#endif
                }
            }
        }
    }

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movb %cl, %al
movq %rdi, 0x150(%rsp)
movq %rsi, 0x148(%rsp)
movq %rdx, 0x140(%rsp)
andb $0x1, %al
movb %al, 0x13f(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x148(%rsp), %rdi
callq 0x4bce0
testb $0x1, %al
jne 0x4e9ea
jmp 0x4e9ec
jmp 0x4ea0b
leaq 0x1139f(%rip), %rdi     # 0x5fd92
leaq 0xff7b(%rip), %rsi      # 0x5e975
movl $0x26c, %edx            # imm = 0x26C
leaq 0x1139e(%rip), %rcx     # 0x5fda4
callq 0x6220
movq 0x148(%rsp), %rax
movq 0x20(%rax), %rax
movb 0x88(%rax), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x4ea25
jmp 0x4ea27
jmp 0x4ea46
leaq 0x113f1(%rip), %rdi     # 0x5fe1f
leaq 0xff40(%rip), %rsi      # 0x5e975
movl $0x26d, %edx            # imm = 0x26D
leaq 0x11363(%rip), %rcx     # 0x5fda4
callq 0x6220
movq 0x148(%rsp), %rax
movq 0x20(%rax), %rax
movb 0x89(%rax), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x4ea60
jmp 0x4ea62
jmp 0x4ea81
leaq 0x113d1(%rip), %rdi     # 0x5fe3a
leaq 0xff05(%rip), %rsi      # 0x5e975
movl $0x26e, %edx            # imm = 0x26E
leaq 0x11328(%rip), %rcx     # 0x5fda4
callq 0x6220
movq 0x148(%rsp), %rax
movl $0x0, 0x8(%rax)
leaq 0x120(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x1a4a0
movq 0x68(%rsp), %rax
movq 0x60(%rsp), %rcx
movq 0x8(%rax), %rdi
movq 0x148(%rsp), %rax
movq 0x20(%rax), %rsi
addq $0x18, %rsi
movl 0x18(%rax), %edx
movq (%rdi), %rax
movq 0x60(%rax), %rax
callq *%rax
jmp 0x4eace
movq 0x148(%rsp), %rax
addq $0x28, %rax
movq %rax, 0x58(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x17030
movq 0x58(%rsp), %rdi
movq %rax, %rsi
callq 0x500f0
jmp 0x4eafb
movl $0x0, 0x110(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x17030
movl %eax, 0x10c(%rsp)
movl 0x110(%rsp), %eax
cmpl 0x10c(%rsp), %eax
jge 0x4ed6a
movslq 0x110(%rsp), %rsi
leaq 0x120(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x1a4b0
movq 0x40(%rsp), %rdi
movq %rax, 0x100(%rsp)
movslq 0x110(%rsp), %rsi
callq 0x1a4b0
movq 0x68(%rsp), %rdi
movss 0x70(%rax), %xmm0
movss %xmm0, 0xfc(%rsp)
movq 0x100(%rsp), %rsi
movq 0x148(%rsp), %rax
movq 0x20(%rax), %rax
movl 0x8c(%rax), %edx
incl %edx
xorl %ecx, %ecx
callq 0x4c940
movb %dl, 0x4f(%rsp)
movq %rax, 0x50(%rsp)
jmp 0x4eba3
movb 0x4f(%rsp), %al
movq 0x50(%rsp), %rcx
movq %rcx, 0xd8(%rsp)
movb %al, 0xe0(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movb 0xe0(%rsp), %al
movb %al, 0xf0(%rsp)
testb $0x1, 0xf0(%rsp)
je 0x4ec6a
movq 0xe8(%rsp), %rdi
callq 0x46ec0
testb $0x1, %al
jne 0x4ebfa
jmp 0x4ebfc
jmp 0x4ec41
leaq 0x11256(%rip), %rdi     # 0x5fe59
leaq 0xfd6b(%rip), %rsi      # 0x5e975
movl $0x278, %edx            # imm = 0x278
leaq 0x1118e(%rip), %rcx     # 0x5fda4
callq 0x6220
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x1a510
jmp 0x4efeb
movq 0x140(%rsp), %rdi
movq 0xe8(%rsp), %rax
movq %rax, 0xd0(%rsp)
leaq 0xd0(%rsp), %rsi
callq 0x4f130
jmp 0x4ec68
jmp 0x4ec6a
movq 0xe8(%rsp), %rax
addq $0x90, %rax
movq %rax, 0x28(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x50230
movq %rdx, 0x30(%rsp)
movl %eax, 0x3c(%rsp)
jmp 0x4ec9d
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rax
movl 0x3c(%rsp), %ecx
movl %ecx, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
leaq 0xc0(%rsp), %rsi
callq 0x50200
jmp 0x4ecc9
movq 0x148(%rsp), %rax
addq $0x28, %rax
movq %rax, 0x10(%rsp)
leaq 0xfc(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x50290
movq %rax, 0x18(%rsp)
movss %xmm0, 0x24(%rsp)
jmp 0x4ecfc
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
movss 0x24(%rsp), %xmm0
movss %xmm0, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
leaq 0xb0(%rsp), %rsi
callq 0x50260
jmp 0x4ed2c
movss 0xfc(%rsp), %xmm0
movq 0xe8(%rsp), %rax
mulss 0x8(%rax), %xmm0
movq 0x148(%rsp), %rax
addss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%rax)
movl 0x110(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x110(%rsp)
jmp 0x4eb1a
movq 0x68(%rsp), %rax
movq 0x148(%rsp), %rcx
movss 0x1c(%rcx), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x8(%rax), %rdi
callq 0x28980
movaps %xmm0, %xmm1
movss 0xc(%rsp), %xmm0
movq 0x148(%rsp), %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm1
addss %xmm1, %xmm0
movss %xmm0, 0x8(%rax)
movq 0x140(%rsp), %rdi
movq 0x148(%rsp), %rax
movq %rax, 0xa8(%rsp)
leaq 0xa8(%rsp), %rsi
callq 0x4f130
jmp 0x4edd5
testb $0x1, 0x13f(%rsp)
je 0x4efd6
movq 0x68(%rsp), %rax
cmpq $0x0, 0x98(%rax)
jne 0x4efd6
movq 0x148(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x98(%rsp)
movq 0xa0(%rsp), %rax
movl 0x8c(%rax), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
movl $0x0, 0x90(%rsp)
movq 0xa0(%rsp), %rdi
addq $0xa8, %rdi
callq 0x46f70
movl %eax, 0x8c(%rsp)
movl 0x90(%rsp), %eax
cmpl 0x8c(%rsp), %eax
jge 0x4efd4
movq 0xa0(%rsp), %rdi
addq $0xa8, %rdi
movslq 0x90(%rsp), %rsi
callq 0x46f90
movq (%rax), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rdi
callq 0x4bce0
testb $0x1, %al
jne 0x4eead
jmp 0x4efbc
movq 0x68(%rsp), %rax
movq 0x80(%rsp), %rcx
movss 0x8(%rcx), %xmm0
movss 0x1c(%rcx), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x4(%rsp)
movq 0x8(%rax), %rdi
callq 0x28980
movq 0x68(%rsp), %rdi
movaps %xmm0, %xmm1
movss 0x4(%rsp), %xmm0
divss %xmm1, %xmm0
movss %xmm0, 0x7c(%rsp)
movq 0x98(%rsp), %rsi
movq 0x80(%rsp), %rax
movl 0x18(%rax), %edx
movl 0x94(%rsp), %ecx
callq 0x4f000
movss %xmm0, 0x8(%rsp)
jmp 0x4ef16
movq 0x68(%rsp), %rax
movss 0x8(%rsp), %xmm0
movss %xmm0, 0x78(%rsp)
movss 0x7c(%rsp), %xmm0
movq 0x80(%rsp), %rcx
movl 0x10(%rcx), %ecx
cvtsi2ss %rcx, %xmm1
mulss %xmm1, %xmm0
movss 0x78(%rsp), %xmm1
addss %xmm1, %xmm0
movss %xmm0, 0x74(%rsp)
movl 0x44(%rax), %ecx
movl 0x48(%rax), %esi
imull %ecx, %esi
movq 0x80(%rsp), %rcx
movl 0x10(%rcx), %edx
addl %esi, %edx
movl %edx, 0x10(%rcx)
movq 0x80(%rsp), %rcx
movss 0x1c(%rcx), %xmm0
movss %xmm0, (%rsp)
movq 0x8(%rax), %rdi
callq 0x28980
movaps %xmm0, %xmm1
movss (%rsp), %xmm0
movss 0x74(%rsp), %xmm2
mulss %xmm2, %xmm1
movq 0x80(%rsp), %rax
movl 0x10(%rax), %eax
cvtsi2ss %rax, %xmm2
divss %xmm2, %xmm1
addss %xmm1, %xmm0
movq 0x80(%rsp), %rax
movss %xmm0, 0x8(%rax)
jmp 0x4efbe
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x4ee5c
jmp 0x4efd6
leaq 0x120(%rsp), %rdi
callq 0x1a510
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x118(%rsp), %rdi
callq 0x6520
nopl (%rax,%rax)