// File: /workspace/github_cpp_makefile_star2_O3/uclaopt[P]AsyncQVI/include/algo.h
// Function: QVI::update(int)
void update(int iter){
			
			// select (state, action) uniformly random
			if(params->style == 0){
				init_state = uniformInt(0, params->len_state-1);
				init_action = uniformInt(0, params->len_action-1);
			}
			// select (state, action) globally cyclic
			else{
				init_state = (iter/params->len_action) % params->len_state;
				init_action = iter % params->len_action;
			}
			
			S = 0.;
			for (int i = 0; i < params->max_inner_iter; i++){
				// call sample oracle
				s.SO(init_state, init_action, next_state, r);
				S += r + params->gamma * V->at(next_state);
			}
			// averaged reward
			S = S / params->max_inner_iter;
			double newQ = S - (1-params->gamma)*params->epsilon/4.;
			
			// update shared memory
			pthread_mutex_lock(&writelock);
			if (newQ > V->at(init_state)){
				V->at(init_state) = newQ;
				pi->at(init_state) = init_action;
			}
			pthread_mutex_unlock(&writelock);
		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movq 0x14e8(%rdi), %rdi
cmpl $0x0, 0x2c(%rdi)
je 0x3d1b
movl %esi, %eax
cltd
idivl 0x4(%rdi)
movl %edx, %ecx
cltd
idivl (%rdi)
movl %edx, (%rbx)
jmp 0x3d70
movl (%rdi), %eax
decl %eax
xorl %ebp, %ebp
leaq 0x18(%rsp), %r14
movl %ebp, (%r14)
movl %eax, 0x4(%r14)
leaq 0x54bc(%rip), %r15      # 0x91f0
movq %r14, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x55fe
movl %eax, (%rbx)
movq 0x14e8(%rbx), %rax
movl 0x4(%rax), %eax
decl %eax
movl %ebp, (%r14)
movl %eax, 0x4(%r14)
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %rdi, %rdx
callq 0x55fe
movl %eax, %ecx
movq 0x14e8(%rbx), %rdi
movl %ecx, 0x4(%rbx)
movq $0x0, 0x18(%rbx)
movl 0x38(%rdi), %eax
testl %eax, %eax
jle 0x3df4
leaq 0x20(%rbx), %r14
leaq 0x8(%rbx), %r15
leaq 0x10(%rbx), %r12
xorl %ebp, %ebp
movl (%rbx), %esi
movl 0x4(%rbx), %edx
movq %r14, %rdi
movq %r15, %rcx
movq %r12, %r8
callq 0x3c72
movq 0x14d8(%rbx), %rcx
movslq 0x8(%rbx), %rsi
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x3ead
movq 0x14e8(%rbx), %rdi
movsd 0x18(%rdi), %xmm0
movsd (%rax,%rsi,8), %xmm2
mulsd %xmm0, %xmm2
addsd 0x10(%rbx), %xmm2
addsd 0x18(%rbx), %xmm2
movsd %xmm2, 0x18(%rbx)
incl %ebp
movl 0x38(%rdi), %eax
cmpl %eax, %ebp
jl 0x3d90
jmp 0x3dfd
movsd 0x18(%rdi), %xmm0
xorpd %xmm2, %xmm2
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm2
movsd %xmm2, 0x10(%rsp)
movsd %xmm2, 0x18(%rbx)
movsd 0x2200(%rip), %xmm1     # 0x6018
subsd %xmm0, %xmm1
mulsd 0x60(%rdi), %xmm1
movsd %xmm1, 0x8(%rsp)
leaq 0x676a(%rip), %rdi      # 0xa598
callq 0x2280
movq 0x14d8(%rbx), %rcx
movslq (%rbx), %rsi
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x3ead
movsd 0x8(%rsp), %xmm1
mulsd 0x21c2(%rip), %xmm1     # 0x6020
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
ucomisd (%rax,%rsi,8), %xmm0
jbe 0x3e94
movsd %xmm0, (%rax,%rsi,8)
movq 0x14e0(%rbx), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0x3ead
movl 0x4(%rbx), %ecx
movl %ecx, (%rax,%rsi,4)
leaq 0x66fd(%rip), %rdi      # 0xa598
callq 0x2130
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x23b2(%rip), %rdi      # 0x6266
xorl %eax, %eax
callq 0x22a0
nop