// File: 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:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movl %esi, 0xac(%rsp)
movl %edx, 0xa8(%rsp)
movl %ecx, 0xa4(%rsp)
movl %r8d, 0xa0(%rsp)
movl %r9d, 0x9c(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0x98(%rsp)
movq 0x68(%rsp), %rcx
movl 0x98(%rsp), %eax
cmpl 0x34(%rcx), %eax
jge 0xf112
xorps %xmm0, %xmm0
movsd %xmm0, 0x90(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x88(%rsp)
movl $0x0, 0x84(%rsp)
movq 0x68(%rsp), %rcx
movl 0x84(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0xed7f
movq 0x68(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movslq 0xa4(%rsp), %rsi
callq 0x8190
movq %rax, %rdi
movslq 0x84(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x3c80
movq 0x68(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
addq $0xb8, %rdi
movslq 0xac(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x84(%rsp), %rsi
callq 0x3c80
movsd 0x58(%rsp), %xmm0
movq 0x68(%rsp), %rdi
movsd (%rax), %xmm2
movsd 0x90(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
addq $0x100, %rdi            # imm = 0x100
movslq 0xa4(%rsp), %rsi
callq 0x8190
movq %rax, %rdi
movslq 0x84(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x3c80
movq 0x68(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
addq $0xb8, %rdi
movslq 0xa8(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x84(%rsp), %rsi
callq 0x3c80
movsd 0x60(%rsp), %xmm0
movsd (%rax), %xmm2
movsd 0x88(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0xec34
movq 0x68(%rsp), %rdi
movsd 0x88(%rsp), %xmm0
subsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
addq $0xa0, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x3c80
movsd 0x50(%rsp), %xmm1
subsd (%rax), %xmm1
movsd 0x723e(%rip), %xmm0     # 0x16010
mulsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
testb $0x1, 0x1143d(%rip)     # 0x20220
je 0xee14
movsd 0x78(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xee04
movsd 0x7224(%rip), %xmm0     # 0x16020
movsd %xmm0, 0x78(%rsp)
jmp 0xee12
movsd 0x720c(%rip), %xmm0     # 0x16018
movsd %xmm0, 0x78(%rsp)
jmp 0xee14
movl $0x0, 0x74(%rsp)
movq 0x68(%rsp), %rcx
movl 0x74(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0xf076
movq 0x68(%rsp), %rdi
cvtsi2sdl 0xa0(%rsp), %xmm0
mulsd 0x48(%rdi), %xmm0
mulsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0xb8, %rdi
movslq 0xac(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x74(%rsp), %rsi
callq 0x3c80
movq 0x68(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
addq $0xb8, %rdi
movslq 0xa8(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x74(%rsp), %rsi
callq 0x3c80
movsd 0x18(%rsp), %xmm0
movq 0x68(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
addq $0x118, %rdi            # imm = 0x118
movslq 0xa4(%rsp), %rsi
callq 0x8190
movq %rax, %rdi
movslq 0x74(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x3c80
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm2
movq 0x68(%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 0xa0(%rsp), %xmm0
mulsd 0x48(%rdi), %xmm0
mulsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
addq $0x100, %rdi            # imm = 0x100
movslq 0xa4(%rsp), %rsi
callq 0x8190
movq %rax, %rdi
movslq 0x74(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x3c80
movq 0x68(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
addq $0xe8, %rdi
movslq 0xac(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x74(%rsp), %rsi
callq 0x3c80
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm2
movq 0x68(%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 0xa0(%rsp), %xmm0
mulsd 0x48(%rdi), %xmm0
mulsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
addq $0x100, %rdi            # imm = 0x100
movslq 0xa4(%rsp), %rsi
callq 0x8190
movq %rax, %rdi
movslq 0x74(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x3c80
movq 0x68(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
addq $0xe8, %rdi
movslq 0xa8(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x74(%rsp), %rsi
callq 0x3c80
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm2
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0xee1c
movq 0x68(%rsp), %rdi
movl 0x9c(%rsp), %eax
imull 0xa0(%rsp), %eax
cvtsi2sd %eax, %xmm0
mulsd 0x48(%rdi), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0xd0, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x3c80
movsd 0x8(%rsp), %xmm0
movsd 0x10(%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 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0xebfc
addq $0xb8, %rsp
retq
nopw (%rax,%rax)