// File: /workspace/github_cpp_makefile_star2_O1/uclaopt[P]AsyncQVI/include/oracle.h
// Function: test_sailing(Sailing&, std::vector<int, std::allocator<int>>*, Params*)
void test_sailing(Sailing& s, std::vector<int>* pi, Params* params){
	
	double start_time = get_wall_time();
	s.setValues(params);
	// total discounted reward
	double total_reward = 0.;
	// how many times has the goal state been reached.
	int flag = 0;
	int isflag = 0;
	// run text_max_episode episodes
	for (int episode = 0; episode < params->test_max_episode; episode++){
		// start from an arbitrary state
		int i = uniformInt(0,params->len_state-1);
		int j = 0;
		double r = 0;
		isflag = 0;
		for (int step = 0; step < params->test_max_step; step++){
			s.SO(i,(*pi)[i],j,r);
			total_reward += pow(params->gamma,step)*r;
			if(r == 1 && !isflag){
				flag += 1;
				isflag = 1;
			}
			i = j;
		}
	}
	params->test_time += get_wall_time() - start_time;
	// average total reward
	total_reward /= params->test_max_episode;
	cout<<get_wall_time()-params->test_time-params->time<<' '<<total_reward<<' '<<flag<<endl;
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
callq 0x2e6c
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3bd0
cmpl $0x0, 0x20(%r14)
jle 0x3000
movq %r15, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
xorl %ebx, %ebx
movq 0x30(%rsp), %r12
movq 0x28(%rsp), %r15
movl %eax, 0x1c(%rsp)
movl (%r14), %eax
decl %eax
xorl %ebp, %ebp
movl %ebp, 0x10(%rsp)
movl %eax, 0x14(%rsp)
leaq 0x62bb(%rip), %rsi      # 0x91f0
movq %rdi, %rdx
callq 0x5552
movl %ebp, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
cmpl %ebp, 0x24(%r14)
jle 0x2fdd
xorl %r13d, %r13d
xorl %ebp, %ebp
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
movslq %eax, %rsi
movq (%r12), %rax
movl (%rax,%rsi,4), %edx
movq %r15, %rdi
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r8
callq 0x3cb2
movsd 0x18(%r14), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
callq 0x2350
movsd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm0
ucomisd 0x3072(%rip), %xmm1     # 0x6018
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
setnp %al
sete %cl
andb %al, %cl
testl %ebp, %ebp
sete %al
andb %cl, %al
movzbl %al, %eax
addl %eax, %ebx
testb %al, %al
movl $0x1, %eax
cmovnel %eax, %ebp
movl 0x18(%rsp), %eax
incl %r13d
cmpl 0x24(%r14), %r13d
jl 0x2f5f
jmp 0x2fe3
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
movl 0x1c(%rsp), %eax
incl %eax
cmpl 0x20(%r14), %eax
leaq 0x10(%rsp), %rdi
jl 0x2f1b
jmp 0x300c
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x2e6c
subsd 0x20(%rsp), %xmm0
addsd 0x80(%r14), %xmm0
movsd %xmm0, 0x80(%r14)
xorps %xmm0, %xmm0
cvtsi2sdl 0x20(%r14), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
callq 0x2e6c
subsd 0x80(%r14), %xmm0
subsd 0x78(%r14), %xmm0
movq 0x5f7b(%rip), %rdi      # 0x8fd8
callq 0x22d0
movb $0x20, %bpl
leaq 0x10(%rsp), %r14
movb %bpl, (%r14)
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2220
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x22d0
movb %bpl, (%r14)
leaq 0x10(%rsp), %rsi
movl $0x1, %edx
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
movl %ebx, %esi
callq 0x2340
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq