// File: /workspace/github_cpp_makefile_star2_O3/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), %r12
testq %r12, %r12
jle 0x6341
movl 0x30(%rdi), %r10d
movslq %ecx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
movq 0x100(%rdi), %rcx
addq %rax, %rcx
movq %rcx, -0x20(%rsp)
movslq %esi, %r11
movq 0xb8(%rdi), %rsi
shlq $0x3, %r11
leaq (%r11,%r11,2), %rcx
leaq (%rsi,%rcx), %r13
movslq %edx, %rdx
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %r11
addq %r11, %rsi
movq %rsi, -0x28(%rsp)
movq 0xa0(%rdi), %rdx
movq (%rdx,%rax), %rdx
movb 0x605c(%rip), %sil      # 0xc1a0
cvtsi2sd %r8d, %xmm0
movq 0x118(%rdi), %rbx
addq %rax, %rbx
movq %rbx, -0x10(%rsp)
movq 0xe8(%rdi), %rbx
addq %rbx, %rcx
movq %rcx, -0x8(%rsp)
addq %r11, %rbx
movq %rbx, -0x18(%rsp)
imull %r8d, %r9d
cvtsi2sd %r9d, %xmm1
movq 0xd0(%rdi), %r8
movq (%r8,%rax), %r8
xorl %r9d, %r9d
xorpd %xmm2, %xmm2
movb %sil, -0x29(%rsp)
testl %r10d, %r10d
jle 0x62ec
movq -0x20(%rsp), %rax
movq (%rax), %rax
movq (%r13), %r11
movq -0x28(%rsp), %rcx
movq (%rcx), %rbx
xorpd %xmm3, %xmm3
xorl %r14d, %r14d
movq (%rax), %r15
movsd (%r15,%r9,8), %xmm4
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
movsd (%rbx,%r14,8), %xmm5
movhpd (%r11,%r14,8), %xmm5    # xmm5 = xmm5[0],mem[0]
mulpd %xmm4, %xmm5
addpd %xmm5, %xmm3
incq %r14
addq $0x18, %rax
cmpq %r14, %r10
jne 0x61b3
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
subsd %xmm4, %xmm3
subsd (%rdx,%r9,8), %xmm3
addsd %xmm3, %xmm3
xorl %eax, %eax
ucomisd %xmm2, %xmm3
seta %r11b
testb %sil, %sil
je 0x6214
movb %r11b, %al
leaq 0x1e91(%rip), %rcx      # 0x80a0
movsd (%rcx,%rax,8), %xmm3
testl %r10d, %r10d
jle 0x6318
movq %rdx, %rsi
movq %r12, %rcx
movq %r13, %rbp
movq (%r13), %r13
movq -0x28(%rsp), %rax
movq (%rax), %r12
movq -0x10(%rsp), %rax
movq (%rax), %r14
movq -0x20(%rsp), %rax
movq (%rax), %r11
movq -0x8(%rsp), %rax
movq (%rax), %r15
movq -0x18(%rsp), %rax
movq (%rax), %rax
xorl %ebx, %ebx
movsd (%r13,%rbx,8), %xmm4
subsd (%r12,%rbx,8), %xmm4
movq (%r14), %rdx
movsd (%rdx,%r9,8), %xmm5
movsd 0x48(%rdi), %xmm6
mulsd %xmm0, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, (%rdx,%r9,8)
movq (%r11), %rdx
movsd 0x48(%rdi), %xmm4
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm4
mulsd (%rdx,%r9,8), %xmm4
movsd (%r15,%rbx,8), %xmm5
subsd %xmm4, %xmm5
movsd %xmm5, (%r15,%rbx,8)
movsd 0x48(%rdi), %xmm4
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm4
mulsd (%rdx,%r9,8), %xmm4
addsd (%rax,%rbx,8), %xmm4
movsd %xmm4, (%rax,%rbx,8)
incq %rbx
addq $0x18, %r14
addq $0x18, %r11
cmpq %rbx, %r10
jne 0x6254
movq %rcx, %r12
movq %rbp, %r13
movq %rsi, %rdx
movb -0x29(%rsp), %sil
jmp 0x6318
xorpd %xmm3, %xmm3
subsd (%rdx,%r9,8), %xmm3
addsd %xmm3, %xmm3
xorl %eax, %eax
ucomisd %xmm2, %xmm3
seta %r11b
testb %sil, %sil
je 0x6318
movb %r11b, %al
leaq 0x1d8d(%rip), %rcx      # 0x80a0
movsd (%rcx,%rax,8), %xmm3
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 %r12, %r9
jne 0x618f
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq