// File: thunlp[P]KB2E/TransE/Train_TransE.cpp
// Function: Train::gradient(int, int, int, int, int, int)
void gradient(int e1_a,int e2_a,int rel_a,int e1_b,int e2_b,int rel_b)
    {
        for (int ii=0; ii<n; ii++)
        {

            double x = 2*(entity_vec[e2_a][ii]-entity_vec[e1_a][ii]-relation_vec[rel_a][ii]);
            if (L1_flag)
            	if (x>0)
            		x=1;
            	else
            		x=-1;
            relation_tmp[rel_a][ii]-=-1*rate*x;
            entity_tmp[e1_a][ii]-=-1*rate*x;
            entity_tmp[e2_a][ii]+=-1*rate*x;
            x = 2*(entity_vec[e2_b][ii]-entity_vec[e1_b][ii]-relation_vec[rel_b][ii]);
            if (L1_flag)
            	if (x>0)
            		x=1;
            	else
            		x=-1;
            relation_tmp[rel_b][ii]-=rate*x;
            entity_tmp[e1_b][ii]-=rate*x;
            entity_tmp[e2_b][ii]+=rate*x;
        }
    }

// Assembly:
subq $0xb8, %rsp
movl 0xc0(%rsp), %eax
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, 0x88(%rsp)
movl $0x0, 0x98(%rsp)
movq 0x88(%rsp), %rcx
movl 0x98(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0xc856
movq 0x88(%rsp), %rdi
addq $0xe0, %rdi
movslq 0xa8(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x78(%rsp)
addq $0xe0, %rdi
movslq 0xac(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movsd 0x78(%rsp), %xmm0
movq 0x88(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0x80(%rsp)
addq $0xc8, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movsd 0x80(%rsp), %xmm1
subsd (%rax), %xmm1
movsd 0x5bdc(%rip), %xmm0     # 0x12010
mulsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
testb $0x1, 0xddd8(%rip)      # 0x1a220
je 0xc482
movsd 0x90(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc46f
movsd 0x5bbc(%rip), %xmm0     # 0x12020
movsd %xmm0, 0x90(%rsp)
jmp 0xc480
movsd 0x5ba1(%rip), %xmm0     # 0x12018
movsd %xmm0, 0x90(%rsp)
jmp 0xc482
movq 0x88(%rsp), %rdi
movsd 0x5b86(%rip), %xmm0     # 0x12018
mulsd 0x50(%rdi), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
addq $0xf8, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movsd 0x38(%rsp), %xmm0
movsd 0x40(%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)
movsd 0x5b05(%rip), %xmm0     # 0x12018
mulsd 0x50(%rdi), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
addq $0x110, %rdi            # imm = 0x110
movslq 0xac(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movsd 0x48(%rsp), %xmm0
movsd 0x50(%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)
movsd 0x5a84(%rip), %xmm0     # 0x12018
mulsd 0x50(%rdi), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
addq $0x110, %rdi            # imm = 0x110
movslq 0xa8(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movsd 0x58(%rsp), %xmm0
movsd 0x60(%rsp), %xmm2
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
addq $0xe0, %rdi
movslq 0x9c(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
addq $0xe0, %rdi
movslq 0xa0(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movsd 0x68(%rsp), %xmm0
movq 0x88(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
addq $0xc8, %rdi
movslq 0xc0(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movsd 0x70(%rsp), %xmm1
subsd (%rax), %xmm1
movsd 0x5972(%rip), %xmm0     # 0x12010
mulsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
testb $0x1, 0xdb6e(%rip)      # 0x1a220
je 0xc6ec
movsd 0x90(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc6d9
movsd 0x5952(%rip), %xmm0     # 0x12020
movsd %xmm0, 0x90(%rsp)
jmp 0xc6ea
movsd 0x5937(%rip), %xmm0     # 0x12018
movsd %xmm0, 0x90(%rsp)
jmp 0xc6ec
movq 0x88(%rsp), %rdi
movsd 0x50(%rdi), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0xf8, %rdi
movslq 0xc0(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
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)
movsd 0x50(%rdi), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0x110, %rdi            # imm = 0x110
movslq 0xa0(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movsd 0x18(%rsp), %xmm0
movsd 0x20(%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)
movsd 0x50(%rdi), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
addq $0x110, %rdi            # imm = 0x110
movslq 0x9c(%rsp), %rsi
callq 0x7fb0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x37d0
movsd 0x28(%rsp), %xmm0
movsd 0x30(%rsp), %xmm2
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0xc366
addq $0xb8, %rsp
retq
nop