// File: /workspace/github_cpp_makefile_star2_O1/thunlp[P]KB2E/TransE/Train_TransE.cpp
// Function: Train::gradient(int, int, int, int, int, int)
void gradient(int e1_a,int e2_a,int rel_a,int e1_b,int e2_b,int rel_b)
    {
        for (int ii=0; ii<n; ii++)
        {

            double x = 2*(entity_vec[e2_a][ii]-entity_vec[e1_a][ii]-relation_vec[rel_a][ii]);
            if (L1_flag)
            	if (x>0)
            		x=1;
            	else
            		x=-1;
            relation_tmp[rel_a][ii]-=-1*rate*x;
            entity_tmp[e1_a][ii]-=-1*rate*x;
            entity_tmp[e2_a][ii]+=-1*rate*x;
            x = 2*(entity_vec[e2_b][ii]-entity_vec[e1_b][ii]-relation_vec[rel_b][ii]);
            if (L1_flag)
            	if (x>0)
            		x=1;
            	else
            		x=-1;
            relation_tmp[rel_b][ii]-=rate*x;
            entity_tmp[e1_b][ii]-=rate*x;
            entity_tmp[e2_b][ii]+=rate*x;
        }
    }

// Assembly:
movslq 0x30(%rdi), %rax
testq %rax, %rax
jle 0x54df
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movslq %edx, %r10
movq 0xc8(%rdi), %r15
movq 0xe0(%rdi), %rdx
shlq $0x3, %r10
leaq (%r10,%r10,2), %r14
movq (%rdx,%r14), %r10
movq %r10, -0x8(%rsp)
movslq %esi, %rsi
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rbx
movq (%rdx,%rbx), %rsi
movq %rsi, -0x10(%rsp)
movslq %ecx, %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %r11
movq (%r15,%r11), %rcx
movb 0x4e3d(%rip), %r10b     # 0xa1a0
movq 0xf8(%rdi), %r12
movq (%r12,%r11), %r11
movq 0x110(%rdi), %rbp
movq (%rbp,%rbx), %rbx
movq (%rbp,%r14), %r14
movslq %r9d, %r9
shlq $0x3, %r9
leaq (%r9,%r9,2), %rsi
movslq 0x38(%rsp), %r9
shlq $0x3, %r9
leaq (%r9,%r9,2), %r13
movq (%r15,%r13), %r9
movq (%r12,%r13), %r15
movq (%rdx,%rsi), %r12
movslq %r8d, %r8
shlq $0x3, %r8
leaq (%r8,%r8,2), %r13
movq (%rdx,%r13), %r8
movq (%rbp,%r13), %r13
movq (%rbp,%rsi), %rbp
shlq $0x3, %rax
xorl %edx, %edx
movsd 0x1c56(%rip), %xmm0     # 0x7020
movsd 0x1c86(%rip), %xmm1     # 0x7058
movq -0x8(%rsp), %rsi
movsd (%rsi,%rdx), %xmm2
movq -0x10(%rsp), %rsi
subsd (%rsi,%rdx), %xmm2
subsd (%rcx,%rdx), %xmm2
addsd %xmm2, %xmm2
testb %r10b, %r10b
je 0x5411
xorpd %xmm3, %xmm3
cmpltsd %xmm2, %xmm3
movapd %xmm3, %xmm2
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm3
orpd %xmm2, %xmm3
movapd %xmm3, %xmm2
movsd 0x50(%rdi), %xmm3
mulsd %xmm2, %xmm3
addsd (%r11,%rdx), %xmm3
movsd %xmm3, (%r11,%rdx)
movsd 0x50(%rdi), %xmm3
mulsd %xmm2, %xmm3
addsd (%rbx,%rdx), %xmm3
movsd %xmm3, (%rbx,%rdx)
movsd (%r14,%rdx), %xmm3
mulsd 0x50(%rdi), %xmm2
subsd %xmm2, %xmm3
movsd %xmm3, (%r14,%rdx)
movsd (%r12,%rdx), %xmm2
subsd (%r8,%rdx), %xmm2
subsd (%r9,%rdx), %xmm2
addsd %xmm2, %xmm2
je 0x5483
xorpd %xmm3, %xmm3
cmpltsd %xmm2, %xmm3
movapd %xmm3, %xmm2
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm3
orpd %xmm2, %xmm3
movapd %xmm3, %xmm2
movsd (%r15,%rdx), %xmm3
movsd 0x50(%rdi), %xmm4
mulsd %xmm2, %xmm4
subsd %xmm4, %xmm3
movsd %xmm3, (%r15,%rdx)
movsd (%r13,%rdx), %xmm3
movsd 0x50(%rdi), %xmm4
mulsd %xmm2, %xmm4
subsd %xmm4, %xmm3
movsd %xmm3, (%r13,%rdx)
mulsd 0x50(%rdi), %xmm2
addsd (%rbp,%rdx), %xmm2
movsd %xmm2, (%rbp,%rdx)
addq $0x8, %rdx
cmpq %rdx, %rax
jne 0x53d2
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq