// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movslq 0x38(%rsp), %rbx
movslq 0x30(%rdi), %rax
movq %rax, -0x8(%rsp)
movslq %edx, %r11
movq 0xc8(%rdi), %rdx
movq 0xe0(%rdi), %r10
imulq $0x18, %r11, %r11
leaq (%r10,%r11), %rax
movq %rax, -0x10(%rsp)
movslq %esi, %rsi
imulq $0x18, %rsi, %rsi
leaq (%r10,%rsi), %r14
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
leaq (%rdx,%rcx), %r15
movq 0xf8(%rdi), %r12
addq %r12, %rcx
movq 0x110(%rdi), %r13
addq %r13, %rsi
addq %r13, %r11
movslq %r9d, %r9
imulq $0x18, %r9, %rbp
imulq $0x18, %rbx, %r9
addq %r9, %rdx
addq %r9, %r12
leaq (%r10,%rbp), %r9
movslq %r8d, %r8
imulq $0x18, %r8, %r8
addq %r8, %r10
addq %r13, %r8
addq %rbp, %r13
movb 0x526d(%rip), %bpl      # 0xa1a8
movsd 0x10d5(%rip), %xmm0     # 0x6018
movsd 0x1105(%rip), %xmm1     # 0x6050
xorl %ebx, %ebx
cmpq -0x8(%rsp), %rbx
jge 0x5069
movq -0x10(%rsp), %rax
movq (%rax), %rax
movsd (%rax,%rbx,8), %xmm2
movq (%r14), %rax
subsd (%rax,%rbx,8), %xmm2
movq (%r15), %rax
subsd (%rax,%rbx,8), %xmm2
addsd %xmm2, %xmm2
testb $0x1, %bpl
je 0x4f9c
xorpd %xmm3, %xmm3
cmpltsd %xmm2, %xmm3
movapd %xmm3, %xmm2
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm3
orpd %xmm2, %xmm3
movapd %xmm3, %xmm2
movq (%rcx), %rax
movsd 0x50(%rdi), %xmm3
mulsd %xmm2, %xmm3
addsd (%rax,%rbx,8), %xmm3
movsd %xmm3, (%rax,%rbx,8)
movq (%rsi), %rax
movsd 0x50(%rdi), %xmm3
mulsd %xmm2, %xmm3
addsd (%rax,%rbx,8), %xmm3
movsd %xmm3, (%rax,%rbx,8)
movq (%r11), %rax
mulsd 0x50(%rdi), %xmm2
movsd (%rax,%rbx,8), %xmm3
subsd %xmm2, %xmm3
movsd %xmm3, (%rax,%rbx,8)
movq (%r9), %rax
movsd (%rax,%rbx,8), %xmm2
movq (%r10), %rax
subsd (%rax,%rbx,8), %xmm2
movq (%rdx), %rax
subsd (%rax,%rbx,8), %xmm2
addsd %xmm2, %xmm2
je 0x5019
xorpd %xmm3, %xmm3
cmpltsd %xmm2, %xmm3
movapd %xmm3, %xmm2
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm3
orpd %xmm2, %xmm3
movapd %xmm3, %xmm2
movq (%r12), %rax
movsd (%rax,%rbx,8), %xmm3
movsd 0x50(%rdi), %xmm4
mulsd %xmm2, %xmm4
subsd %xmm4, %xmm3
movsd %xmm3, (%rax,%rbx,8)
movq (%r8), %rax
movsd (%rax,%rbx,8), %xmm3
movsd 0x50(%rdi), %xmm4
mulsd %xmm2, %xmm4
subsd %xmm4, %xmm3
movsd %xmm3, (%rax,%rbx,8)
movq (%r13), %rax
mulsd 0x50(%rdi), %xmm2
addsd (%rax,%rbx,8), %xmm2
movsd %xmm2, (%rax,%rbx,8)
incq %rbx
jmp 0x4f4d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq