// File: /workspace/github_cpp_makefile_star2_O2/IdelCoder[P]PTransE-ag/Test_TransE_path.cpp
// Function: Test::calc_sum(int, int, int)
double calc_sum(int e1,int e2,int rel)
    {
        double sum=0;
        if (L1_flag)
        	for (int ii=0; ii<n; ii++)
            sum+=-fabs(entity_vec[e2][ii]-entity_vec[e1][ii]-relation_vec[rel][ii]);
        else
        for (int ii=0; ii<n; ii++)
            sum+=-sqr(entity_vec[e2][ii]-entity_vec[e1][ii]-relation_vec[rel][ii]);
        if (L1_flag)
        	for (int ii=0; ii<n; ii++)
            sum+=-fabs(entity_vec[e1][ii]-entity_vec[e2][ii]-relation_vec[rel+relation_num][ii]);
        else
        for (int ii=0; ii<n; ii++)
            sum+=-sqr(entity_vec[e1][ii]-entity_vec[e2][ii]-relation_vec[rel+relation_num][ii]);
		int h = e1;
		int l = e2;
		//used = "0";
		if (used=="1")
		{
			//cout<<"Here"<<endl;
			vector<pair<vector<int>,double> > path_list = fb_path[make_pair(h,l)];
			if (path_list.size()>0)
			{
				for (int path_id = 0; path_id<path_list.size(); path_id++)
				{
					vector<int> rel_path = path_list[path_id].first;

					double pr_path = 0;
					double pr = path_list[path_id].second;
					string  s;
				    ostringstream oss;//创建一个流
					for (int ii=0; ii<rel_path.size(); ii++)
					{
						oss<<rel_path[ii]<<" ";
					}
				    s=oss.str();//
					if (path_confidence.count(make_pair(s,rel))>0)
						pr_path = path_confidence[make_pair(s,rel)];
					//pr_path = 1;
					sum+=calc_path(rel,rel_path)*pr*pr_path;
				}
			}
			path_list = fb_path[make_pair(l,h)];
			if (path_list.size()>0)
			{
				for (int path_id = 0; path_id<path_list.size(); path_id++)
				{
					vector<int> rel_path = path_list[path_id].first;
					double pr = path_list[path_id].second;
					double pr_path = 0;
					string  s;
				    ostringstream oss;//创建一个流
					for (int ii=0; ii<rel_path.size(); ii++)
					{
						oss<<rel_path[ii]<<" ";
					}
				    s=oss.str();//
					if (path_confidence.count(make_pair(s,rel+relation_num))>0)
						pr_path = path_confidence[make_pair(s,rel+relation_num)];
					//pr_path = 1;
					sum+=calc_path(rel+relation_num,rel_path)*pr*pr_path;
				}
			}
		}
        return sum;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %edx, %r14d
movl %esi, %ebp
movb 0x956f(%rip), %sil      # 0x101c0
movl 0x956c(%rip), %r12d     # 0x101c4
movslq %edx, %rdx
movq (%rdi), %rax
movq %rdi, 0x28(%rsp)
movq 0x18(%rdi), %r8
imulq $0x18, %rdx, %r15
addq %r8, %r15
movslq %ebp, %rdx
imulq $0x18, %rdx, %rdx
addq %r8, %rdx
movl %ecx, 0x4(%rsp)
movslq %ecx, %r8
imulq $0x18, %r8, %r9
addq %rax, %r9
xorl %r10d, %r10d
testl %r12d, %r12d
cmovgl %r12d, %r10d
xorpd %xmm2, %xmm2
xorl %r11d, %r11d
testb %sil, %sil
je 0x6cd1
movapd 0x33ac(%rip), %xmm0     # 0xa050
cmpq %r11, %r10
je 0x6cfe
movq (%r15), %rbx
movsd (%rbx,%r11,8), %xmm1
movq (%rdx), %rbx
subsd (%rbx,%r11,8), %xmm1
movq (%r9), %rbx
subsd (%rbx,%r11,8), %xmm1
andpd %xmm0, %xmm1
subsd %xmm1, %xmm2
incq %r11
jmp 0x6ca4
cmpq %r11, %r10
je 0x6cfe
movq (%r15), %rbx
movsd (%rbx,%r11,8), %xmm0
movq (%rdx), %rbx
subsd (%rbx,%r11,8), %xmm0
movq (%r9), %rbx
subsd (%rbx,%r11,8), %xmm0
mulsd %xmm0, %xmm0
subsd %xmm0, %xmm2
incq %r11
jmp 0x6cd1
movslq 0x9753(%rip), %r9       # 0x10458
addq %r8, %r9
imulq $0x18, %r9, %r8
addq %r8, %rax
xorl %r8d, %r8d
testl %r12d, %r12d
cmovgl %r12d, %r8d
testb %sil, %sil
je 0x6d52
xorl %esi, %esi
movapd 0x3328(%rip), %xmm0     # 0xa050
cmpq %rsi, %r8
je 0x6d7e
movq (%rdx), %rdi
movsd (%rdi,%rsi,8), %xmm1
movq (%r15), %rdi
subsd (%rdi,%rsi,8), %xmm1
movq (%rax), %rdi
subsd (%rdi,%rsi,8), %xmm1
andpd %xmm0, %xmm1
subsd %xmm1, %xmm2
incq %rsi
jmp 0x6d28
xorl %esi, %esi
cmpq %rsi, %r8
je 0x6d7e
movq (%rdx), %rdi
movsd (%rdi,%rsi,8), %xmm0
movq (%r15), %rdi
subsd (%rdi,%rsi,8), %xmm0
movq (%rax), %rdi
subsd (%rdi,%rsi,8), %xmm0
mulsd %xmm0, %xmm0
subsd %xmm0, %xmm2
incq %rsi
jmp 0x6d54
movsd %xmm2, 0x8(%rsp)
leaq 0x945d(%rip), %rdi      # 0x101e8
leaq 0x32fe(%rip), %rsi      # 0xa090
callq 0x3ae6
testb %al, %al
je 0x71e7
movq 0x28(%rsp), %rax
leaq 0xc0(%rax), %rbx
shlq $0x20, %r14
movl %ebp, %r15d
orq %r14, %r15
leaq 0xe0(%rsp), %rsi
movq %r15, (%rsi)
movq %rbx, %rdi
callq 0x601c
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x3d0e
movq (%r14), %rsi
movq 0x8(%r14), %rax
cmpq %rsi, %rax
je 0x6fc9
movq %r15, 0x80(%rsp)
movq %rbx, 0x10(%rsp)
xorl %ebx, %ebx
leaq 0x68(%rsp), %r12
leaq 0xe0(%rsp), %r13
leaq 0x33aa(%rip), %rbp      # 0xa1b5
leaq 0x88(%rsp), %r15
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rbx, %rax
jbe 0x6fbc
movq %r12, %rdi
movq %rbx, %r12
shlq $0x5, %r12
addq %r12, %rsi
movq %rdi, %r14
callq 0x5ef8
movq 0x50(%rsp), %rax
movsd 0x18(%rax,%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
movq %r13, %rdi
callq 0x2210
xorl %r12d, %r12d
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r12, %rcx
jbe 0x6e9c
movl (%rax,%r12,4), %esi
movq %r13, %rdi
callq 0x22d0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2190
incq %r12
jmp 0x6e6a
movq %r15, %rdi
leaq 0xe8(%rsp), %rsi
callq 0x2280
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x21f0
movq %r15, %rdi
callq 0x2368
movq %r15, %rdi
movq %r12, %rsi
callq 0x2220
movl 0x4(%rsp), %eax
movl %eax, 0xa8(%rsp)
leaq 0x9327(%rip), %rdi      # 0x10208
movq %r15, %rsi
callq 0x77a6
movq %rax, %r12
movq %r15, %rdi
callq 0x2368
testq %r12, %r12
je 0x6f37
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x2220
movq %r14, %r12
movl 0x4(%rsp), %eax
movl %eax, 0xa8(%rsp)
leaq 0x92ed(%rip), %rdi      # 0x10208
movq %r15, %rsi
callq 0x3efa
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
callq 0x2368
jmp 0x6f44
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r14, %r12
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x5ef8
movq 0x28(%rsp), %rdi
movl 0x4(%rsp), %esi
movq %r14, %rdx
callq 0x77c0
movsd 0x20(%rsp), %xmm1
mulsd %xmm0, %xmm1
mulsd 0x18(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0x5f46
movq %r13, %rdi
callq 0x2070
leaq 0x30(%rsp), %rdi
callq 0x2368
movq %r12, %rdi
callq 0x5f46
incq %rbx
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rax
jmp 0x6e13
movq 0x10(%rsp), %rbx
movq 0x80(%rsp), %r15
rolq $0x20, %r15
leaq 0xe0(%rsp), %rsi
movq %r15, (%rsi)
movq %rbx, %rdi
callq 0x601c
leaq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x6082
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rax
cmpq %rsi, %rax
je 0x71dd
xorl %r14d, %r14d
leaq 0x68(%rsp), %r15
leaq 0xe0(%rsp), %r13
leaq 0x319e(%rip), %rbp      # 0xa1b5
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r14, %rax
jbe 0x71dd
movq %r14, %rbx
shlq $0x5, %rbx
addq %rbx, %rsi
movq %r15, %rdi
callq 0x5ef8
movq 0x50(%rsp), %rax
movsd 0x18(%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
movq %r13, %rdi
callq 0x2210
xorl %ebx, %ebx
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbx, %rcx
jbe 0x709a
movl (%rax,%rbx,4), %esi
movq %r13, %rdi
callq 0x22d0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2190
incq %rbx
jmp 0x7069
movq %r14, 0x18(%rsp)
leaq 0x88(%rsp), %r14
movq %r14, %rdi
leaq 0xe8(%rsp), %rsi
callq 0x2280
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x21f0
movq %r14, %rdi
callq 0x2368
movl 0x9383(%rip), %ebx      # 0x10458
movq %r14, %rdi
movq %r12, %rsi
callq 0x2220
addl 0x4(%rsp), %ebx
movl %ebx, 0xa8(%rsp)
leaq 0x9116(%rip), %rdi      # 0x10208
movq %r14, %rsi
callq 0x77a6
movq %rax, %r12
movq %r14, %rdi
callq 0x2368
testq %r12, %r12
je 0x714b
movl 0x9348(%rip), %ebx      # 0x10458
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
callq 0x2220
addl 0x4(%rsp), %ebx
movl %ebx, 0xa8(%rsp)
leaq 0x90d9(%rip), %rdi      # 0x10208
movq %r14, %rsi
callq 0x3efa
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0x2368
jmp 0x7155
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x92fc(%rip), %r12d     # 0x10458
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x5ef8
addl 0x4(%rsp), %r12d
movq 0x28(%rsp), %rdi
movl %r12d, %esi
movq %r14, %rdx
callq 0x77c0
movsd 0x20(%rsp), %xmm1
mulsd %xmm0, %xmm1
mulsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0x5f46
movq %r13, %rdi
callq 0x2070
leaq 0x30(%rsp), %rdi
callq 0x2368
movq %r15, %rdi
callq 0x5f46
movq 0x18(%rsp), %r14
incq %r14
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rax
jmp 0x7017
leaq 0x50(%rsp), %rdi
callq 0x3d62
movsd 0x8(%rsp), %xmm0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7232
jmp 0x7239
jmp 0x7217
jmp 0x7217
jmp 0x7239
jmp 0x7239
jmp 0x7239
jmp 0x7239
jmp 0x7217
jmp 0x7232
jmp 0x722d
jmp 0x7239
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x2368
jmp 0x723c
jmp 0x7239
jmp 0x7239
movq %rax, %rbx
jmp 0x7249
movq %rax, %rbx
jmp 0x725d
jmp 0x7239
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x2070
leaq 0x30(%rsp), %rdi
callq 0x2368
leaq 0x68(%rsp), %rdi
callq 0x5f46
leaq 0x50(%rsp), %rdi
callq 0x3d62
movq %rbx, %rdi
callq 0x22e0
nop