// File: 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:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movl %esi, 0xcc(%rsp)
movl %edx, 0xc8(%rsp)
movl %ecx, 0xc4(%rsp)
movl %r8d, 0xc0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x4053d(%rip), %rdi     # 0x4ffc0
leaq 0xc4(%rsp), %rsi
callq 0x4680
movl (%rax), %eax
movl %eax, 0xbc(%rsp)
movl $0x0, 0xb8(%rsp)
movq 0x88(%rsp), %rcx
movl 0xb8(%rsp), %eax
cmpl 0x6c(%rcx), %eax
jge 0x1015a
xorps %xmm0, %xmm0
movsd %xmm0, 0xb0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0xa8(%rsp)
movl $0x0, 0xa4(%rsp)
movq 0x88(%rsp), %rcx
movl 0xa4(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0xfc3f
movq 0x88(%rsp), %rdi
addq $0x168, %rdi            # imm = 0x168
movslq 0xbc(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xb8(%rsp), %rsi
callq 0x3fb0
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x78(%rsp)
addq $0xf0, %rdi
movslq 0xcc(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x3fb0
movsd 0x78(%rsp), %xmm0
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm2
movsd 0xb0(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
addq $0x168, %rdi            # imm = 0x168
movslq 0xbc(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xb8(%rsp), %rsi
callq 0x3fb0
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x80(%rsp)
addq $0xf0, %rdi
movslq 0xc8(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x3fb0
movsd 0x80(%rsp), %xmm0
movsd (%rax), %xmm2
movsd 0xa8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xa8(%rsp)
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0xfadf
movq 0x88(%rsp), %rdi
movsd 0xa8(%rsp), %xmm0
subsd 0xb0(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
addq $0xd8, %rdi
movslq 0xc4(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xb8(%rsp), %rsi
callq 0x3fb0
movsd 0x60(%rsp), %xmm1
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm0
movsd 0x60(%rdi), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x6359(%rip), %xmm0     # 0x16020
subsd 0x60(%rdi), %xmm0
movsd %xmm0, 0x68(%rsp)
addq $0x108, %rdi            # imm = 0x108
movslq 0xbc(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xb8(%rsp), %rsi
callq 0x3fb0
movsd 0x68(%rsp), %xmm1
movsd 0x70(%rsp), %xmm0
movsd (%rax), %xmm2
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x62e3(%rip), %xmm0     # 0x16010
mulsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
testb $0x1, 0xf4df(%rip)      # 0x1f220
je 0xfd7b
movsd 0x98(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xfd68
movsd 0x62c3(%rip), %xmm0     # 0x16020
movsd %xmm0, 0x98(%rsp)
jmp 0xfd79
movsd 0x62a8(%rip), %xmm0     # 0x16018
movsd %xmm0, 0x98(%rsp)
jmp 0xfd7b
movl $0x0, 0x94(%rsp)
movq 0x88(%rsp), %rcx
movl 0x94(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0x10028
movq 0x88(%rsp), %rdi
cvtsi2sdl 0xc0(%rsp), %xmm0
mulsd 0x80(%rdi), %xmm0
mulsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
addq $0xf0, %rdi
movslq 0xcc(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x94(%rsp), %rsi
callq 0x3fb0
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
addq $0xf0, %rdi
movslq 0xc8(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x94(%rsp), %rsi
callq 0x3fb0
movsd 0x28(%rsp), %xmm0
movq 0x88(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
addq $0x180, %rdi            # imm = 0x180
movslq 0xbc(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movslq 0x94(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xb8(%rsp), %rsi
callq 0x3fb0
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm2
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
cvtsi2sdl 0xc0(%rsp), %xmm0
mulsd 0x80(%rdi), %xmm0
mulsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
addq $0x168, %rdi            # imm = 0x168
movslq 0xbc(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movslq 0x94(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xb8(%rsp), %rsi
callq 0x3fb0
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
addq $0x138, %rdi            # imm = 0x138
movslq 0xcc(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x94(%rsp), %rsi
callq 0x3fb0
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm2
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
cvtsi2sdl 0xc0(%rsp), %xmm0
mulsd 0x80(%rdi), %xmm0
mulsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
addq $0x168, %rdi            # imm = 0x168
movslq 0xbc(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movslq 0x94(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xb8(%rsp), %rsi
callq 0x3fb0
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
addq $0x138, %rdi            # imm = 0x138
movslq 0xc8(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x94(%rsp), %rsi
callq 0x3fb0
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0xfd86
movq 0x88(%rsp), %rdi
cvtsi2sdl 0xc0(%rsp), %xmm0
mulsd 0x80(%rdi), %xmm0
mulsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x60(%rdi), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0x120, %rdi            # imm = 0x120
movslq 0xc4(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xb8(%rsp), %rsi
callq 0x3fb0
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
cvtsi2sdl 0xc0(%rsp), %xmm0
mulsd 0x80(%rdi), %xmm0
mulsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x5f3e(%rip), %xmm0     # 0x16020
subsd 0x60(%rdi), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0x150, %rdi            # imm = 0x150
movslq 0xbc(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xb8(%rsp), %rsi
callq 0x3fb0
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm2
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0xb8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb8(%rsp)
jmp 0xfaa4
addq $0xd8, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)