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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, %ebp
movl %edx, %r14d
movl %esi, %r15d
movq %rdi, %rbx
leaq 0x44(%rsp), %r12
movl %ecx, (%r12)
leaq 0x36bb2(%rip), %rdi     # 0x3cf50
movq %r12, %rsi
callq 0x3736
movslq (%rax), %rcx
movl 0x68(%rbx), %eax
movl 0x6c(%rbx), %r8d
movslq %r15d, %rdx
movslq %r14d, %rsi
movslq (%r12), %rdi
imulq $0x18, %rdi, %rdi
movq 0xd8(%rbx), %r9
addq %rdi, %r9
movq %r9, 0x28(%rsp)
imulq $0x18, %rcx, %rcx
movq 0x108(%rbx), %r9
addq %rcx, %r9
movq %r9, 0x20(%rsp)
movb 0x5dc1(%rip), %r9b      # 0xc1a8
movb %r9b, 0xf(%rsp)
cvtsi2sd %ebp, %xmm0
addq 0x120(%rbx), %rdi
movq %rdi, 0x30(%rsp)
movq 0x150(%rbx), %rdi
movq %rcx, 0x10(%rsp)
addq %rcx, %rdi
movq %rdi, 0x18(%rsp)
xorl %r11d, %r11d
testl %eax, %eax
cmovlel %r11d, %eax
testl %r8d, %r8d
cmovlel %r11d, %r8d
movq %r8, 0x38(%rsp)
imulq $0x18, %rdx, %r14
imulq $0x18, %rsi, %r15
movsd 0x1beb(%rip), %xmm1     # 0x8020
xorpd %xmm2, %xmm2
cmpq 0x38(%rsp), %r11
je 0x6627
movq 0x168(%rbx), %r13
addq 0x10(%rsp), %r13
movq 0xf0(%rbx), %rbp
leaq (%r14,%rbp), %r12
addq %r15, %rbp
xorpd %xmm4, %xmm4
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x64a2
movq (%r13), %rsi
movq (%rsi,%rcx), %rsi
movq (%r12), %r8
movq (%rbp), %r9
movsd (%rsi,%r11,8), %xmm3
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
movsd (%r8,%rdx,8), %xmm5
movhpd (%r9,%rdx,8), %xmm5     # xmm5 = xmm5[0],mem[0]
mulpd %xmm3, %xmm5
addpd %xmm5, %xmm4
incq %rdx
addq $0x18, %rcx
jmp 0x6466
movapd %xmm4, %xmm3
unpckhpd %xmm4, %xmm3            # xmm3 = xmm3[1],xmm4[1]
subsd %xmm4, %xmm3
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
movsd 0x60(%rbx), %xmm4
movsd (%rcx,%r11,8), %xmm5
mulsd %xmm4, %xmm5
subsd %xmm5, %xmm3
movapd %xmm1, %xmm5
subsd %xmm4, %xmm5
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
mulsd (%rcx,%r11,8), %xmm5
subsd %xmm5, %xmm3
addsd %xmm3, %xmm3
xorl %ecx, %ecx
ucomisd %xmm2, %xmm3
seta %dl
testb $0x1, 0xf(%rsp)
je 0x6505
movb %dl, %cl
leaq 0x1b70(%rip), %rdx      # 0x8070
movsd (%rdx,%rcx,8), %xmm3
movq 0x180(%rbx), %r9
addq 0x10(%rsp), %r9
movq 0x138(%rbx), %rsi
leaq (%rsi,%r14), %r8
addq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movsd 0x80(%rbx), %xmm4
mulsd %xmm0, %xmm4
cmpq %rcx, %rax
je 0x65c9
movq (%r12), %r10
movsd (%r10,%rcx,8), %xmm5
movq (%rbp), %r10
subsd (%r10,%rcx,8), %xmm5
movq (%r9), %r10
movq (%r10,%rdx), %r10
movsd (%r10,%r11,8), %xmm6
mulsd %xmm3, %xmm4
mulsd %xmm5, %xmm4
subsd %xmm4, %xmm6
movsd %xmm6, (%r10,%r11,8)
movq (%r13), %r10
movq (%r10,%rdx), %r10
movq (%r8), %rdi
movsd (%rdi,%rcx,8), %xmm4
movsd 0x80(%rbx), %xmm5
mulsd %xmm0, %xmm5
mulsd %xmm3, %xmm5
mulsd (%r10,%r11,8), %xmm5
subsd %xmm5, %xmm4
movsd %xmm4, (%rdi,%rcx,8)
movsd 0x80(%rbx), %xmm4
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm4
movq (%rsi), %rdi
mulsd (%r10,%r11,8), %xmm4
addsd (%rdi,%rcx,8), %xmm4
movsd %xmm4, (%rdi,%rcx,8)
incq %rcx
addq $0x18, %rdx
jmp 0x6523
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
movsd (%rcx,%r11,8), %xmm5
mulsd %xmm3, %xmm4
mulsd 0x60(%rbx), %xmm4
subsd %xmm4, %xmm5
movsd %xmm5, (%rcx,%r11,8)
movapd %xmm1, %xmm4
subsd 0x60(%rbx), %xmm4
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movsd (%rcx,%r11,8), %xmm5
movsd 0x80(%rbx), %xmm6
mulsd %xmm0, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, (%rcx,%r11,8)
incq %r11
jmp 0x6439
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq