// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %edx, %ebp
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r14
movups %xmm0, 0x34(%r14)
movups %xmm0, 0x24(%r14)
movups %xmm0, 0x14(%r14)
movups %xmm0, 0x4(%r14)
xorl %eax, %eax
movq %rax, 0x44(%r14)
movb $0x1, 0x5c(%r14)
movq %rax, 0x60(%r14)
movq %r14, %rdi
callq 0xd546
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x28(%rax)
testb %al, %al
je 0x1f6a5
movq 0x8(%rbx), %rax
movss 0xc(%rax), %xmm0
jmp 0x1f800
movl %ebp, %r12d
movss 0xd958(%rip), %xmm0     # 0x2d008
movss %xmm0, 0x18(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
xorl %r13d, %r13d
leaq 0x20(%rsp), %r14
leaq 0x90(%rsp), %r15
cmpq %r12, %r13
jae 0x1f7fa
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x20(%rax)
testb %al, %al
jne 0x1f7fa
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x20(%rax)
movl %eax, %ebp
movq 0x8(%rbx), %rdi
cmpl $-0x1, %eax
je 0x1f7dc
movq (%rdi), %rax
movq %r14, %rsi
movl %ebp, %edx
callq *0x30(%rax)
testb %al, %al
je 0x1f837
movq 0x8(%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
movl %ebp, %ecx
callq 0xe0cc
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 0x18(%rsp), %xmm0
movss %xmm0, 0x1c(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xd546
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x28(%rax)
movl %eax, %ebp
movss 0x14(%rsp), %xmm1
mulss 0x18(%rsp), %xmm1
addss 0x10(%rsp), %xmm1
testb %al, %al
je 0x1f799
movq 0x8(%rbx), %rax
movss 0xc(%rax), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
cmpb $0x0, 0xec(%rsp)
jne 0x1f7c1
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f7c1
movss %xmm1, 0x14(%rsp)
callq 0x6340
movss 0x14(%rsp), %xmm1
incq %r13
xorb $0x1, %bpl
movss %xmm1, 0x10(%rsp)
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0x18(%rsp)
jmp 0x1f7ef
movss 0xc(%rdi), %xmm0
addss 0x10(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
xorl %ebp, %ebp
testb %bpl, %bpl
jne 0x1f6cf
jmp 0x1f806
movss 0x10(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
cmpb $0x0, 0x7c(%rsp)
jne 0x1f81f
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1f81f
callq 0x6340
movss 0xc(%rsp), %xmm0
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xeaf8(%rip), %rdi      # 0x2e336
leaq 0xeb1c(%rip), %rsi      # 0x2e361
leaq 0xeb28(%rip), %rcx      # 0x2e374
movl $0x75, %edx
callq 0x61c0
jmp 0x1f85c
jmp 0x1f85c
jmp 0x1f85c
movq %rax, %rbx
jmp 0x1f880
movq %rax, %rbx
cmpb $0x0, 0xec(%rsp)
jne 0x1f880
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f880
callq 0x6340
cmpb $0x0, 0x7c(%rsp)
jne 0x1f899
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1f899
callq 0x6340
movq %rbx, %rdi
callq 0x6410
nop