// File: /workspace/github_cpp_makefile_star2_O3/uclaopt[P]AsyncQVI/include/algo.h
// Function: Qlearning::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 if(params->style == 1){
				init_state = (iter/params->len_action) % params->len_state;
				init_action = iter % params->len_action;
			}
			// select (state, action) following a Markovian trajectory with some exploration
			else{
				init_state = next_state;
				init_action = (*pi)[next_state];
				if(uniformDouble(0.,1.) < params->explore)
					init_action = uniformInt(0, params->len_action-1);
			}
			
			// call sample oracle
			s.SO(init_state, init_action, next_state, r);
			
			// update global variables with mutex
			pthread_mutex_lock(&writelock);
			
			// learning rate of Q-learning
			//params->alpha = 1./pow(iter,0.51);
			(*Q)[init_state][init_action] = (1-params->alpha) * (*Q)[init_state][init_action]
											+ params->alpha * (r + params->gamma*(*V)[next_state]);
			if((*Q)[init_state][init_action] > (*V)[init_state]){
				(*V)[init_state] = (*Q)[init_state][init_action];
				(*pi)[init_state] = init_action;
			}
			pthread_mutex_unlock(&writelock);			
		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x14e8(%rdi), %rcx
movl 0x2c(%rcx), %eax
cmpl $0x1, %eax
je 0x3f1b
testl %eax, %eax
jne 0x3f2f
movl (%rcx), %eax
decl %eax
xorl %ebp, %ebp
movq %rsp, %r14
movl %ebp, (%r14)
movl %eax, 0x4(%r14)
leaq 0x5300(%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)
movq %rsp, %rdi
movq %r15, %rsi
jmp 0x3f7b
movl %esi, %eax
cltd
idivl 0x4(%rcx)
movl %edx, %r9d
cltd
idivl (%rcx)
movl %edx, (%rbx)
movl %r9d, 0x4(%rbx)
jmp 0x3f8f
movslq 0x8(%rbx), %rax
movl %eax, (%rbx)
movq 0x14e0(%rbx), %rcx
movq (%rcx), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x4(%rbx)
leaq 0x52a4(%rip), %rdi      # 0x91f0
callq 0x585c
movq 0x14e8(%rbx), %rax
movsd 0x48(%rax), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x3f8b
movl 0x4(%rax), %eax
decl %eax
movq %rsp, %rdi
movl $0x0, (%rdi)
movl %eax, 0x4(%rdi)
leaq 0x5275(%rip), %rsi      # 0x91f0
movq %rdi, %rdx
callq 0x55fe
movl %eax, %r9d
movl %eax, 0x4(%rbx)
jmp 0x3f8f
movl 0x4(%rbx), %r9d
leaq 0x18(%rbx), %rdi
movl (%rbx), %esi
leaq 0x8(%rbx), %rcx
leaq 0x10(%rbx), %r8
movl %r9d, %edx
callq 0x3c72
leaq 0x65ec(%rip), %rdi      # 0xa598
callq 0x2280
movq 0x14e8(%rbx), %rax
movsd 0x18(%rax), %xmm1
movsd 0x50(%rax), %xmm2
movsd 0x204e(%rip), %xmm0     # 0x6018
subsd %xmm2, %xmm0
movslq (%rbx), %rax
movq 0x14d0(%rbx), %rcx
movq 0x14d8(%rbx), %rdx
movq (%rcx), %rsi
leaq (%rax,%rax,2), %rdi
movslq 0x4(%rbx), %rcx
movq (%rsi,%rdi,8), %rsi
movslq 0x8(%rbx), %rdi
movq (%rdx), %rdx
mulsd (%rdx,%rdi,8), %xmm1
addsd 0x10(%rbx), %xmm1
mulsd %xmm2, %xmm1
mulsd (%rsi,%rcx,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rsi,%rcx,8)
ucomisd (%rdx,%rax,8), %xmm0
jbe 0x402a
movsd %xmm0, (%rdx,%rax,8)
movq 0x14e0(%rbx), %rdx
movq (%rdx), %rdx
movl %ecx, (%rdx,%rax,4)
leaq 0x6567(%rip), %rdi      # 0xa598
callq 0x2130
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop