// File: /workspace/github_cpp_makefile_star2_O1/KokiKishimoto[P]cp_decomposition/cp.cpp
// Function: CP::computeGradients(Triple&, double)
double computeGradients(Triple& triple, double y) {
		const std::vector<double>& subj_v = subjVec[triple.subj];
		const std::vector<double>& obj_v = objVec[triple.obj];
		const std::vector<double>& relation_v = relationVec[triple.relation];

		op.product(subj_v, obj_v, relation_v, outVec1, outVec2, outVec3);

		double score = op.innerProduct(relation_v, outVec1);

		double yscore = y * score;
		double loss = std::log(1.0 + std::exp(-yscore));
		fs = -(y * sigmoid(-yscore));

		for (int i = 0; i < vecDim; i++) {
			outVec1[i] = fs * outVec1[i];
			outVec2[i] = fs * outVec2[i];
			outVec3[i] = fs * outVec3[i];
		}

		norms[0] = op.norm(outVec1);
		norms[1] = op.norm(outVec2);
		norms[2] = op.norm(outVec3);

		return loss;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movslq (%rsi), %rax
leaq (%rax,%rax,2), %rdx
shlq $0x3, %rdx
addq 0x30(%rdi), %rdx
movslq 0x4(%rsi), %rax
leaq (%rax,%rax,2), %rcx
shlq $0x3, %rcx
addq 0x48(%rdi), %rcx
movslq 0x8(%rsi), %rax
leaq (%rax,%rax,2), %r15
shlq $0x3, %r15
addq 0x60(%rdi), %r15
movsd %xmm0, 0x8(%rsp)
leaq 0x190(%rdi), %r14
leaq 0x1a8(%rdi), %r13
leaq 0x1c0(%rdi), %rbp
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %r8
movq %r14, %r9
pushq %rbp
pushq %r13
callq 0x6664
addq $0x10, %rsp
movq (%r12), %rdi
testq %rdi, %rdi
je 0x5260
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2260
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
je 0x5299
sarq $0x3, %rcx
movq (%r14), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm1
mulsd (%rdx,%rsi,8), %xmm1
addsd %xmm1, %xmm0
incq %rsi
cmpq %rsi, %rcx
jne 0x5281
jmp 0x529d
xorpd %xmm0, %xmm0
xorpd 0x1d8b(%rip), %xmm0     # 0x7030
mulsd 0x8(%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
callq 0x23c0
addsd 0x1d5a(%rip), %xmm0     # 0x7018
callq 0x21d0
movsd %xmm0, (%rsp)
movapd 0x10(%rsp), %xmm0
xorpd 0x1d5a(%rip), %xmm0     # 0x7030
callq 0x23c0
addsd 0x1d35(%rip), %xmm0     # 0x7018
movsd 0x1d35(%rip), %xmm1     # 0x7020
divsd %xmm0, %xmm1
mulsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x1f0(%rbx)
movslq 0x200(%rbx), %rax
testq %rax, %rax
jle 0x5354
movq (%r14), %rcx
movq (%r13), %rdx
movq (%rbp), %rsi
xorl %edi, %edi
movsd 0x1f0(%rbx), %xmm0
mulsd (%rcx,%rdi,8), %xmm0
movsd %xmm0, (%rcx,%rdi,8)
movsd 0x1f0(%rbx), %xmm0
mulsd (%rdx,%rdi,8), %xmm0
movsd %xmm0, (%rdx,%rdi,8)
movsd 0x1f0(%rbx), %xmm0
mulsd (%rsi,%rdi,8), %xmm0
movsd %xmm0, (%rsi,%rdi,8)
incq %rdi
cmpq %rdi, %rax
jne 0x5316
movq 0x190(%rbx), %rax
movq 0x198(%rbx), %rcx
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
subq %rax, %rcx
je 0x5392
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rdx
cmpq %rdx, %rcx
jne 0x537d
ucomisd %xmm1, %xmm0
jb 0x539e
sqrtsd %xmm0, %xmm0
jmp 0x53a3
callq 0x21c0
movq 0x1d8(%rbx), %rax
movsd %xmm0, (%rax)
movq 0x1a8(%rbx), %rax
movq 0x1b0(%rbx), %rcx
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
subq %rax, %rcx
je 0x53ec
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rdx
cmpq %rdx, %rcx
jne 0x53d7
ucomisd %xmm1, %xmm0
jb 0x53f8
sqrtsd %xmm0, %xmm0
jmp 0x53fd
callq 0x21c0
movq 0x1d8(%rbx), %rax
movsd %xmm0, 0x8(%rax)
movq 0x1c0(%rbx), %rax
movq 0x1c8(%rbx), %rcx
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
subq %rax, %rcx
je 0x5447
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rdx
cmpq %rdx, %rcx
jne 0x5432
ucomisd %xmm1, %xmm0
jb 0x5453
sqrtsd %xmm0, %xmm0
jmp 0x5458
callq 0x21c0
movsd (%rsp), %xmm1
movq 0x1d8(%rbx), %rax
movsd %xmm0, 0x10(%rax)
movaps %xmm1, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop