// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
subq $0x30, %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), %r8
leaq 0x1a8(%rdi), %r14
leaq 0x1c0(%rdi), %r15
movq %r15, (%rsp)
movq %rax, %rsi
movq %r14, %r9
callq 0x6554
xorpd 0x1e91(%rip), %xmm0     # 0x7040
mulsd 0x18(%rsp), %xmm0
movapd %xmm0, 0x20(%rsp)
callq 0x23c0
addsd 0x1e50(%rip), %xmm0     # 0x7018
callq 0x21d0
movsd %xmm0, 0x10(%rsp)
movapd 0x20(%rsp), %xmm0
xorpd 0x1e5f(%rip), %xmm0     # 0x7040
callq 0x23c0
addsd 0x1e2a(%rip), %xmm0     # 0x7018
movsd 0x1e2a(%rip), %xmm1     # 0x7020
divsd %xmm0, %xmm1
mulsd 0x18(%rsp), %xmm1
movsd %xmm1, 0x1f0(%rbx)
movslq 0x1f8(%rbx), %rcx
movq 0x190(%rbx), %rax
testq %rcx, %rcx
jle 0x5261
movq (%r14), %rdx
movq (%r15), %rsi
xorl %edi, %edi
movsd 0x1f0(%rbx), %xmm0
mulsd (%rax,%rdi,8), %xmm0
movsd %xmm0, (%rax,%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, %rcx
jne 0x5223
movq 0x198(%rbx), %rcx
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
subq %rax, %rcx
je 0x5298
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 0x5283
ucomisd %xmm1, %xmm0
jb 0x52a4
sqrtsd %xmm0, %xmm0
jmp 0x52a9
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 0x52f2
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 0x52dd
ucomisd %xmm1, %xmm0
jb 0x52fe
sqrtsd %xmm0, %xmm0
jmp 0x5303
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 0x534d
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 0x5338
ucomisd %xmm1, %xmm0
jb 0x5359
sqrtsd %xmm0, %xmm0
jmp 0x535e
callq 0x21c0
movsd 0x10(%rsp), %xmm1
movq 0x1d8(%rbx), %rax
movsd %xmm0, 0x10(%rax)
movaps %xmm1, %xmm0
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop