// File: /workspace/github_cpp_makefile_star2_O1/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 0x4(%rsp), %rsi
movl %ecx, (%rsi)
leaq 0x36658(%rip), %rdi     # 0x3cf50
callq 0x3cc8
movslq (%rax), %r15
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x6c(%rbx), %rsi
callq 0x4c96
leaq 0x10(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x6c(%rbx), %rsi
callq 0x4c96
movslq 0x6c(%rbx), %rax
testq %rax, %rax
jle 0x69de
movl 0x68(%rbx), %ecx
leaq (%r15,%r15,2), %rdx
shlq $0x3, %rdx
addq 0x168(%rbx), %rdx
movslq %r14d, %rsi
movq 0xf0(%rbx), %r8
leaq (%rsi,%rsi,2), %rsi
leaq (%r8,%rsi,8), %rsi
movq 0x30(%rsp), %rdi
movslq %ebp, %r9
leaq (%r9,%r9,2), %r9
leaq (%r8,%r9,8), %r8
movq 0x10(%rsp), %r9
xorl %r10d, %r10d
testl %ecx, %ecx
jle 0x69d6
movq (%rdx), %r11
movq (%rsi), %r14
movq (%r8), %r12
xorl %r13d, %r13d
movq (%r11), %rbp
movsd (%rbp,%r10,8), %xmm0
mulsd (%r14,%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 0x6995
incq %r10
cmpq %rax, %r10
jne 0x6985
cmpb $0x0, 0x57c3(%rip)      # 0xc1a8
je 0x6a85
testl %eax, %eax
jle 0x6b14
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rdx
movslq 0x4(%rsp), %rsi
movq 0xd8(%rbx), %rdi
leaq (%rsi,%rsi,2), %rsi
movq (%rdi,%rsi,8), %rsi
movsd 0x60(%rbx), %xmm5
movsd 0x1602(%rip), %xmm1     # 0x8020
subsd %xmm5, %xmm1
movq 0x108(%rbx), %rdi
leaq (%r15,%r15,2), %r8
xorpd 0x163b(%rip), %xmm1     # 0x8070
movq (%rdi,%r8,8), %rdi
xorpd %xmm0, %xmm0
xorl %r8d, %r8d
movapd 0x1648(%rip), %xmm2     # 0x8090
movsd (%rcx,%r8,8), %xmm3
subsd (%rdx,%r8,8), %xmm3
movsd (%rsi,%r8,8), %xmm4
mulsd %xmm5, %xmm4
subsd %xmm4, %xmm3
movsd (%rdi,%r8,8), %xmm4
mulsd %xmm1, %xmm4
addsd %xmm3, %xmm4
andpd %xmm2, %xmm4
addsd %xmm4, %xmm0
incq %r8
cmpq %r8, %rax
jne 0x6a48
jmp 0x6b18
testl %eax, %eax
jle 0x6b14
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rdx
movslq 0x4(%rsp), %rsi
movq 0xd8(%rbx), %rdi
leaq (%rsi,%rsi,2), %rsi
movq (%rdi,%rsi,8), %rsi
movsd 0x60(%rbx), %xmm4
movsd 0x1568(%rip), %xmm1     # 0x8020
subsd %xmm4, %xmm1
movq 0x108(%rbx), %rdi
leaq (%r15,%r15,2), %r8
movq (%rdi,%r8,8), %rdi
xorpd 0x159d(%rip), %xmm1     # 0x8070
xorpd %xmm0, %xmm0
xorl %r8d, %r8d
movsd (%rcx,%r8,8), %xmm2
subsd (%rdx,%r8,8), %xmm2
movsd (%rsi,%r8,8), %xmm3
mulsd %xmm4, %xmm3
subsd %xmm3, %xmm2
movsd (%rdi,%r8,8), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm0
incq %r8
cmpq %r8, %rax
jne 0x6ada
jmp 0x6b18
xorpd %xmm0, %xmm0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm0, 0x8(%rsp)
je 0x6b3b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
movsd 0x8(%rsp), %xmm0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6b58
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
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 0x6b86
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
jmp 0x6b86
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6b9d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
movq %rbx, %rdi
callq 0x22f0
nop