// File: /workspace/github_cpp_makefile_star2_O3/bonetblai[P]mdp-engine/ctp3/../engine/policy.h
// Function: std::pair<float, float> Online::Evaluation::evaluation_with_stdev<state_t>(Online::Policy::policy_t<state_t> const&, state_t const&, unsigned int, unsigned int, bool)
inline std::pair<float, float>
  evaluation_with_stdev(const Policy::policy_t<T> &policy,
                        const T &s,
                        unsigned number_trials,
                        unsigned max_depth,
                        bool verbose = false) {
    float sum = 0;
    std::vector<float> values;
    values.reserve(number_trials);
    if( verbose ) std::cout << "#trials=" << number_trials << ":";
    for( unsigned trial = 0; trial < number_trials; ++trial ) {
        if( verbose ) std::cout << " " << trial << std::flush;
        values.push_back(evaluation_trial(policy, s, max_depth));
        sum += values.back();
        if( verbose ) {
            std::cout << "(" << std::setprecision(1) << sum/(1+trial) << ")"
                      << std::flush;
        }
    }
    if( verbose ) std::cout << std::endl;

    // compute average
    float avg = 0;
    for( unsigned i = 0; i < number_trials; ++i ) {
        avg += values[i];
    }
    avg /= number_trials;

    // compute stdev
    float stdev = 0;
    for( unsigned i = 0; i < number_trials; ++i ) {
        stdev += (avg - values[i]) * (avg - values[i]);
    }
    stdev = sqrt(stdev) / (number_trials - 1);
    return std::make_pair(avg, stdev);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, %ebp
movl %ecx, 0x8(%rsp)
movl %edx, %ebx
movq %rsi, 0x40(%rsp)
movq %rdi, %r13
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl %edx, %r14d
movq %r14, %rsi
callq 0x2a0e2
testb %bpl, %bpl
je 0x29ed9
movq 0x13133(%rip), %rdi     # 0x3cfd8
leaq 0x243e(%rip), %rsi      # 0x2c2ea
movl $0x8, %edx
callq 0x52e0
movq 0x1311b(%rip), %rdi     # 0x3cfd8
movq %r14, %rsi
callq 0x51d0
leaq 0x1f91(%rip), %rsi      # 0x2be5d
movl $0x1, %edx
movq %rax, %rdi
callq 0x52e0
movq %rbx, 0x38(%rsp)
testl %ebx, %ebx
je 0x29ff7
xorps %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
xorl %ebx, %ebx
movq 0x130e0(%rip), %r15     # 0x3cfd8
testb %bpl, %bpl
je 0x29f24
movl $0x1, %edx
movq %r15, %rdi
leaq 0x2055(%rip), %rsi      # 0x2bf61
callq 0x52e0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x51d0
movq %rax, %rdi
callq 0x51e0
movq %r13, %rdi
movq 0x40(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x1dacf
movss %xmm0, 0xc(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x29f56
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x29f6a
leaq 0x20(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x2a174
movq 0x28(%rsp), %rsi
movss 0x10(%rsp), %xmm0
addss -0x4(%rsi), %xmm0
movss %xmm0, 0x10(%rsp)
testb %bpl, %bpl
je 0x29feb
movl $0x1, %edx
movq %r15, %rdi
leaq 0x20e0(%rip), %rsi      # 0x2c06f
callq 0x52e0
incq %rbx
movl %ebx, %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
movq (%r15), %rax
movq -0x18(%rax), %rax
movq $0x1, 0x8(%r15,%rax)
movss 0x10(%rsp), %xmm1
divss %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movq %r15, %rdi
callq 0x53b0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1491(%rip), %rsi      # 0x2b46d
callq 0x52e0
movq %r12, %rdi
callq 0x51e0
jmp 0x29fee
incq %rbx
cmpq %r14, %rbx
jne 0x29ef8
testb %bpl, %bpl
movq 0x38(%rsp), %rbx
je 0x2a030
movq 0x12fd0(%rip), %rdi     # 0x3cfd8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x5270
movsbl %al, %esi
movq 0x12fb5(%rip), %rdi     # 0x3cfd8
callq 0x5040
movq %rax, %rdi
callq 0x51e0
movq 0x20(%rsp), %rdi
testl %ebx, %ebx
je 0x2a07a
xorps %xmm0, %xmm0
xorl %eax, %eax
addss (%rdi,%rax,4), %xmm0
incq %rax
cmpq %rax, %r14
jne 0x2a03e
xorps %xmm1, %xmm1
cvtsi2ss %r14, %xmm1
divss %xmm1, %xmm0
xorps %xmm3, %xmm3
testl %ebx, %ebx
je 0x2a085
xorl %eax, %eax
movaps %xmm0, %xmm1
subss (%rdi,%rax,4), %xmm1
mulss %xmm1, %xmm1
addss %xmm1, %xmm3
incq %rax
cmpq %rax, %r14
jne 0x2a060
jmp 0x2a085
xorps %xmm3, %xmm3
xorps %xmm0, %xmm0
testq %rdi, %rdi
je 0x2a0a0
movss %xmm3, 0x8(%rsp)
movaps %xmm0, 0x10(%rsp)
callq 0x5260
movss 0x8(%rsp), %xmm3
movaps 0x10(%rsp), %xmm0
decl %ebx
cvtsi2ss %rbx, %xmm2
xorps %xmm1, %xmm1
sqrtss %xmm3, %xmm1
divss %xmm2, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a0c8
jmp 0x2a0c8
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2a0da
callq 0x5260
movq %rbx, %rdi
callq 0x5410