// File: bonetblai[P]mdp-engine/ctp3/../engine/policy.h
// Function: float Online::Evaluation::evaluation_trial<state_t>(Online::Policy::policy_t<state_t> const&, state_t const&, unsigned int)
inline float evaluation_trial(const Policy::policy_t<T> &policy, const T &s, unsigned max_depth) {
    T state = s;
    size_t steps = 0;
    float cost = 0;
    float discount = 1;
    if( policy.problem().dead_end(state) ) return policy.problem().dead_end_value();
    while( (steps < max_depth) && !policy.problem().terminal(state) ) {
        //std::cout << "evaluation_trial: " << state << std::flush;
        Problem::action_t action = policy(state);
        //std::cout << ", a=" << action << std::endl;
        if( action == Problem::noop ) {
            //std::cout << "no applicable action" << std::endl;
            return cost + policy.problem().dead_end_value();
        }
        assert(policy.problem().applicable(state, action));
        std::pair<T, bool> p = policy.problem().sample(state, action);
        cost += discount * policy.problem().cost(state, action);
        discount *= policy.problem().discount();
        state = p.first;
        ++steps;
        if( policy.problem().dead_end(state) ) {
            return cost + policy.problem().dead_end_value();
        }
    }
    return cost;
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x168(%rsp)
movq %rsi, 0x160(%rsp)
movl %edx, 0x15c(%rsp)
movq 0x160(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x16650
movq $0x0, 0xe0(%rsp)
movl $0x0, 0xdc(%rsp)
movl $0x3f800000, 0xd8(%rsp) # imm = 0x3F800000
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq 0x38(%rsp), %rsi
movq %rax, %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movb %al, 0x47(%rsp)
jmp 0x3c83e
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x3c848
jmp 0x3c89d
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq %rax, %rdi
callq 0x3cbe0
movss %xmm0, 0x34(%rsp)
jmp 0x3c865
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x174(%rsp)
movl $0x1, 0xc8(%rsp)
jmp 0x3cba7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0x3cbc5
jmp 0x3c89f
movq 0xe0(%rsp), %rcx
movl 0x15c(%rsp), %eax
movl %eax, %edx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x33(%rsp)
jae 0x3c8ec
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq %rax, %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
leaq 0xe8(%rsp), %rsi
callq *%rax
movb %al, 0x32(%rsp)
jmp 0x3c8e2
movb 0x32(%rsp), %al
xorb $-0x1, %al
movb %al, 0x33(%rsp)
movb 0x33(%rsp), %al
testb $0x1, %al
jne 0x3c8f9
jmp 0x3cb8a
movq 0x168(%rsp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
leaq 0xe8(%rsp), %rsi
callq *%rax
movl %eax, 0x2c(%rsp)
jmp 0x3c918
movl 0x2c(%rsp), %eax
movl %eax, 0xc4(%rsp)
cmpl $-0x1, 0xc4(%rsp)
jne 0x3c982
movss 0xdc(%rsp), %xmm0
movss %xmm0, 0x24(%rsp)
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq %rax, %rdi
callq 0x3cbe0
movss %xmm0, 0x28(%rsp)
jmp 0x3c959
movss 0x28(%rsp), %xmm1
movss 0x24(%rsp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x174(%rsp)
movl $0x1, 0xc8(%rsp)
jmp 0x3cba7
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq %rax, %rdi
movl 0xc4(%rsp), %edx
movq (%rdi), %rax
movq 0x30(%rax), %rax
leaq 0xe8(%rsp), %rsi
callq *%rax
movb %al, 0x23(%rsp)
jmp 0x3c9b0
movb 0x23(%rsp), %al
testb $0x1, %al
jne 0x3c9ba
jmp 0x3c9bc
jmp 0x3c9db
leaq 0x21903(%rip), %rdi     # 0x5e2c6
leaq 0x21927(%rip), %rsi     # 0x5e2f1
movl $0x75, %edx
leaq 0x2192e(%rip), %rcx     # 0x5e304
callq 0x6220
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq %rax, %rsi
movl 0xc4(%rsp), %ecx
leaq 0x48(%rsp), %rdi
leaq 0xe8(%rsp), %rdx
callq 0x19da0
jmp 0x3ca06
movss 0xd8(%rsp), %xmm0
movss %xmm0, 0x18(%rsp)
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq %rax, %rdi
movl 0xc4(%rsp), %edx
movq (%rdi), %rax
movq 0x48(%rax), %rax
leaq 0xe8(%rsp), %rsi
callq *%rax
movss %xmm0, 0x1c(%rsp)
jmp 0x3ca45
movss 0x1c(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
mulss %xmm0, %xmm1
movss 0xdc(%rsp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xdc(%rsp)
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq %rax, %rdi
callq 0x28980
movaps %xmm0, %xmm1
movss 0xd8(%rsp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, 0xd8(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x17c20
jmp 0x3caad
movq 0xe0(%rsp), %rax
incq %rax
movq %rax, 0xe0(%rsp)
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq %rax, %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
leaq 0xe8(%rsp), %rsi
callq *%rax
movb %al, 0x17(%rsp)
jmp 0x3cae7
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x3caf1
jmp 0x3cb63
movss 0xdc(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x168(%rsp), %rdi
callq 0x1ac80
movq %rax, %rdi
callq 0x3cbe0
movss %xmm0, 0x10(%rsp)
jmp 0x3cb1d
movss 0x10(%rsp), %xmm1
movss 0xc(%rsp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x174(%rsp)
movl $0x1, 0xc8(%rsp)
jmp 0x3cb6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x19f70
jmp 0x3cbc5
movl $0x0, 0xc8(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x19f70
movl 0xc8(%rsp), %eax
testl %eax, %eax
jne 0x3cba7
jmp 0x3cb85
jmp 0x3c89f
movss 0xdc(%rsp), %xmm0
movss %xmm0, 0x174(%rsp)
movl $0x1, 0xc8(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x115b0
movss 0x174(%rsp), %xmm0
addq $0x178, %rsp            # imm = 0x178
retq
leaq 0xe8(%rsp), %rdi
callq 0x115b0
movq 0xd0(%rsp), %rdi
callq 0x6520
nop