// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0xa4d8
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x28(%rax)
testb %al, %al
je 0x16465
movq 0x8(%rbx), %rax
movss 0xc(%rax), %xmm0
jmp 0x16597
movl %ebp, %r12d
incq %r12
movss 0x9b99(%rip), %xmm0     # 0x2000c
movss %xmm0, 0xc(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
leaq 0x18(%rsp), %r14
leaq 0x88(%rsp), %r15
decq %r12
je 0x16584
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x20(%rax)
testb %al, %al
jne 0x16584
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x20(%rax)
movl %eax, %ebp
movq 0x8(%rbx), %rdi
cmpl $-0x1, %eax
je 0x1658c
movq (%rdi), %rax
movq %r14, %rsi
movl %ebp, %edx
callq *0x30(%rax)
testb %al, %al
je 0x165bd
movq 0x8(%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
movl %ebp, %ecx
callq 0xb318
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movl %ebp, %edx
callq *0x48(%rax)
movss %xmm0, 0x14(%rsp)
movq 0x8(%rbx), %rax
movss 0x8(%rax), %xmm0
mulss 0xc(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa8c8
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x28(%rax)
movl %eax, %ebp
movss 0x14(%rsp), %xmm1
mulss 0xc(%rsp), %xmm1
movss 0x4(%rsp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x4(%rsp)
testb %al, %al
je 0x16565
movq 0x8(%rbx), %rax
movss 0xc(%rax), %xmm0
addss 0x4(%rsp), %xmm0
movss %xmm0, 0x8(%rsp)
movq %r15, %rdi
callq 0x8e90
movss 0x10(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
testb %bpl, %bpl
je 0x1648f
jmp 0x1659d
movss 0x4(%rsp), %xmm0
jmp 0x16597
movss 0x4(%rsp), %xmm0
addss 0xc(%rdi), %xmm0
movss %xmm0, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x8e90
movss 0x8(%rsp), %xmm0
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xacef(%rip), %rdi      # 0x212b3
leaq 0xad13(%rip), %rsi      # 0x212de
leaq 0xad1f(%rip), %rcx      # 0x212f1
pushq $0x75
popq %rdx
callq 0x51b0
jmp 0x165e0
jmp 0x165e0
jmp 0x165e0
movq %rax, %rbx
jmp 0x165f5
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x8e90
leaq 0x18(%rsp), %rdi
callq 0x8e90
movq %rbx, %rdi
callq 0x5410
nop