// File: /workspace/github_cpp_makefile_star2_O1/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
movslq 0x34(%rdi), %rax
movq %rax, -0x8(%rsp)
testq %rax, %rax
jle 0x6237
movl 0x30(%rdi), %r10d
movslq %ecx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
movq 0x100(%rdi), %rcx
addq %rax, %rcx
movslq %esi, %r11
movq 0xb8(%rdi), %rsi
shlq $0x3, %r11
leaq (%r11,%r11,2), %r14
leaq (%rsi,%r14), %rbx
movslq %edx, %rdx
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rdx, %rsi
movq 0xa0(%rdi), %r11
movq (%r11,%rax), %r11
movq %r11, -0x10(%rsp)
movb 0x6116(%rip), %r11b     # 0xc1a0
movb %r11b, -0x29(%rsp)
cvtsi2sd %r8d, %xmm0
movq 0x118(%rdi), %r11
addq %rax, %r11
movq %r11, -0x20(%rsp)
movq 0xe8(%rdi), %r11
addq %r11, %r14
movq %r14, -0x18(%rsp)
addq %rdx, %r11
movq %r11, -0x28(%rsp)
imull %r8d, %r9d
cvtsi2sd %r9d, %xmm1
movq 0xd0(%rdi), %rdx
movq (%rdx,%rax), %r8
xorl %r9d, %r9d
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
testl %r10d, %r10d
jle 0x6127
movq (%rcx), %rax
movq (%rbx), %rdx
movq (%rsi), %r11
xorpd %xmm3, %xmm3
xorl %r14d, %r14d
movq (%rax), %r15
movsd (%r15,%r9,8), %xmm4
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
movsd (%r11,%r14,8), %xmm5
movhpd (%rdx,%r14,8), %xmm5    # xmm5 = xmm5[0],mem[0]
mulpd %xmm4, %xmm5
addpd %xmm5, %xmm3
incq %r14
addq $0x18, %rax
cmpq %r14, %r10
jne 0x60ee
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
subsd %xmm4, %xmm3
movq -0x10(%rsp), %rax
subsd (%rax,%r9,8), %xmm3
addsd %xmm3, %xmm3
xorl %eax, %eax
ucomisd %xmm2, %xmm3
seta %dl
cmpb $0x0, -0x29(%rsp)
je 0x6154
movb %dl, %al
leaq 0x1f51(%rip), %rdx      # 0x80a0
movsd (%rdx,%rax,8), %xmm3
testl %r10d, %r10d
jle 0x620c
movq (%rbx), %r13
movq (%rsi), %r12
movq -0x20(%rsp), %rax
movq (%rax), %r11
movq (%rcx), %r14
movq -0x18(%rsp), %rax
movq (%rax), %r15
movq -0x28(%rsp), %rax
movq (%rax), %rax
xorl %edx, %edx
movsd (%r13,%rdx,8), %xmm4
subsd (%r12,%rdx,8), %xmm4
movq (%r11), %rbp
movsd (%rbp,%r9,8), %xmm5
movsd 0x48(%rdi), %xmm6
mulsd %xmm0, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, (%rbp,%r9,8)
movq (%r14), %rbp
movsd 0x48(%rdi), %xmm4
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm4
mulsd (%rbp,%r9,8), %xmm4
movsd (%r15,%rdx,8), %xmm5
subsd %xmm4, %xmm5
movsd %xmm5, (%r15,%rdx,8)
movsd 0x48(%rdi), %xmm4
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm4
mulsd (%rbp,%r9,8), %xmm4
addsd (%rax,%rdx,8), %xmm4
movsd %xmm4, (%rax,%rdx,8)
incq %rdx
addq $0x18, %r11
addq $0x18, %r14
cmpq %rdx, %r10
jne 0x6180
movsd (%r8,%r9,8), %xmm4
movsd 0x48(%rdi), %xmm5
mulsd %xmm1, %xmm5
mulsd %xmm3, %xmm5
subsd %xmm5, %xmm4
movsd %xmm4, (%r8,%r9,8)
incq %r9
cmpq -0x8(%rsp), %r9
jne 0x60d5
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq