// File: /workspace/github_cpp_makefile_star2_O2/thunlp[P]KB2E/TransR/Train_TransR.cpp
// Function: Train::gradient_one(int, int, int, int, int)
void gradient_one(int e1, int e2, int rel, int belta,int same)
    {
    	for (int ii=0; ii<m; ii++)
        {
            double tmp1 = 0, tmp2 = 0;
            for (int jj=0; jj<n; jj++)
            {
                tmp1+=A[rel][jj][ii]*entity_vec[e1][jj];
                tmp2+=A[rel][jj][ii]*entity_vec[e2][jj];
            }
            double x = 2*(tmp2-tmp1-relation_vec[rel][ii]);
            if (L1_flag)
            	if (x>0)
            		x=1;
            	else
            		x=-1;
            for (int jj=0; jj<n; jj++)
            {
                A_tmp[rel][jj][ii]-=belta*rate*x*(entity_vec[e1][jj]-entity_vec[e2][jj]);
                entity_tmp[e1][jj]-=belta*rate*x*A[rel][jj][ii];
                entity_tmp[e2][jj]+=belta*rate*x*A[rel][jj][ii];
            }
            relation_tmp[rel][ii]-=same*belta*rate*x;
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x30(%rdi), %eax
movl 0x34(%rdi), %r11d
movslq %ecx, %rcx
movslq %esi, %r10
movslq %edx, %rdx
imulq $0x18, %rcx, %rcx
movq 0xa0(%rdi), %rsi
addq %rcx, %rsi
movq %rsi, -0x10(%rsp)
cvtsi2sd %r8d, %xmm0
imull %r8d, %r9d
cvtsi2sd %r9d, %xmm1
movq 0xd0(%rdi), %rsi
movq %rcx, -0x20(%rsp)
addq %rcx, %rsi
movq %rsi, -0x18(%rsp)
xorl %r8d, %r8d
testl %eax, %eax
cmovlel %r8d, %eax
movb 0x5694(%rip), %cl       # 0xb1a8
movb %cl, -0x21(%rsp)
testl %r11d, %r11d
cmovlel %r8d, %r11d
movq %r11, -0x8(%rsp)
imulq $0x18, %r10, %r11
imulq $0x18, %rdx, %rbx
xorpd %xmm2, %xmm2
cmpq -0x8(%rsp), %r8
je 0x5cc1
movq 0x100(%rdi), %r15
addq -0x20(%rsp), %r15
movq 0xb8(%rdi), %r12
leaq (%r12,%r11), %r13
addq %rbx, %r12
xorpd %xmm4, %xmm4
xorl %edx, %edx
xorl %r9d, %r9d
cmpq %r9, %rax
je 0x5b9a
movq (%r15), %r10
movq (%r10,%rdx), %r10
movq (%r13), %r14
movq (%r12), %rbp
movsd (%r10,%r8,8), %xmm3
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
movsd (%r14,%r9,8), %xmm5
movhpd (%rbp,%r9,8), %xmm5     # xmm5 = xmm5[0],mem[0]
mulpd %xmm3, %xmm5
addpd %xmm5, %xmm4
incq %r9
addq $0x18, %rdx
jmp 0x5b5e
movapd %xmm4, %xmm3
unpckhpd %xmm4, %xmm3            # xmm3 = xmm3[1],xmm4[1]
subsd %xmm4, %xmm3
movq -0x10(%rsp), %rcx
movq (%rcx), %rdx
subsd (%rdx,%r8,8), %xmm3
addsd %xmm3, %xmm3
xorl %edx, %edx
ucomisd %xmm2, %xmm3
seta %r9b
testb $0x1, -0x21(%rsp)
je 0x5bd8
movb %r9b, %dl
leaq 0x14cd(%rip), %rcx      # 0x70a0
movsd (%rcx,%rdx,8), %xmm3
movq 0x118(%rdi), %rbp
addq -0x20(%rsp), %rbp
movq 0xe8(%rdi), %r14
leaq (%r14,%r11), %rdx
addq %rbx, %r14
xorl %r9d, %r9d
xorl %r10d, %r10d
movsd 0x48(%rdi), %xmm4
cmpq %r10, %rax
je 0x5c99
movq (%r13), %rsi
movsd (%rsi,%r10,8), %xmm5
movq (%r12), %rsi
subsd (%rsi,%r10,8), %xmm5
movq (%rbp), %rsi
movq (%rsi,%r9), %rsi
movsd (%rsi,%r8,8), %xmm6
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm4
mulsd %xmm5, %xmm4
subsd %xmm4, %xmm6
movsd %xmm6, (%rsi,%r8,8)
movq (%r15), %rsi
movq (%rsi,%r9), %rsi
movq (%rdx), %rcx
movsd (%rcx,%r10,8), %xmm4
movsd 0x48(%rdi), %xmm5
mulsd %xmm0, %xmm5
mulsd %xmm3, %xmm5
mulsd (%rsi,%r8,8), %xmm5
subsd %xmm5, %xmm4
movsd %xmm4, (%rcx,%r10,8)
movsd 0x48(%rdi), %xmm4
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm4
movq (%r14), %rcx
mulsd (%rsi,%r8,8), %xmm4
addsd (%rcx,%r10,8), %xmm4
movsd %xmm4, (%rcx,%r10,8)
incq %r10
addq $0x18, %r9
jmp 0x5bf8
movq -0x18(%rsp), %rcx
movq (%rcx), %rdx
movsd (%rdx,%r8,8), %xmm5
mulsd %xmm1, %xmm4
mulsd %xmm3, %xmm4
subsd %xmm4, %xmm5
movsd %xmm5, (%rdx,%r8,8)
incq %r8
jmp 0x5b30
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq