// File: /workspace/github_cpp_makefile_star2_O2/thunlp[P]KB2E/CTransR/Train_CTransR.cpp
// Function: Train::calc_sum(int, int, int)
double calc_sum(int e1,int e2,int rel)
    {
        int fb_rel = cluster2fb[rel];
    	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[fb_rel][jj][ii]*entity_vec[e1][jj];
                e2_vec[ii]+=A[fb_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]-relation_vec[rel][ii]*cluster_rate-(1-cluster_rate)*fb_relation_vec[fb_rel][ii]);
        else
        	for (int ii=0; ii<m; ii++)
            	sum+=sqr(e2_vec[ii]-e1_vec[ii]-relation_vec[rel][ii]*cluster_rate-(1-cluster_rate)*fb_relation_vec[fb_rel][ii]);
        return sum;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
leaq 0xc(%rsp), %rsi
movl %ecx, (%rsi)
leaq 0x36e42(%rip), %rdi     # 0x3cf50
callq 0x3736
movslq (%rax), %r15
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movslq 0x6c(%rbx), %rsi
callq 0x4624
leaq 0x10(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movslq 0x6c(%rbx), %rsi
callq 0x4624
movl 0x68(%rbx), %edx
movl 0x6c(%rbx), %ecx
xorl %esi, %esi
testl %edx, %edx
cmovlel %esi, %edx
movslq %r14d, %rdi
testl %ecx, %ecx
cmovlel %esi, %ecx
movslq %ebp, %r8
imulq $0x18, %r15, %r10
imulq $0x18, %rdi, %rax
movq %rax, (%rsp)
imulq $0x18, %r8, %r8
cmpq %rcx, %rsi
je 0x6203
movq 0x168(%rbx), %r9
movq %r10, %rdi
addq %r10, %r9
movq 0xf0(%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 0x61f8
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 0x61ac
incq %rsi
movq %rdi, %r10
jmp 0x6174
movq 0x10(%rsp), %rdx
movq 0x30(%rsp), %rsi
movslq 0xc(%rsp), %rdi
imulq $0x18, %rdi, %rdi
addq 0xd8(%rbx), %rdi
movsd 0x60(%rbx), %xmm0
movsd 0x1df6(%rip), %xmm1     # 0x8020
subsd %xmm0, %xmm1
xorpd 0x1e2a(%rip), %xmm1     # 0x8060
addq 0x108(%rbx), %r10
cmpb $0x0, 0x5f64(%rip)      # 0xc1a8
je 0x6299
xorpd %xmm5, %xmm5
xorl %r8d, %r8d
movapd 0x1e2b(%rip), %xmm2     # 0x8080
cmpq %r8, %rcx
je 0x62e0
movsd (%rdx,%r8,8), %xmm3
subsd (%rsi,%r8,8), %xmm3
movq (%rdi), %rax
movsd (%rax,%r8,8), %xmm4
mulsd %xmm0, %xmm4
subsd %xmm4, %xmm3
movq (%r10), %rax
movsd (%rax,%r8,8), %xmm4
mulsd %xmm1, %xmm4
addsd %xmm3, %xmm4
andpd %xmm2, %xmm4
addsd %xmm4, %xmm5
incq %r8
jmp 0x6255
xorpd %xmm4, %xmm4
xorl %r8d, %r8d
cmpq %r8, %rcx
je 0x62e7
movsd (%rdx,%r8,8), %xmm2
subsd (%rsi,%r8,8), %xmm2
movq (%rdi), %rax
movsd (%rax,%r8,8), %xmm3
mulsd %xmm0, %xmm3
subsd %xmm3, %xmm2
movq (%r10), %rax
movsd (%rax,%r8,8), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm4
incq %r8
jmp 0x62a0
movsd %xmm5, (%rsp)
jmp 0x62ec
movsd %xmm4, (%rsp)
leaq 0x10(%rsp), %rdi
callq 0x3fd0
leaq 0x30(%rsp), %rdi
callq 0x3fd0
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 0x3fd0
jmp 0x6326
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3fd0
movq %rbx, %rdi
callq 0x22d0