// File: /workspace/github_cpp_makefile_star2_O1/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 0x3d5b
movl %esi, %eax
cltd
idivl 0x4(%rdi)
movl %edx, %ecx
cltd
idivl (%rdi)
movl %edx, (%rbx)
jmp 0x3da9
movl (%rdi), %eax
decl %eax
xorl %ebp, %ebp
leaq 0x18(%rsp), %r14
movl %ebp, (%r14)
movl %eax, 0x4(%r14)
leaq 0x547c(%rip), %r15      # 0x91f0
movq %r14, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5552
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 0x5552
movl %eax, %ecx
movl %ecx, 0x4(%rbx)
movq $0x0, 0x18(%rbx)
movq 0x14e8(%rbx), %rax
movl 0x38(%rax), %ecx
testl %ecx, %ecx
jle 0x3e2e
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 0x3cb2
movq 0x14d8(%rbx), %rax
movslq 0x8(%rbx), %rsi
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x3ee7
movq 0x14e8(%rbx), %rax
movsd 0x18(%rax), %xmm0
mulsd (%rcx,%rsi,8), %xmm0
addsd 0x10(%rbx), %xmm0
addsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x18(%rbx)
incl %ebp
movl 0x38(%rax), %ecx
cmpl %ecx, %ebp
jl 0x3dd0
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd 0x18(%rbx), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd %xmm1, 0x18(%rbx)
movsd 0x21c7(%rip), %xmm0     # 0x6018
subsd 0x18(%rax), %xmm0
mulsd 0x60(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x6730(%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 0x3ee7
movsd 0x8(%rsp), %xmm1
mulsd 0x2188(%rip), %xmm1     # 0x6020
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
ucomisd (%rax,%rsi,8), %xmm0
jbe 0x3ece
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 0x3ee7
movl 0x4(%rbx), %ecx
movl %ecx, (%rax,%rsi,4)
leaq 0x66c3(%rip), %rdi      # 0xa598
callq 0x2130
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22f8(%rip), %rdi      # 0x61e6
xorl %eax, %eax
callq 0x22a0
nop