// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
movl %ecx, %ebx
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, %r14
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x34(%r14), %rsi
callq 0x45dc
leaq 0x10(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x34(%r14), %rsi
callq 0x45dc
movslq 0x34(%r14), %rax
testq %rax, %rax
jle 0x5eba
movl 0x30(%r14), %ecx
movslq %ebx, %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x3, %rdx
addq 0x100(%r14), %rdx
movslq %r12d, %rsi
movq 0xb8(%r14), %r8
leaq (%rsi,%rsi,2), %rsi
leaq (%r8,%rsi,8), %rsi
movq 0x30(%rsp), %rdi
movslq %r15d, %r9
leaq (%r9,%r9,2), %r9
leaq (%r8,%r9,8), %r8
movq 0x10(%rsp), %r9
xorl %r10d, %r10d
testl %ecx, %ecx
jle 0x5eb2
movq (%rdx), %r11
movq (%rsi), %r15
movq (%r8), %r12
xorl %r13d, %r13d
movq (%r11), %rbp
movsd (%rbp,%r10,8), %xmm0
mulsd (%r15,%r13,8), %xmm0
addsd (%rdi,%r10,8), %xmm0
movsd %xmm0, (%rdi,%r10,8)
movsd (%rbp,%r10,8), %xmm0
mulsd (%r12,%r13,8), %xmm0
addsd (%r9,%r10,8), %xmm0
movsd %xmm0, (%r9,%r10,8)
incq %r13
addq $0x18, %r11
cmpq %r13, %rcx
jne 0x5e71
incq %r10
cmpq %rax, %r10
jne 0x5e61
cmpb $0x0, 0x62df(%rip)      # 0xc1a0
je 0x5f2c
testl %eax, %eax
jle 0x5f89
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rdx
cvtsi2sdl 0x8(%rsp), %xmm4
movslq %ebx, %rsi
movq 0xa0(%r14), %rdi
leaq (%rsi,%rsi,2), %rsi
xorpd 0x215f(%rip), %xmm4     # 0x8050
movq (%rdi,%rsi,8), %rsi
xorpd %xmm0, %xmm0
xorl %edi, %edi
movapd 0x218d(%rip), %xmm1     # 0x8090
movsd (%rcx,%rdi,8), %xmm2
subsd (%rdx,%rdi,8), %xmm2
movsd (%rsi,%rdi,8), %xmm3
mulsd %xmm4, %xmm3
addsd %xmm2, %xmm3
andpd %xmm1, %xmm3
addsd %xmm3, %xmm0
incq %rdi
cmpq %rdi, %rax
jne 0x5f03
jmp 0x5f8d
testl %eax, %eax
jle 0x5f89
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rdx
cvtsi2sdl 0x8(%rsp), %xmm3
movslq %ebx, %rsi
movq 0xa0(%r14), %rdi
leaq (%rsi,%rsi,2), %rsi
movq (%rdi,%rsi,8), %rsi
xorpd 0x20f6(%rip), %xmm3     # 0x8050
xorpd %xmm0, %xmm0
xorl %edi, %edi
movsd (%rcx,%rdi,8), %xmm1
subsd (%rdx,%rdi,8), %xmm1
movsd (%rsi,%rdi,8), %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rdi
cmpq %rdi, %rax
jne 0x5f60
jmp 0x5f8d
xorpd %xmm0, %xmm0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm0, 0x8(%rsp)
je 0x5fb0
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movsd 0x8(%rsp), %xmm0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x5fcd
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
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 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5ffb
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x5ffb
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6012
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x22e0