// File: /workspace/github_cpp_makefile_star2_O2/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, 0xc(%rsp)
movl %ecx, %r12d
movl %edx, %r14d
movl %esi, %r15d
movq %rdi, %rbx
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movslq 0x34(%rbx), %rsi
callq 0x4114
leaq 0x10(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movslq 0x34(%rbx), %rsi
callq 0x4114
movl 0x30(%rbx), %edx
movl 0x34(%rbx), %r9d
movslq %r12d, %rcx
xorl %esi, %esi
testl %edx, %edx
cmovlel %esi, %edx
movslq %r15d, %rdi
testl %r9d, %r9d
cmovlel %esi, %r9d
movslq %r14d, %r8
imulq $0x18, %rcx, %rcx
imulq $0x18, %rdi, %rax
movq %rax, (%rsp)
imulq $0x18, %r8, %r8
cmpq %r9, %rsi
je 0x5986
movq %r9, %rdi
movq 0x100(%rbx), %r9
addq %rcx, %r9
movq 0xb8(%rbx), %r10
movq (%rsp), %rax
leaq (%r10,%rax), %r11
movq 0x30(%rsp), %r14
addq %r8, %r10
movq 0x10(%rsp), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpq %r13, %rdx
je 0x597b
movq (%r9), %rbp
movq (%rbp,%r12), %rbp
movsd (%rbp,%rsi,8), %xmm0
movq (%r11), %rax
mulsd (%rax,%r13,8), %xmm0
addsd (%r14,%rsi,8), %xmm0
movsd %xmm0, (%r14,%rsi,8)
movsd (%rbp,%rsi,8), %xmm0
movq (%r10), %rax
mulsd (%rax,%r13,8), %xmm0
addsd (%r15,%rsi,8), %xmm0
movsd %xmm0, (%r15,%rsi,8)
incq %r13
addq $0x18, %r12
jmp 0x592f
incq %rsi
movq %rdi, %r9
jmp 0x58f7
movq 0x10(%rsp), %rdx
movq 0x30(%rsp), %rsi
cvtsi2sdl 0xc(%rsp), %xmm0
xorpd 0x16b2(%rip), %xmm0     # 0x7050
addq 0xa0(%rbx), %rcx
cmpb $0x0, 0x57fc(%rip)      # 0xb1a8
je 0x59e8
xorpd %xmm4, %xmm4
xorl %edi, %edi
movapd 0x16c4(%rip), %xmm1     # 0x7080
cmpq %rdi, %r9
je 0x5a1a
movsd (%rdx,%rdi,8), %xmm2
subsd (%rsi,%rdi,8), %xmm2
movq (%rcx), %rax
movsd (%rax,%rdi,8), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
andpd %xmm1, %xmm3
addsd %xmm3, %xmm4
incq %rdi
jmp 0x59bc
xorpd %xmm3, %xmm3
xorl %edi, %edi
cmpq %rdi, %r9
je 0x5a21
movsd (%rdx,%rdi,8), %xmm1
subsd (%rsi,%rdi,8), %xmm1
movq (%rcx), %rax
movsd (%rax,%rdi,8), %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm3
incq %rdi
jmp 0x59ee
movsd %xmm4, (%rsp)
jmp 0x5a26
movsd %xmm3, (%rsp)
leaq 0x10(%rsp), %rdi
callq 0x3c54
leaq 0x30(%rsp), %rdi
callq 0x3c54
movsd (%rsp), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3c54
jmp 0x5a60
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3c54
movq %rbx, %rdi
callq 0x22d0