// File: 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:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movl %esi, 0xec(%rsp)
movl %edx, 0xe8(%rsp)
movl %ecx, 0xe4(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x40b88(%rip), %rdi     # 0x4ffc0
leaq 0xe4(%rsp), %rsi
callq 0x4680
movl (%rax), %eax
movl %eax, 0xe0(%rsp)
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0xaec0
movq 0x78(%rsp), %rax
movq 0x80(%rsp), %rdi
movslq 0x6c(%rax), %rsi
callq 0x8d00
jmp 0xf47b
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0xaec0
movq 0x78(%rsp), %rax
movq 0x70(%rsp), %rdi
movslq 0x6c(%rax), %rsi
callq 0x8d00
jmp 0xf4a2
movl $0x0, 0x9c(%rsp)
movq 0x78(%rsp), %rcx
movl 0x9c(%rsp), %eax
cmpl 0x6c(%rcx), %eax
jge 0xf69d
movl $0x0, 0x98(%rsp)
movq 0x78(%rsp), %rcx
movl 0x98(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0xf685
movq 0x78(%rsp), %rdi
addq $0x168, %rdi            # imm = 0x168
movslq 0xe0(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x9c(%rsp), %rsi
callq 0x3fb0
movq 0x78(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
addq $0xf0, %rdi
movslq 0xec(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x3fb0
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movslq 0x9c(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x3fb0
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movq 0x78(%rsp), %rdi
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
addq $0x168, %rdi            # imm = 0x168
movslq 0xe0(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x9c(%rsp), %rsi
callq 0x3fb0
movq 0x78(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
addq $0xf0, %rdi
movslq 0xe8(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x98(%rsp), %rsi
callq 0x3fb0
movsd (%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movslq 0x9c(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x3fb0
movsd 0x60(%rsp), %xmm0
movsd 0x68(%rsp), %xmm2
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0xf4cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
jmp 0xf9ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x6a70
jmp 0xf9ac
jmp 0xf687
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0xf4ad
xorps %xmm0, %xmm0
movsd %xmm0, 0x90(%rsp)
testb $0x1, 0xfb70(%rip)      # 0x1f220
je 0xf81a
movl $0x0, 0x8c(%rsp)
movq 0x78(%rsp), %rcx
movl 0x8c(%rsp), %eax
cmpl 0x6c(%rcx), %eax
jge 0xf815
movslq 0x8c(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x3fb0
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movslq 0x8c(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x3fb0
movsd 0x30(%rsp), %xmm0
movq 0x78(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
addq $0xd8, %rdi
movslq 0xe4(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x3fb0
movsd 0x38(%rsp), %xmm1
movq 0x78(%rsp), %rdi
movsd (%rax), %xmm0
movsd 0x60(%rdi), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x689c(%rip), %xmm0     # 0x16020
subsd 0x60(%rdi), %xmm0
movsd %xmm0, 0x40(%rsp)
addq $0x108, %rdi            # imm = 0x108
movslq 0xe0(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x3fb0
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd (%rax), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movaps 0x6877(%rip), %xmm1     # 0x16060
pand %xmm1, %xmm0
addsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0xf6c1
jmp 0xf975
movl $0x0, 0x88(%rsp)
movq 0x78(%rsp), %rcx
movl 0x88(%rsp), %eax
cmpl 0x6c(%rcx), %eax
jge 0xf973
movslq 0x88(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x3fb0
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0x88(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x3fb0
movsd 0x10(%rsp), %xmm0
movq 0x78(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
addq $0xd8, %rdi
movslq 0xe4(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x88(%rsp), %rsi
callq 0x3fb0
movsd 0x18(%rsp), %xmm1
movq 0x78(%rsp), %rdi
movsd (%rax), %xmm0
movsd 0x60(%rdi), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x6738(%rip), %xmm0     # 0x16020
subsd 0x60(%rdi), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0x108, %rdi            # imm = 0x108
movslq 0xe0(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x88(%rsp), %rsi
callq 0x3fb0
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd (%rax), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x2a80
addsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movl 0x88(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
jmp 0xf825
jmp 0xf975
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x6a70
leaq 0xc8(%rsp), %rdi
callq 0x6a70
movsd 0x8(%rsp), %xmm0
addq $0xf8, %rsp
retq
leaq 0xc8(%rsp), %rdi
callq 0x6a70
movq 0xc0(%rsp), %rdi
callq 0x23a0
nopw %cs:(%rax,%rax)