// File: /workspace/github_cpp_makefile_star2_O3/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 0xc(%rsp), %rsi
movl %ecx, (%rsi)
leaq 0x363c4(%rip), %rdi     # 0x3cf50
callq 0x3c96
movslq 0x6c(%rbx), %rcx
movq %rcx, 0x40(%rsp)
testq %rcx, %rcx
jle 0x6e3f
movslq (%rax), %rcx
movl 0x68(%rbx), %eax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x168(%rbx), %rdx
addq %rcx, %rdx
movq %rdx, 0x10(%rsp)
movslq %r15d, %rdi
movq 0xf0(%rbx), %rsi
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %r8
leaq (%rsi,%r8), %r15
movslq %r14d, %rdi
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rdi, %rsi
movslq 0xc(%rsp), %r9
movq 0xd8(%rbx), %r10
shlq $0x3, %r9
leaq (%r9,%r9,2), %r9
movq (%r10,%r9), %rdx
movq %rdx, 0x38(%rsp)
movq 0x108(%rbx), %r10
movq (%r10,%rcx), %rdx
movq %rdx, 0x30(%rsp)
movb 0x5591(%rip), %dl       # 0xc1a8
movb %dl, 0xb(%rsp)
cvtsi2sd %ebp, %xmm0
movq 0x180(%rbx), %rdx
addq %rcx, %rdx
movq %rdx, 0x20(%rsp)
movq 0x138(%rbx), %rdx
addq %rdx, %r8
movq %r8, 0x28(%rsp)
addq %rdi, %rdx
movq %rdx, 0x18(%rsp)
movq 0x120(%rbx), %rdi
movq (%rdi,%r9), %r12
movq 0x150(%rbx), %rdi
movq (%rdi,%rcx), %r13
xorl %ebp, %ebp
movsd 0x13bb(%rip), %xmm1     # 0x8020
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
testl %eax, %eax
jle 0x6cbf
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq (%r15), %rdi
movq (%rsi), %r9
xorpd %xmm3, %xmm3
xorl %r10d, %r10d
movq (%rcx), %r11
movsd (%r11,%rbp,8), %xmm4
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
movsd (%r9,%r10,8), %xmm5
movhpd (%rdi,%r10,8), %xmm5    # xmm5 = xmm5[0],mem[0]
mulpd %xmm4, %xmm5
addpd %xmm5, %xmm3
incq %r10
addq $0x18, %rcx
cmpq %r10, %rax
jne 0x6c86
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
subsd %xmm4, %xmm3
movsd 0x60(%rbx), %xmm4
movq 0x38(%rsp), %rcx
movsd (%rcx,%rbp,8), %xmm5
mulsd %xmm4, %xmm5
subsd %xmm5, %xmm3
movapd %xmm1, %xmm5
subsd %xmm4, %xmm5
movq 0x30(%rsp), %rcx
mulsd (%rcx,%rbp,8), %xmm5
subsd %xmm5, %xmm3
addsd %xmm3, %xmm3
xorl %ecx, %ecx
ucomisd %xmm2, %xmm3
seta %dil
cmpb $0x0, 0xb(%rsp)
je 0x6d10
movb %dil, %cl
leaq 0x1395(%rip), %rdx      # 0x80a0
movsd (%rdx,%rcx,8), %xmm3
testl %eax, %eax
jle 0x6dde
movq %r15, %rdx
movq (%r15), %rdi
movq (%rsi), %r14
movq 0x20(%rsp), %rcx
movq (%rcx), %r15
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq 0x28(%rsp), %r8
movq (%r8), %r9
movq 0x18(%rsp), %r8
movq (%r8), %r10
xorl %r11d, %r11d
movsd (%rdi,%r11,8), %xmm4
subsd (%r14,%r11,8), %xmm4
movq (%r15), %r8
movsd (%r8,%rbp,8), %xmm5
movsd 0x80(%rbx), %xmm6
mulsd %xmm0, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, (%r8,%rbp,8)
movq (%rcx), %r8
movsd 0x80(%rbx), %xmm4
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm4
mulsd (%r8,%rbp,8), %xmm4
movsd (%r9,%r11,8), %xmm5
subsd %xmm4, %xmm5
movsd %xmm5, (%r9,%r11,8)
movsd 0x80(%rbx), %xmm4
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm4
mulsd (%r8,%rbp,8), %xmm4
addsd (%r10,%r11,8), %xmm4
movsd %xmm4, (%r10,%r11,8)
incq %r11
addq $0x18, %r15
addq $0x18, %rcx
cmpq %r11, %rax
jne 0x6d44
movsd 0x60(%rbx), %xmm4
movq %rdx, %r15
movsd (%r12,%rbp,8), %xmm5
movsd 0x80(%rbx), %xmm6
mulsd %xmm0, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, (%r12,%rbp,8)
movapd %xmm1, %xmm4
subsd 0x60(%rbx), %xmm4
movsd (%r13,%rbp,8), %xmm5
movsd 0x80(%rbx), %xmm6
mulsd %xmm0, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm6
subsd %xmm6, %xmm5
movsd %xmm5, (%r13,%rbp,8)
incq %rbp
cmpq 0x40(%rsp), %rbp
jne 0x6c69
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq