// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movl %r8d, %ebp
movl %ecx, 0x8(%rsp)
movl %edx, %ebx
movq %rsi, 0x50(%rsp)
movq %rdi, %r13
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl %edx, %r14d
movq %r14, %rsi
callq 0x2beb0
testb %bpl, %bpl
je 0x2bca5
movq 0x13367(%rip), %rdi     # 0x3efd8
leaq 0x26b5(%rip), %rsi      # 0x2e32d
movl $0x8, %edx
callq 0x62e0
movq 0x1334f(%rip), %rdi     # 0x3efd8
movq %r14, %rsi
callq 0x61d0
leaq 0x21ca(%rip), %rsi      # 0x2de62
movl $0x1, %edx
movq %rax, %rdi
callq 0x62e0
movq %rbx, 0x48(%rsp)
testl %ebx, %ebx
je 0x2bdbf
xorps %xmm0, %xmm0
movss %xmm0, 0x30(%rsp)
xorl %ebx, %ebx
movq 0x13314(%rip), %r15     # 0x3efd8
testb %bpl, %bpl
je 0x2bcf0
movl $0x1, %edx
movq %r15, %rdi
leaq 0x228e(%rip), %rsi      # 0x2df66
callq 0x62e0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x61d0
movq %rax, %rdi
callq 0x61e0
movq %r13, %rdi
movq 0x50(%rsp), %rsi
movl 0x8(%rsp), %edx
callq 0x1f63d
movss %xmm0, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2bd22
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x2bd31
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x2bf3e
movq 0x18(%rsp), %rax
movss 0x30(%rsp), %xmm0
addss -0x4(%rax), %xmm0
movss %xmm0, 0x30(%rsp)
testb %bpl, %bpl
je 0x2bdb3
movl $0x1, %edx
movq %r15, %rdi
leaq 0x2357(%rip), %rsi      # 0x2e0b2
callq 0x62e0
leal 0x1(%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
movq (%r15), %rax
movq -0x18(%rax), %rax
movq $0x1, 0x8(%r15,%rax)
movss 0x30(%rsp), %xmm1
divss %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movq %r15, %rdi
callq 0x63b0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x16b7(%rip), %rsi      # 0x2d45d
callq 0x62e0
movq %r12, %rdi
callq 0x61e0
incq %rbx
cmpq %rbx, %r14
jne 0x2bcc4
testb %bpl, %bpl
movq 0x48(%rsp), %rbx
je 0x2bdf8
movq 0x13208(%rip), %rdi     # 0x3efd8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x6270
movsbl %al, %esi
movq 0x131ed(%rip), %rdi     # 0x3efd8
callq 0x6040
movq %rax, %rdi
callq 0x61e0
xorps %xmm3, %xmm3
xorps %xmm0, %xmm0
testl %ebx, %ebx
je 0x2be16
movq 0x10(%rsp), %rax
xorl %ecx, %ecx
addss (%rax,%rcx,4), %xmm0
incq %rcx
cmpq %rcx, %r14
jne 0x2be09
xorps %xmm1, %xmm1
cvtsi2ss %r14, %xmm1
divss %xmm1, %xmm0
testl %ebx, %ebx
je 0x2be48
movq 0x10(%rsp), %rax
xorps %xmm3, %xmm3
xorl %ecx, %ecx
movaps %xmm0, %xmm1
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm1
addss %xmm1, %xmm3
incq %rcx
cmpq %rcx, %r14
jne 0x2be30
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2be6d
movaps %xmm0, 0x30(%rsp)
movss %xmm3, 0x8(%rsp)
callq 0x6260
movss 0x8(%rsp), %xmm3
movaps 0x30(%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 $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2be95
jmp 0x2be95
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2bea7
callq 0x6260
movq %rbx, %rdi
callq 0x6410
nop