// File: /workspace/github_cpp_makefile_star2_O1/KokiKishimoto[P]cp_decomposition/quantizedcp.cpp
// Function: QuantizeCP::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];

		double score = op.qproduct(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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movslq (%rsi), %rax
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x30(%rdi), %rax
movslq 0x4(%rsi), %rcx
leaq (%rcx,%rcx,2), %rdx
shlq $0x3, %rdx
addq 0x48(%rdi), %rdx
movslq 0x8(%rsi), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x60(%rdi), %rcx
movsd %xmm0, 0x18(%rsp)
leaq 0x190(%rdi), %r14
leaq 0x1a8(%rdi), %r15
leaq 0x1c0(%rdi), %r12
movq %r12, (%rsp)
movq %rax, %rsi
movq %r14, %r8
movq %r15, %r9
callq 0x651e
xorpd 0x1ede(%rip), %xmm0     # 0x7040
mulsd 0x18(%rsp), %xmm0
movapd %xmm0, 0x20(%rsp)
callq 0x23c0
addsd 0x1e9d(%rip), %xmm0     # 0x7018
callq 0x21d0
movsd %xmm0, 0x10(%rsp)
movapd 0x20(%rsp), %xmm0
xorpd 0x1eac(%rip), %xmm0     # 0x7040
callq 0x23c0
addsd 0x1e77(%rip), %xmm0     # 0x7018
movsd 0x1e77(%rip), %xmm1     # 0x7020
divsd %xmm0, %xmm1
mulsd 0x18(%rsp), %xmm1
movsd %xmm1, 0x1f0(%rbx)
movslq 0x1f8(%rbx), %rax
testq %rax, %rax
jle 0x5211
movq (%r14), %rcx
movq (%r15), %rdx
movq (%r12), %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 0x51d3
movq 0x190(%rbx), %rax
movq 0x198(%rbx), %rcx
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
subq %rax, %rcx
je 0x524f
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 0x523a
ucomisd %xmm1, %xmm0
jb 0x525b
sqrtsd %xmm0, %xmm0
jmp 0x5260
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 0x52a9
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 0x5294
ucomisd %xmm1, %xmm0
jb 0x52b5
sqrtsd %xmm0, %xmm0
jmp 0x52ba
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 0x5304
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 0x52ef
ucomisd %xmm1, %xmm0
jb 0x5310
sqrtsd %xmm0, %xmm0
jmp 0x5315
callq 0x21c0
movsd 0x10(%rsp), %xmm1
movq 0x1d8(%rbx), %rax
movsd %xmm0, 0x10(%rax)
movaps %xmm1, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq