// File: /workspace/github_cpp_makefile_star2_O1/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), %rdi
movl 0x2c(%rdi), %eax
cmpl $0x1, %eax
je 0x3f55
testl %eax, %eax
jne 0x3f67
movl (%rdi), %eax
decl %eax
xorl %ebp, %ebp
movq %rsp, %r14
movl %ebp, (%r14)
movl %eax, 0x4(%r14)
leaq 0x52c6(%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)
movq %rsp, %rdi
movq %r15, %rsi
jmp 0x3fb3
movl %esi, %eax
cltd
idivl 0x4(%rdi)
movl %edx, %ecx
cltd
idivl (%rdi)
movl %edx, (%rbx)
movl %ecx, 0x4(%rbx)
jmp 0x3fbe
movslq 0x8(%rbx), %rax
movl %eax, (%rbx)
movq 0x14e0(%rbx), %rcx
movq (%rcx), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x4(%rbx)
leaq 0x526c(%rip), %rdi      # 0x91f0
callq 0x578a
movq 0x14e8(%rbx), %rax
movsd 0x48(%rax), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x3fbe
movl 0x4(%rax), %eax
decl %eax
movq %rsp, %rdi
movl $0x0, (%rdi)
movl %eax, 0x4(%rdi)
leaq 0x523d(%rip), %rsi      # 0x91f0
movq %rdi, %rdx
callq 0x5552
movl %eax, 0x4(%rbx)
leaq 0x18(%rbx), %rdi
movl (%rbx), %esi
movl 0x4(%rbx), %edx
leaq 0x8(%rbx), %rcx
leaq 0x10(%rbx), %r8
callq 0x3cb2
leaq 0x65bd(%rip), %rdi      # 0xa598
callq 0x2280
movq 0x14e8(%rbx), %rax
movsd 0x18(%rax), %xmm1
movsd 0x50(%rax), %xmm2
movsd 0x201f(%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 0x4059
movsd %xmm0, (%rdx,%rax,8)
movq 0x14e0(%rbx), %rdx
movq (%rdx), %rdx
movl %ecx, (%rdx,%rax,4)
leaq 0x6538(%rip), %rdi      # 0xa598
callq 0x2130
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq