// File: /workspace/github_cpp_makefile_star2_O3/bonetblai[P]mdp-engine/ctp3/../engine/uct.h
// Function: Online::Policy::UCT::uct_t<state_t>::select_action(state_t const&, Online::Policy::UCT::data_t const&, int, bool, bool) const
Problem::action_t select_action(const T &state,
                                    const data_t &data,
                                    int depth,
                                    bool add_bonus,
                                    bool random_ties) const {
        float log_ns = logf(data.counts_[0]);
        std::vector<Problem::action_t> best_actions;
        int nactions = problem_.number_actions(state);
        float best_value = std::numeric_limits<float>::max();

        best_actions.reserve(random_ties ? nactions : 1);
        for( Problem::action_t a = 0; a < nactions; ++a ) {
            if( problem_.applicable(state, a) ) {
                // if this action has never been taken in this node, select it
                if( data.counts_[1+a] == 0 ) {
                    return a;
                }

                // compute score of action adding bonus (if applicable)
                assert(data.counts_[0] > 0);
                float par = parameter_ == 0 ? -data.values_[1+a] : parameter_;
                float bonus = add_bonus ? par * sqrtf(2 * log_ns / data.counts_[1+a]) : 0;
                float value = data.values_[1+a] + bonus;

                // update best action so far
                if( value <= best_value ) {
                    if( value < best_value ) {
                        best_value = value;
                        best_actions.clear();
                    }
                    if( random_ties || best_actions.empty() )
                        best_actions.push_back(a);
                }
            }
        }
        assert(!best_actions.empty());
        return best_actions[Random::random(best_actions.size())];
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %ebx
movl %r8d, 0x30(%rsp)
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq 0x18(%rdx), %rax
cvtsi2ssl (%rax), %xmm0
callq 0x5450
movss %xmm0, 0xc(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x8(%r12), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x10(%rax)
movl %eax, %r13d
cltq
testb %bl, %bl
movl $0x1, %esi
cmovneq %rax, %rsi
leaq 0x10(%rsp), %rdi
callq 0xbe32
movl $0x0, 0x8(%rsp)
testl %r13d, %r13d
jle 0x1f8fd
movss 0xc(%rsp), %xmm0
addss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
xorl %edx, %edx
movss 0xb828(%rip), %xmm0     # 0x2b014
movss %xmm0, 0x34(%rsp)
movq 0x8(%r12), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x30(%rax)
testb %al, %al
movss 0x34(%rsp), %xmm3
je 0x1f883
movl 0x8(%rsp), %ebp
movslq %ebp, %rax
movq 0x18(%r14), %rdx
movl 0x4(%rdx,%rax,4), %ecx
testl %ecx, %ecx
je 0x1f947
cmpl $0x0, (%rdx)
jle 0x1f953
movss 0x38(%r12), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jne 0x1f849
movq (%r14), %rdx
movss 0x4(%rdx,%rax,4), %xmm0
xorps 0xb807(%rip), %xmm0     # 0x2b050
cmpb $0x0, 0x30(%rsp)
je 0x1f86f
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
movss 0xc(%rsp), %xmm2
divss %xmm1, %xmm2
xorps %xmm1, %xmm1
sqrtss %xmm2, %xmm1
mulss %xmm1, %xmm0
movaps %xmm0, %xmm1
movq (%r14), %rcx
addss 0x4(%rcx,%rax,4), %xmm1
movss %xmm1, 0x4(%rsp)
ucomiss %xmm3, %xmm1
jbe 0x1f888
movaps %xmm3, %xmm0
jmp 0x1f8d1
movq 0x18(%rsp), %rax
jae 0x1f8a0
movq 0x10(%rsp), %rsi
cmpq %rsi, %rax
je 0x1f8ab
movq %rsi, 0x18(%rsp)
jmp 0x1f8ae
movq %rax, %rsi
movss %xmm3, 0x4(%rsp)
jmp 0x1f8ae
movq %rax, %rsi
testb %bl, %bl
jne 0x1f8b9
cmpq %rsi, 0x10(%rsp)
jne 0x1f8cb
cmpq 0x20(%rsp), %rsi
je 0x1f8e6
movl %ebp, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
movss 0x4(%rsp), %xmm0
movl 0x8(%rsp), %edx
incl %edx
movl %edx, 0x8(%rsp)
cmpl %r13d, %edx
jl 0x1f7ec
jmp 0x1f8fd
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xa316
movss 0x4(%rsp), %xmm0
jmp 0x1f8d1
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rbx
cmpq %rbx, %rdi
je 0x1f972
subq %rdi, %rbx
shrq $0x2, %rbx
cmpl $0x1, %ebx
je 0x1f92c
testl %ebx, %ebx
je 0x1f991
callq 0x5200
xorl %edx, %edx
divl %ebx
movq 0x10(%rsp), %rdi
jmp 0x1f92e
xorl %edx, %edx
movl (%rdi,%rdx,4), %ebp
callq 0x5260
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
jne 0x1f931
jmp 0x1f936
leaq 0xcd54(%rip), %rdi      # 0x2c6ae
leaq 0xcc11(%rip), %rsi      # 0x2c572
leaq 0xcd5a(%rip), %rcx      # 0x2c6c2
movl $0x12c, %edx            # imm = 0x12C
callq 0x51c0
leaq 0xcdce(%rip), %rdi      # 0x2c747
leaq 0xcbf2(%rip), %rsi      # 0x2c572
leaq 0xcd3b(%rip), %rcx      # 0x2c6c2
movl $0x13c, %edx            # imm = 0x13C
callq 0x51c0
leaq 0xbc83(%rip), %rdi      # 0x2b61b
leaq 0xbc84(%rip), %rsi      # 0x2b623
leaq 0xbc90(%rip), %rcx      # 0x2b636
movl $0x3a, %edx
callq 0x51c0
jmp 0x1f9b6
jmp 0x1f9b6
jmp 0x1f9b6
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1f9c8
callq 0x5260
movq %rbx, %rdi
callq 0x5410