// File: KokiKishimoto[P]cp_decomposition/./updater.hpp
// Function: Updater::SGD(Triple&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&)
void SGD(Triple& triple, std::vector<double>& gradient_r, std::vector<double>& gradient_s, std::vector<double>& gradient_o, std::vector<double>& norms, std::vector< std::vector<double> >& subjVec, std::vector< std::vector<double> >& objVec, std::vector< std::vector<double> >& relationVec) {
		std::vector<double>& r_v = relationVec[triple.relation];
		if (norms[0] >= threshold) {
			double x = (threshold / norms[0]);
			for (int i = 0; i < gradient_r.size(); i++) {
				r_v[i] -= learningRate * x * gradient_r[i];
			}
		} else {
			for (int i = 0; i < gradient_r.size(); i++) {
				r_v[i] -= learningRate * gradient_r[i];
			}			
		}

		std::vector<double>& s_e_v = subjVec[triple.subj];
		if (norms[1] >= threshold) {
			double x = (threshold / norms[1]);
			for (int i = 0; i < gradient_s.size(); i++) {
				s_e_v[i] -= learningRate * x * gradient_s[i];
			}
		} else {
			for (int i = 0; i < gradient_s.size(); i++) {
				s_e_v[i] -= learningRate * gradient_s[i];
			}			
		}

		std::vector<double>& o_e_v = objVec[triple.obj];
		if (norms[2] >= threshold) {
			double x = (threshold / norms[2]);
			for (int i = 0; i < gradient_o.size(); i++) {
				o_e_v[i] -= learningRate * x * gradient_o[i];
			}
		} else {
			for (int i = 0; i < gradient_o.size(); i++) {
				o_e_v[i] -= learningRate * gradient_o[i];
			}			
		}		
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq 0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rsi
callq 0xaa60
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xaab0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movsd (%rcx), %xmm0
ucomisd 0x18(%rax), %xmm0
jb 0xc502
movq -0x80(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xaab0
movsd -0x88(%rbp), %xmm0
divsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movslq -0x44(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
callq 0xb090
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
jae 0xc4fd
movq -0x80(%rbp), %rax
movsd 0x8(%rax), %xmm0
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x44(%rbp), %rsi
callq 0xaab0
movsd (%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
movq -0x38(%rbp), %rdi
movslq -0x44(%rbp), %rsi
callq 0xaab0
movsd -0xa0(%rbp), %xmm0
movsd -0x98(%rbp), %xmm2
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xc455
jmp 0xc5aa
movl $0x0, -0x48(%rbp)
movslq -0x48(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
callq 0xb090
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0xc5a8
movq -0x80(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0xaab0
movsd (%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x38(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0xaab0
movsd -0xb8(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm2
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xc509
jmp 0xc5aa
movq 0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq (%rax), %rsi
callq 0xaa60
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0xaab0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movsd (%rcx), %xmm0
ucomisd 0x18(%rax), %xmm0
jb 0xc6c6
movq -0x80(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0xaab0
movsd -0xc0(%rbp), %xmm0
divsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movslq -0x5c(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x20(%rbp), %rdi
callq 0xb090
movq %rax, %rcx
movq -0xc8(%rbp), %rax
cmpq %rcx, %rax
jae 0xc6c1
movq -0x80(%rbp), %rax
movsd 0x8(%rax), %xmm0
mulsd -0x58(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x5c(%rbp), %rsi
callq 0xaab0
movsd (%rax), %xmm0
movsd %xmm0, -0xd0(%rbp)
movq -0x50(%rbp), %rdi
movslq -0x5c(%rbp), %rsi
callq 0xaab0
movsd -0xd8(%rbp), %xmm0
movsd -0xd0(%rbp), %xmm2
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xc619
jmp 0xc76e
movl $0x0, -0x60(%rbp)
movslq -0x60(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x20(%rbp), %rdi
callq 0xb090
movq %rax, %rcx
movq -0xe0(%rbp), %rax
cmpq %rcx, %rax
jae 0xc76c
movq -0x80(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0xf0(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x60(%rbp), %rsi
callq 0xaab0
movsd (%rax), %xmm0
movsd %xmm0, -0xe8(%rbp)
movq -0x50(%rbp), %rdi
movslq -0x60(%rbp), %rsi
callq 0xaab0
movsd -0xf0(%rbp), %xmm0
movsd -0xe8(%rbp), %xmm2
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0xc6cd
jmp 0xc76e
movq 0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq 0x4(%rax), %rsi
callq 0xaa60
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rdi
movl $0x2, %esi
callq 0xaab0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movsd (%rcx), %xmm0
ucomisd 0x18(%rax), %xmm0
jb 0xc88b
movq -0x80(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0xf8(%rbp)
movq -0x30(%rbp), %rdi
movl $0x2, %esi
callq 0xaab0
movsd -0xf8(%rbp), %xmm0
divsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movslq -0x74(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x28(%rbp), %rdi
callq 0xb090
movq %rax, %rcx
movq -0x100(%rbp), %rax
cmpq %rcx, %rax
jae 0xc886
movq -0x80(%rbp), %rax
movsd 0x8(%rax), %xmm0
mulsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x74(%rbp), %rsi
callq 0xaab0
movsd (%rax), %xmm0
movsd %xmm0, -0x108(%rbp)
movq -0x68(%rbp), %rdi
movslq -0x74(%rbp), %rsi
callq 0xaab0
movsd -0x110(%rbp), %xmm0
movsd -0x108(%rbp), %xmm2
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xc7de
jmp 0xc933
movl $0x0, -0x78(%rbp)
movslq -0x78(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x28(%rbp), %rdi
callq 0xb090
movq %rax, %rcx
movq -0x118(%rbp), %rax
cmpq %rcx, %rax
jae 0xc931
movq -0x80(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x128(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0xaab0
movsd (%rax), %xmm0
movsd %xmm0, -0x120(%rbp)
movq -0x68(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0xaab0
movsd -0x128(%rbp), %xmm0
movsd -0x120(%rbp), %xmm2
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0xc892
jmp 0xc933
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopl (%rax)