// File: IdelCoder[P]PTransE-ag/Train_PTransE-pos.cpp
// Function: Train::gradient_kb(int, int, int, double)
void gradient_kb(int e1,int e2,int rel, double belta)
    {
        for (int ii=0; ii<n; ii++)
        {
            // entity_vec vector<vector<double> >
            double x = 2*(entity_vec[e2][ii]-entity_vec[e1][ii]-relation_vec[rel][ii]);
            if (L1_flag)
            	if (x>0)
            		x=1;
            	else
            		x=-1;
            relation_tmp[rel][ii]-=belta*rate*x;
            entity_tmp[e1][ii]-=belta*rate*x;
            entity_tmp[e2][ii]+=belta*rate*x;
        }
    }

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movl %esi, 0x6c(%rsp)
movl %edx, 0x68(%rsp)
movl %ecx, 0x64(%rsp)
movsd %xmm0, 0x58(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0x0, 0x54(%rsp)
movq 0x40(%rsp), %rcx
movl 0x54(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0x11646
movq 0x40(%rsp), %rdi
addq $0xf8, %rdi
movslq 0x68(%rsp), %rsi
callq 0xbb00
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x4890
movq 0x40(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
addq $0xf8, %rdi
movslq 0x6c(%rsp), %rsi
callq 0xbb00
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x4890
movsd 0x30(%rsp), %xmm0
movq 0x40(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
addq $0xe0, %rdi
movslq 0x64(%rsp), %rsi
callq 0xbb00
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x4890
movsd 0x38(%rsp), %xmm1
subsd (%rax), %xmm1
movsd 0x8b5c(%rip), %xmm0     # 0x1a010
mulsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
testb $0x1, 0x13d43(%rip)     # 0x25208
je 0x114f6
movsd 0x48(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x114e6
movsd 0x8b42(%rip), %xmm0     # 0x1a020
movsd %xmm0, 0x48(%rsp)
jmp 0x114f4
movsd 0x8b2a(%rip), %xmm0     # 0x1a018
movsd %xmm0, 0x48(%rsp)
jmp 0x114f6
movq 0x40(%rsp), %rdi
movsd 0x58(%rsp), %xmm0
mulsd 0x58(%rdi), %xmm0
movsd %xmm0, (%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
addq $0x110, %rdi            # imm = 0x110
movslq 0x64(%rsp), %rsi
callq 0xbb00
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x4890
movsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movq 0x40(%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 0x58(%rsp), %xmm0
mulsd 0x58(%rdi), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
addq $0x128, %rdi            # imm = 0x128
movslq 0x6c(%rsp), %rsi
callq 0xbb00
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x4890
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm2
movq 0x40(%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 0x58(%rsp), %xmm0
mulsd 0x58(%rdi), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
addq $0x128, %rdi            # imm = 0x128
movslq 0x68(%rsp), %rsi
callq 0xbb00
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x4890
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm2
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x1140d
addq $0x78, %rsp
retq
nopl (%rax,%rax)