// File: 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:
subq $0x628, %rsp            # imm = 0x628
movq %rdi, 0x620(%rsp)
movl %esi, 0x61c(%rsp)
movl %edx, 0x618(%rsp)
movl %ecx, 0x614(%rsp)
movq 0x620(%rsp), %rax
movq %rax, 0xf0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x608(%rsp)
testb $0x1, 0x1d221(%rip)     # 0x2d208
je 0x10101
movl $0x0, 0x604(%rsp)
movl 0x604(%rsp), %eax
cmpl 0x1d207(%rip), %eax     # 0x2d20c
jge 0x100fc
movq 0xf0(%rsp), %rdi
addq $0x18, %rdi
movslq 0x618(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x604(%rsp), %rsi
callq 0x4ef0
movq 0xf0(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0xe0(%rsp)
addq $0x18, %rdi
movslq 0x61c(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x604(%rsp), %rsi
callq 0x4ef0
movsd 0xe0(%rsp), %xmm0
movq 0xf0(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0xe8(%rsp)
movslq 0x614(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x604(%rsp), %rsi
callq 0x4ef0
movsd 0xe8(%rsp), %xmm0
subsd (%rax), %xmm0
movaps 0xff97(%rip), %xmm1     # 0x20050
pand %xmm1, %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
addsd 0x608(%rsp), %xmm0
movsd %xmm0, 0x608(%rsp)
movl 0x604(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x604(%rsp)
jmp 0xfff8
jmp 0x1020c
movl $0x0, 0x600(%rsp)
movl 0x600(%rsp), %eax
cmpl 0x1d0f3(%rip), %eax     # 0x2d20c
jge 0x1020a
movq 0xf0(%rsp), %rdi
addq $0x18, %rdi
movslq 0x618(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x600(%rsp), %rsi
callq 0x4ef0
movq 0xf0(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0xd0(%rsp)
addq $0x18, %rdi
movslq 0x61c(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x600(%rsp), %rsi
callq 0x4ef0
movsd 0xd0(%rsp), %xmm0
movq 0xf0(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0xd8(%rsp)
movslq 0x614(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x600(%rsp), %rsi
callq 0x4ef0
movsd 0xd8(%rsp), %xmm0
subsd (%rax), %xmm0
callq 0x2af0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
addsd 0x608(%rsp), %xmm0
movsd %xmm0, 0x608(%rsp)
movl 0x600(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x600(%rsp)
jmp 0x1010c
jmp 0x1020c
testb $0x1, 0x1cff5(%rip)     # 0x2d208
je 0x10335
movl $0x0, 0x5fc(%rsp)
movl 0x5fc(%rsp), %eax
cmpl 0x1cfdb(%rip), %eax     # 0x2d20c
jge 0x10330
movq 0xf0(%rsp), %rdi
addq $0x18, %rdi
movslq 0x61c(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x5fc(%rsp), %rsi
callq 0x4ef0
movq 0xf0(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0xc0(%rsp)
addq $0x18, %rdi
movslq 0x618(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x5fc(%rsp), %rsi
callq 0x4ef0
movsd 0xc0(%rsp), %xmm0
movq 0xf0(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0xc8(%rsp)
movl 0x614(%rsp), %eax
addl 0x1d1e7(%rip), %eax     # 0x2d4a8
movslq %eax, %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x5fc(%rsp), %rsi
callq 0x4ef0
movsd 0xc8(%rsp), %xmm0
subsd (%rax), %xmm0
movaps 0xfd63(%rip), %xmm1     # 0x20050
pand %xmm1, %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
addsd 0x608(%rsp), %xmm0
movsd %xmm0, 0x608(%rsp)
movl 0x5fc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5fc(%rsp)
jmp 0x10224
jmp 0x10448
movl $0x0, 0x5f8(%rsp)
movl 0x5f8(%rsp), %eax
cmpl 0x1cebf(%rip), %eax     # 0x2d20c
jge 0x10446
movq 0xf0(%rsp), %rdi
addq $0x18, %rdi
movslq 0x61c(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x5f8(%rsp), %rsi
callq 0x4ef0
movq 0xf0(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0xb0(%rsp)
addq $0x18, %rdi
movslq 0x618(%rsp), %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x5f8(%rsp), %rsi
callq 0x4ef0
movsd 0xb0(%rsp), %xmm0
movq 0xf0(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0xb8(%rsp)
movl 0x614(%rsp), %eax
addl 0x1d0cb(%rip), %eax     # 0x2d4a8
movslq %eax, %rsi
callq 0xfd80
movq %rax, %rdi
movslq 0x5f8(%rsp), %rsi
callq 0x4ef0
movsd 0xb8(%rsp), %xmm0
subsd (%rax), %xmm0
callq 0x2af0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
addsd 0x608(%rsp), %xmm0
movsd %xmm0, 0x608(%rsp)
movl 0x5f8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5f8(%rsp)
jmp 0x10340
jmp 0x10448
movl 0x61c(%rsp), %eax
movl %eax, 0x5f4(%rsp)
movl 0x618(%rsp), %eax
movl %eax, 0x5f0(%rsp)
leaq 0x1cdcd(%rip), %rdi     # 0x2d238
leaq 0xfbee(%rip), %rsi      # 0x20060
callq 0x5070
testb $0x1, %al
jne 0x10480
jmp 0x10d4c
movq 0xf0(%rsp), %rax
addq $0xc0, %rax
movq %rax, 0xa8(%rsp)
leaq 0x5f4(%rsp), %rdi
leaq 0x5f0(%rsp), %rsi
callq 0xc100
movq 0xa8(%rsp), %rdi
movq %rax, 0x5d0(%rsp)
leaq 0x5d0(%rsp), %rsi
callq 0xc150
movq %rax, %rsi
leaq 0x5d8(%rsp), %rdi
callq 0x5620
leaq 0x5d8(%rsp), %rdi
callq 0xc130
cmpq $0x0, %rax
jbe 0x108d4
movl $0x0, 0x5cc(%rsp)
movslq 0x5cc(%rsp), %rax
movq %rax, 0xa0(%rsp)
leaq 0x5d8(%rsp), %rdi
callq 0xc130
movq %rax, %rcx
movq 0xa0(%rsp), %rax
cmpq %rcx, %rax
jae 0x108d2
movslq 0x5cc(%rsp), %rsi
leaq 0x5d8(%rsp), %rdi
callq 0x13110
movq %rax, %rsi
leaq 0x5b0(%rsp), %rdi
callq 0xb7d0
jmp 0x10552
movq $0x0, 0x598(%rsp)
movslq 0x5cc(%rsp), %rsi
leaq 0x5d8(%rsp), %rdi
callq 0x13110
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x590(%rsp)
leaq 0x570(%rsp), %rdi
callq 0x2290
leaq 0x3f8(%rsp), %rdi
callq 0x2260
jmp 0x1059d
movl $0x0, 0x3f4(%rsp)
movslq 0x3f4(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x5b0(%rsp), %rdi
callq 0xb8d0
movq %rax, %rcx
movq 0x98(%rsp), %rax
cmpq %rcx, %rax
jae 0x10680
movslq 0x3f4(%rsp), %rsi
leaq 0x5b0(%rsp), %rdi
callq 0xff70
movl (%rax), %esi
leaq 0x3f8(%rsp), %rdi
callq 0x2350
movq %rax, 0x90(%rsp)
jmp 0x10607
movq 0x90(%rsp), %rdi
leaq 0xfb6f(%rip), %rsi      # 0x20185
callq 0x21c0
jmp 0x1061d
jmp 0x1061f
movl 0x3f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3f4(%rsp)
jmp 0x105a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x10d3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x108b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x108a6
leaq 0x3d0(%rsp), %rdi
leaq 0x3f8(%rsp), %rsi
callq 0x21f0
jmp 0x10697
leaq 0x570(%rsp), %rdi
movq %rdi, 0x88(%rsp)
leaq 0x3d0(%rsp), %rsi
movq %rsi, 0x80(%rsp)
callq 0x2250
movq 0x80(%rsp), %rdi
callq 0x23f8
movq 0x88(%rsp), %rsi
leaq 0x3a8(%rsp), %rdi
leaq 0x614(%rsp), %rdx
callq 0x5bb0
jmp 0x106e8
leaq 0x1cb69(%rip), %rdi     # 0x2d258
leaq 0x3a8(%rsp), %rsi
callq 0x13130
movq %rax, 0x78(%rsp)
jmp 0x10703
leaq 0x3a8(%rsp), %rdi
callq 0x5bf0
movq 0x78(%rsp), %rax
cmpq $0x0, %rax
jbe 0x107c6
leaq 0x380(%rsp), %rdi
leaq 0x570(%rsp), %rsi
leaq 0x614(%rsp), %rdx
callq 0x5bb0
jmp 0x1073e
leaq 0x1cb13(%rip), %rdi     # 0x2d258
leaq 0x380(%rsp), %rsi
callq 0x5ac0
movq %rax, 0x70(%rsp)
jmp 0x10759
movq 0x70(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x598(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x5bf0
jmp 0x107c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x3a8(%rsp), %rdi
callq 0x5bf0
jmp 0x108a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x5bf0
jmp 0x108a6
movl 0x614(%rsp), %eax
movl %eax, 0x6c(%rsp)
leaq 0x368(%rsp), %rdi
leaq 0x5b0(%rsp), %rsi
callq 0xb7d0
jmp 0x107e8
movl 0x6c(%rsp), %esi
movq 0xf0(%rsp), %rdi
leaq 0x368(%rsp), %rdx
callq 0x13190
movsd %xmm0, 0x60(%rsp)
jmp 0x10809
movsd 0x60(%rsp), %xmm0
mulsd 0x590(%rsp), %xmm0
movsd 0x598(%rsp), %xmm2
movsd 0x608(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x608(%rsp)
leaq 0x368(%rsp), %rdi
callq 0x4d60
leaq 0x3f8(%rsp), %rdi
callq 0x2070
leaq 0x570(%rsp), %rdi
callq 0x23f8
leaq 0x5b0(%rsp), %rdi
callq 0x4d60
movl 0x5cc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5cc(%rsp)
jmp 0x104fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x368(%rsp), %rdi
callq 0x4d60
leaq 0x3f8(%rsp), %rdi
callq 0x2070
leaq 0x570(%rsp), %rdi
callq 0x23f8
leaq 0x5b0(%rsp), %rdi
callq 0x4d60
jmp 0x10d3d
jmp 0x108d4
movq 0xf0(%rsp), %rax
addq $0xc0, %rax
movq %rax, 0x50(%rsp)
leaq 0x5f0(%rsp), %rdi
leaq 0x5f4(%rsp), %rsi
callq 0xc100
movq %rax, 0x58(%rsp)
jmp 0x10903
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rax
movq %rax, 0x360(%rsp)
leaq 0x360(%rsp), %rsi
callq 0xc150
movq %rax, 0x48(%rsp)
jmp 0x10929
movq 0x48(%rsp), %rsi
leaq 0x5d8(%rsp), %rdi
callq 0xc240
jmp 0x1093d
leaq 0x5d8(%rsp), %rdi
callq 0xc130
cmpq $0x0, %rax
jbe 0x10d2e
movl $0x0, 0x35c(%rsp)
movslq 0x35c(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x5d8(%rsp), %rdi
callq 0xc130
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jae 0x10d2c
movslq 0x35c(%rsp), %rsi
leaq 0x5d8(%rsp), %rdi
callq 0x13110
movq %rax, %rsi
leaq 0x340(%rsp), %rdi
callq 0xb7d0
jmp 0x109b1
movslq 0x35c(%rsp), %rsi
leaq 0x5d8(%rsp), %rdi
callq 0x13110
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x338(%rsp)
movq $0x0, 0x330(%rsp)
leaq 0x310(%rsp), %rdi
callq 0x2290
leaq 0x198(%rsp), %rdi
callq 0x2260
jmp 0x109fc
movl $0x0, 0x194(%rsp)
movslq 0x194(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x340(%rsp), %rdi
callq 0xb8d0
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0x10ab7
movslq 0x194(%rsp), %rsi
leaq 0x340(%rsp), %rdi
callq 0xff70
movl (%rax), %esi
leaq 0x198(%rsp), %rdi
callq 0x2350
movq %rax, 0x30(%rsp)
jmp 0x10a5d
movq 0x30(%rsp), %rdi
leaq 0xf71c(%rip), %rsi      # 0x20185
callq 0x21c0
jmp 0x10a70
jmp 0x10a72
movl 0x194(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x194(%rsp)
jmp 0x10a07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x10d10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x10d03
leaq 0x170(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x21f0
jmp 0x10ace
leaq 0x310(%rsp), %rdi
movq %rdi, 0x28(%rsp)
leaq 0x170(%rsp), %rsi
movq %rsi, 0x20(%rsp)
callq 0x2250
movq 0x20(%rsp), %rdi
callq 0x23f8
movq 0x28(%rsp), %rsi
movl 0x614(%rsp), %eax
movl 0x1c99f(%rip), %ecx     # 0x2d4a8
addl %ecx, %eax
movl %eax, 0x144(%rsp)
leaq 0x148(%rsp), %rdi
leaq 0x144(%rsp), %rdx
callq 0x13300
jmp 0x10b29
leaq 0x1c728(%rip), %rdi     # 0x2d258
leaq 0x148(%rsp), %rsi
callq 0x13130
movq %rax, 0x18(%rsp)
jmp 0x10b44
leaq 0x148(%rsp), %rdi
callq 0x5bf0
movq 0x18(%rsp), %rax
cmpq $0x0, %rax
jbe 0x10c1d
movl 0x614(%rsp), %eax
movl 0x1c93b(%rip), %ecx     # 0x2d4a8
addl %ecx, %eax
movl %eax, 0x114(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x310(%rsp), %rsi
leaq 0x114(%rsp), %rdx
callq 0x13300
jmp 0x10b95
leaq 0x1c6bc(%rip), %rdi     # 0x2d258
leaq 0x118(%rsp), %rsi
callq 0x5ac0
movq %rax, 0x10(%rsp)
jmp 0x10bb0
movq 0x10(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x330(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x5bf0
jmp 0x10c1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x5bf0
jmp 0x10d03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x5bf0
jmp 0x10d03
movl 0x614(%rsp), %eax
movl 0x1c87e(%rip), %ecx     # 0x2d4a8
addl %ecx, %eax
movl %eax, 0xc(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0x340(%rsp), %rsi
callq 0xb7d0
jmp 0x10c47
movl 0xc(%rsp), %esi
movq 0xf0(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x13190
movsd %xmm0, (%rsp)
jmp 0x10c67
movsd (%rsp), %xmm0
mulsd 0x338(%rsp), %xmm0
movsd 0x330(%rsp), %xmm2
movsd 0x608(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x608(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x4d60
leaq 0x198(%rsp), %rdi
callq 0x2070
leaq 0x310(%rsp), %rdi
callq 0x23f8
leaq 0x340(%rsp), %rdi
callq 0x4d60
movl 0x35c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x35c(%rsp)
jmp 0x1095f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x4d60
leaq 0x198(%rsp), %rdi
callq 0x2070
leaq 0x310(%rsp), %rdi
callq 0x23f8
leaq 0x340(%rsp), %rdi
callq 0x4d60
jmp 0x10d3d
jmp 0x10d2e
leaq 0x5d8(%rsp), %rdi
callq 0x5720
jmp 0x10d4c
leaq 0x5d8(%rsp), %rdi
callq 0x5720
jmp 0x10d5d
movsd 0x608(%rsp), %xmm0
addq $0x628, %rsp            # imm = 0x628
retq
movq 0x5a8(%rsp), %rdi
callq 0x2360
nopw (%rax,%rax)