// File: /workspace/github_cpp_makefile_star2_O3/thunlp[P]KB2E/TransR/Train_TransR.cpp
// Function: Train::calc_sum(int, int, int, int)
double calc_sum(int e1,int e2,int rel,int same)
    {
    	vector<double> e1_vec;
        e1_vec.resize(m);
        vector<double> e2_vec;
        e2_vec.resize(m);
        for (int ii=0; ii<m; ii++)
        {
            for (int jj=0; jj<n; jj++)
            {
                e1_vec[ii]+=A[rel][jj][ii]*entity_vec[e1][jj];
                e2_vec[ii]+=A[rel][jj][ii]*entity_vec[e2][jj];
            }
        }
        double sum=0;
        if (L1_flag)
        	for (int ii=0; ii<m; ii++)
            	sum+=fabs(e2_vec[ii]-e1_vec[ii]-same*relation_vec[rel][ii]);
        else
        	for (int ii=0; ii<m; ii++)
            	sum+=sqr(e2_vec[ii]-e1_vec[ii]-same*relation_vec[rel][ii]);
        return sum;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, %ebx
movl %ecx, %r12d
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %r14
xorpd %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x34(%r14), %rsi
callq 0x45d0
leaq 0x30(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x34(%r14), %rsi
callq 0x45d0
movslq 0x34(%r14), %rax
testq %rax, %rax
jle 0x5fe7
movl %ebx, 0x8(%rsp)
movl 0x30(%r14), %edx
movslq %r12d, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (,%rcx,8), %rsi
addq 0x100(%r14), %rsi
movslq %r15d, %rdi
movq 0xb8(%r14), %r9
leaq (%rdi,%rdi,2), %rdi
leaq (%r9,%rdi,8), %rdi
movq 0x10(%rsp), %r8
movslq %ebp, %r10
leaq (%r10,%r10,2), %r10
leaq (%r9,%r10,8), %r9
movq 0x30(%rsp), %r10
xorl %r11d, %r11d
testl %edx, %edx
jle 0x5f72
movq (%rsi), %r15
movq (%rdi), %r12
movq (%r9), %r13
xorl %ebp, %ebp
movq (%r15), %rbx
movsd (%rbx,%r11,8), %xmm0
mulsd (%r12,%rbp,8), %xmm0
addsd (%r8,%r11,8), %xmm0
movsd %xmm0, (%r8,%r11,8)
movsd (%rbx,%r11,8), %xmm0
mulsd (%r13,%rbp,8), %xmm0
addsd (%r10,%r11,8), %xmm0
movsd %xmm0, (%r10,%r11,8)
incq %rbp
addq $0x18, %r15
cmpq %rbp, %rdx
jne 0x5f32
incq %r11
cmpq %rax, %r11
jne 0x5f23
movq 0x30(%rsp), %rdi
cmpb $0x0, 0x621a(%rip)      # 0xc1a0
je 0x5fee
testl %eax, %eax
movl 0x8(%rsp), %edx
jle 0x6041
cvtsi2sd %edx, %xmm4
movq 0x10(%rsp), %rdx
movq 0xa0(%r14), %rsi
xorpd 0x20a4(%rip), %xmm4     # 0x8050
movq (%rsi,%rcx,8), %rcx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movapd 0x20d2(%rip), %xmm1     # 0x8090
movsd (%rdi,%rsi,8), %xmm2
subsd (%rdx,%rsi,8), %xmm2
movsd (%rcx,%rsi,8), %xmm3
mulsd %xmm4, %xmm3
addsd %xmm2, %xmm3
andpd %xmm1, %xmm3
addsd %xmm3, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x5fbe
jmp 0x604a
movq 0x30(%rsp), %rdi
jmp 0x6041
testl %eax, %eax
movl 0x8(%rsp), %esi
jle 0x6041
movq 0x10(%rsp), %rdx
cvtsi2sd %esi, %xmm3
movq 0xa0(%r14), %rsi
movq (%rsi,%rcx,8), %rcx
xorpd 0x203e(%rip), %xmm3     # 0x8050
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd (%rdi,%rsi,8), %xmm1
subsd (%rdx,%rsi,8), %xmm1
movsd (%rcx,%rsi,8), %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x6018
jmp 0x604a
xorpd %xmm0, %xmm0
testq %rdi, %rdi
je 0x6063
movsd %xmm0, 0x8(%rsp)
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movsd 0x8(%rsp), %xmm0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x6086
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
movsd %xmm0, 0x8(%rsp)
callq 0x21d0
movsd 0x8(%rsp), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x60b4
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x60b4
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x60cb
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x22e0
nop