// File: 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 %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x60(%rbp)
addq $0x30, %rdi
movq -0x10(%rbp), %rax
movslq (%rax), %rsi
callq 0x9a00
movq -0x60(%rbp), %rdi
movq %rax, -0x20(%rbp)
addq $0x48, %rdi
movq -0x10(%rbp), %rax
movslq 0x4(%rax), %rsi
callq 0x9a00
movq -0x60(%rbp), %rdi
movq %rax, -0x28(%rbp)
addq $0x60, %rdi
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rsi
callq 0x9a00
movq -0x60(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq %rdi, %r8
addq $0x190, %r8             # imm = 0x190
movq %rdi, %r9
addq $0x1a8, %r9             # imm = 0x1A8
movq %rdi, %rax
addq $0x1c0, %rax            # imm = 0x1C0
movq %rax, (%rsp)
callq 0xe4e0
movsd %xmm0, -0x38(%rbp)
movsd -0x18(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x3460
movaps %xmm0, %xmm1
movsd 0x3ec4(%rip), %xmm0     # 0x10010
addsd %xmm1, %xmm0
callq 0x3220
movq -0x60(%rbp), %rdi
movsd %xmm0, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0xe660
movq -0x60(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0x58(%rbp), %xmm0
mulsd %xmm1, %xmm0
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
movsd %xmm0, 0x1f0(%rax)
movl $0x0, -0x4c(%rbp)
movq -0x60(%rbp), %rcx
movl -0x4c(%rbp), %eax
cmpl 0x1f8(%rcx), %eax
jge 0xc2d0
movq -0x60(%rbp), %rdi
movsd 0x1f0(%rdi), %xmm0
movsd %xmm0, -0x90(%rbp)
addq $0x190, %rdi            # imm = 0x190
movslq -0x4c(%rbp), %rsi
callq 0x9ae0
movsd -0x90(%rbp), %xmm0
movq -0x60(%rbp), %rdi
mulsd (%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
addq $0x190, %rdi            # imm = 0x190
movslq -0x4c(%rbp), %rsi
callq 0x9ae0
movsd -0x88(%rbp), %xmm0
movq -0x60(%rbp), %rdi
movsd %xmm0, (%rax)
movsd 0x1f0(%rdi), %xmm0
movsd %xmm0, -0x80(%rbp)
addq $0x1a8, %rdi            # imm = 0x1A8
movslq -0x4c(%rbp), %rsi
callq 0x9ae0
movsd -0x80(%rbp), %xmm0
movq -0x60(%rbp), %rdi
mulsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
addq $0x1a8, %rdi            # imm = 0x1A8
movslq -0x4c(%rbp), %rsi
callq 0x9ae0
movsd -0x78(%rbp), %xmm0
movq -0x60(%rbp), %rdi
movsd %xmm0, (%rax)
movsd 0x1f0(%rdi), %xmm0
movsd %xmm0, -0x70(%rbp)
addq $0x1c0, %rdi            # imm = 0x1C0
movslq -0x4c(%rbp), %rsi
callq 0x9ae0
movsd -0x70(%rbp), %xmm0
movq -0x60(%rbp), %rdi
mulsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
addq $0x1c0, %rdi            # imm = 0x1C0
movslq -0x4c(%rbp), %rsi
callq 0x9ae0
movsd -0x68(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xc1bf
movq -0x60(%rbp), %rdi
movq %rdi, %rsi
addq $0x190, %rsi            # imm = 0x190
callq 0xe6b0
movq -0x60(%rbp), %rdi
movsd %xmm0, -0xa8(%rbp)
addq $0x1d8, %rdi            # imm = 0x1D8
xorl %eax, %eax
movl %eax, %esi
callq 0x9ae0
movsd -0xa8(%rbp), %xmm0
movq -0x60(%rbp), %rdi
movsd %xmm0, (%rax)
movq %rdi, %rsi
addq $0x1a8, %rsi            # imm = 0x1A8
callq 0xe6b0
movq -0x60(%rbp), %rdi
movsd %xmm0, -0xa0(%rbp)
addq $0x1d8, %rdi            # imm = 0x1D8
movl $0x1, %esi
callq 0x9ae0
movsd -0xa0(%rbp), %xmm0
movq -0x60(%rbp), %rdi
movsd %xmm0, (%rax)
movq %rdi, %rsi
addq $0x1c0, %rsi            # imm = 0x1C0
callq 0xe6b0
movq -0x60(%rbp), %rdi
movsd %xmm0, -0x98(%rbp)
addq $0x1d8, %rdi            # imm = 0x1D8
movl $0x2, %esi
callq 0x9ae0
movsd -0x98(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x48(%rbp), %xmm0
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)