// File: /workspace/github_cpp_makefile_star2_O3/KokiKishimoto[P]cp_decomposition/testcp.cpp
// Function: TestCP::test_inv()
void test_inv() {
		double total = (double)testData.triples.size() * 2;
		double mrr = 0.0, mrr_filter = 0.0;
		double rank_1 = 0.0, rank_1_filter = 0.0;
		double rank_3 = 0.0, rank_3_filter = 0.0;
		double rank_5 = 0.0, rank_5_filter = 0.0;
		double rank_10 = 0.0, rank_10_filter = 0.0;
		int j=0;
		
		for (Triple& test_tuple : testData.triples) {
			if (test_tuple.flag) {
				total = total - 2;
				continue;
			}
			pre_score_inv(test_tuple.subj, test_tuple.relation, test_tuple.relation_rev, test_tuple.obj);
			for (int entity = 0; entity<trainData.entity_counter; ++entity) {
				RankScore& r1 = scores_subj[entity]; 
				r1.set(entity, innerProductSubj(entity, outVec2) + innerProductObj(entity, outVec3_inv));
				RankScore& r2 = scores_obj[entity];
				r2.set(entity, innerProductObj(entity, outVec3) + innerProductSubj(entity, outVec2_inv));
			}
			generate_rank(scores_subj, test_tuple.relation, test_tuple.subj, test_tuple.obj, subjSet, rank1, rank_filter_1);
			generate_rank(scores_obj, test_tuple.relation, test_tuple.obj, test_tuple.subj, objSet, rank2, rank_filter_2);

		}
		rank_1 = calculate_ranking(rank1, rank2, 1);
		rank_3 = calculate_ranking(rank1, rank2, 3);
		rank_5 = calculate_ranking(rank1, rank2, 5);
		rank_10 = calculate_ranking(rank1, rank2, 10);
		mrr = calate_mrr(rank1, rank2);

		rank_1_filter = calculate_ranking(rank_filter_1, rank_filter_2, 1);
		rank_3_filter = calculate_ranking(rank_filter_1, rank_filter_2, 3);
		rank_5_filter = calculate_ranking(rank_filter_1, rank_filter_2, 5);
		rank_10_filter = calculate_ranking(rank_filter_1, rank_filter_2, 10);
		mrr_filter = calate_mrr(rank_filter_1, rank_filter_2);

		std::cout << "Raw Rank1: " << (rank_1 / total) << "\n";
		std::cout << "Raw Rank3: " << (rank_3 / total) << "\n";
		std::cout << "Raw Rank5: " << (rank_5 / total) << "\n";
		std::cout << "Raw Rank10: " << (rank_10 / total) << "\n";
		std::cout << "Raw MRR: " << (mrr / total) << "\n";
		
		std::cout << "Filtered Rank1: " << (rank_1_filter / total) << "\n";
		std::cout << "Filtered Rank3: " << (rank_3_filter / total) << "\n";
		std::cout << "Filtered Rank5: " << (rank_5_filter / total) << "\n";
		std::cout << "Filtered Rank10: " << (rank_10_filter / total) << "\n";
		std::cout << "Filtered MRR: " << (mrr_filter / total) << "\n";
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
movq 0x148(%rdi), %r14
movq 0x150(%rdi), %rdx
movq %rdx, %rax
subq %r14, %rax
sarq $0x2, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rcx
movq %rcx, %xmm0
punpckldq 0x4415(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x441d(%rip), %xmm0     # 0x8020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd %xmm1, %xmm1
movapd %xmm1, (%rsp)
cmpq %r14, %rdx
je 0x3ea2
leaq 0x18(%rbx), %rax
movq %rax, 0x60(%rsp)
leaq 0x318(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x380(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0x3b0(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x348(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x398(%rbx), %rax
movq %rax, 0xb0(%rsp)
leaq 0x3c8(%rbx), %rax
movq %rax, 0xa8(%rsp)
movq %rbx, 0x10(%rsp)
movq %rdx, 0x70(%rsp)
cmpb $0x1, 0x10(%r14)
jne 0x3ca0
movapd (%rsp), %xmm0
addsd 0x43aa(%rip), %xmm0     # 0x8040
movapd %xmm0, (%rsp)
jmp 0x3e95
movl 0x8(%r14), %edx
movl 0xc(%r14), %ecx
movl (%r14), %esi
movq %r14, 0x80(%rsp)
movl 0x4(%r14), %r8d
movq %rbx, %rdi
callq 0x747a
movslq 0x30(%rbx), %rax
testq %rax, %rax
jle 0x3e2d
movq 0x10(%rsp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
movq 0x18(%rcx), %rdx
movq %rdx, 0x90(%rsp)
movq 0x238(%rcx), %rsi
movq 0x298(%rcx), %rdi
movq 0x250(%rcx), %r8
movq 0x2f8(%rcx), %r9
movq 0x2b0(%rcx), %r10
movq 0x2e0(%rcx), %r11
xorl %r14d, %r14d
leaq (%r14,%r14,2), %r13
movq (%rsi,%r13,8), %r15
movq 0x8(%rsi,%r13,8), %r12
movq %r12, %rcx
subq %r15, %rcx
je 0x3d52
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorpd %xmm1, %xmm1
xorl %ebx, %ebx
movsd (%r15,%rbx,8), %xmm0
mulsd (%rdi,%rbx,8), %xmm0
addsd %xmm0, %xmm1
incq %rbx
cmpq %rbx, %rcx
jne 0x3d39
jmp 0x3d56
xorpd %xmm1, %xmm1
movq %r14, %rbp
shlq $0x4, %rbp
movq 0x20(%rsp), %rcx
addq %rbp, %rcx
movq (%r8,%r13,8), %rbx
movq 0x8(%r8,%r13,8), %r13
subq %rbx, %r13
je 0x3dc7
sarq $0x3, %r13
cmpq $0x1, %r13
adcq $0x0, %r13
xorpd %xmm0, %xmm0
xorl %edx, %edx
movsd (%rbx,%rdx,8), %xmm2
mulsd (%r9,%rdx,8), %xmm2
addsd %xmm2, %xmm0
incq %rdx
cmpq %rdx, %r13
jne 0x3d85
addsd %xmm0, %xmm1
movl %r14d, 0x8(%rcx)
movsd %xmm1, (%rcx)
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
movsd (%rbx,%rcx,8), %xmm1
mulsd (%r10,%rcx,8), %xmm1
addsd %xmm1, %xmm0
incq %rcx
cmpq %rcx, %r13
jne 0x3dae
jmp 0x3dd7
xorpd %xmm0, %xmm0
addsd %xmm0, %xmm1
movl %r14d, 0x8(%rcx)
movsd %xmm1, (%rcx)
subq %r15, %r12
je 0x3e08
sarq $0x3, %r12
cmpq $0x1, %r12
adcq $0x0, %r12
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
movsd (%r15,%rcx,8), %xmm2
mulsd (%r11,%rcx,8), %xmm2
addsd %xmm2, %xmm1
incq %rcx
cmpq %rcx, %r12
jne 0x3dee
jmp 0x3e0c
xorpd %xmm1, %xmm1
addsd %xmm1, %xmm0
addq 0x90(%rsp), %rbp
movl %r14d, 0x8(%rbp)
movsd %xmm0, (%rbp)
incq %r14
cmpq %rax, %r14
jne 0x3d12
movq 0x80(%rsp), %r14
movl 0x8(%r14), %edx
movl (%r14), %ecx
movl 0x4(%r14), %r8d
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %r9
pushq 0x40(%rsp)
pushq 0x58(%rsp)
callq 0x7580
addq $0x10, %rsp
movl 0x8(%r14), %edx
movl (%r14), %r8d
movl 0x4(%r14), %ecx
movq %rbx, %rdi
movq 0x60(%rsp), %rsi
movq 0x30(%rsp), %r9
pushq 0xa8(%rsp)
pushq 0xb8(%rsp)
callq 0x7580
addq $0x10, %rsp
movq 0x70(%rsp), %rdx
addq $0x14, %r14
cmpq %rdx, %r14
jne 0x3c82
leaq 0x380(%rbx), %rsi
leaq 0x398(%rbx), %rdx
movq 0x380(%rbx), %rax
movq 0x388(%rbx), %rcx
xorpd %xmm6, %xmm6
xorpd %xmm4, %xmm4
xorpd %xmm5, %xmm5
xorpd %xmm7, %xmm7
subq %rax, %rcx
je 0x4036
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
movq (%rdx), %rdi
xorl %r8d, %r8d
movsd 0x4157(%rip), %xmm0     # 0x8048
movsd (%rax,%r8,8), %xmm1
movapd %xmm4, %xmm2
addsd %xmm0, %xmm2
cmpltsd %xmm0, %xmm1
andpd %xmm1, %xmm2
andnpd %xmm4, %xmm1
orpd %xmm2, %xmm1
movsd (%rdi,%r8,8), %xmm4
cmpltsd %xmm0, %xmm4
movapd %xmm4, %xmm2
andnpd %xmm1, %xmm2
addsd %xmm0, %xmm1
andpd %xmm1, %xmm4
orpd %xmm2, %xmm4
incq %r8
cmpq %r8, %rcx
jne 0x3ef1
xorpd %xmm5, %xmm5
xorl %r8d, %r8d
movsd 0x410a(%rip), %xmm1     # 0x8050
movsd (%rax,%r8,8), %xmm2
movapd %xmm5, %xmm3
addsd %xmm0, %xmm3
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm5, %xmm2
orpd %xmm3, %xmm2
movsd (%rdi,%r8,8), %xmm5
cmpltsd %xmm1, %xmm5
movapd %xmm5, %xmm3
andnpd %xmm2, %xmm3
addsd %xmm0, %xmm2
andpd %xmm2, %xmm5
orpd %xmm3, %xmm5
incq %r8
cmpq %r8, %rcx
jne 0x3f46
xorpd %xmm6, %xmm6
xorl %r8d, %r8d
movsd 0x40bd(%rip), %xmm1     # 0x8058
movsd (%rax,%r8,8), %xmm2
movapd %xmm6, %xmm3
addsd %xmm0, %xmm3
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm6, %xmm2
orpd %xmm3, %xmm2
movsd (%rdi,%r8,8), %xmm6
cmpltsd %xmm1, %xmm6
movapd %xmm6, %xmm3
andnpd %xmm2, %xmm3
addsd %xmm0, %xmm2
andpd %xmm2, %xmm6
orpd %xmm3, %xmm6
incq %r8
cmpq %r8, %rcx
jne 0x3f9b
xorpd %xmm7, %xmm7
xorl %r8d, %r8d
movsd 0x4070(%rip), %xmm1     # 0x8060
movsd (%rax,%r8,8), %xmm2
movapd %xmm7, %xmm3
addsd %xmm0, %xmm3
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm7, %xmm2
orpd %xmm3, %xmm2
movsd (%rdi,%r8,8), %xmm7
cmpltsd %xmm1, %xmm7
movapd %xmm7, %xmm3
andnpd %xmm2, %xmm3
addsd %xmm0, %xmm2
andpd %xmm2, %xmm7
orpd %xmm3, %xmm7
incq %r8
cmpq %r8, %rcx
jne 0x3ff0
movapd %xmm7, 0x60(%rsp)
movapd %xmm6, 0x70(%rsp)
movapd %xmm5, 0x80(%rsp)
movapd %xmm4, 0x90(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
callq 0x7748
movsd %xmm0, 0x18(%rsp)
leaq 0x3b0(%rbx), %rsi
leaq 0x3c8(%rbx), %rdx
movq 0x3b0(%rbx), %rax
movq 0x3b8(%rbx), %rcx
xorpd %xmm5, %xmm5
xorpd %xmm6, %xmm6
xorpd %xmm4, %xmm4
subq %rax, %rcx
je 0x4202
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
movq (%rdx), %rdi
xorl %r8d, %r8d
movsd 0x3f91(%rip), %xmm0     # 0x8048
movsd (%rax,%r8,8), %xmm1
movapd %xmm5, %xmm2
addsd %xmm0, %xmm2
cmpltsd %xmm0, %xmm1
andpd %xmm1, %xmm2
andnpd %xmm5, %xmm1
orpd %xmm2, %xmm1
movsd (%rdi,%r8,8), %xmm5
cmpltsd %xmm0, %xmm5
movapd %xmm5, %xmm2
andnpd %xmm1, %xmm2
addsd %xmm0, %xmm1
andpd %xmm1, %xmm5
orpd %xmm2, %xmm5
incq %r8
cmpq %r8, %rcx
jne 0x40b7
xorpd %xmm6, %xmm6
xorl %r8d, %r8d
movsd 0x3f44(%rip), %xmm1     # 0x8050
movsd (%rax,%r8,8), %xmm2
movapd %xmm6, %xmm3
addsd %xmm0, %xmm3
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm6, %xmm2
orpd %xmm3, %xmm2
movsd (%rdi,%r8,8), %xmm6
cmpltsd %xmm1, %xmm6
movapd %xmm6, %xmm3
andnpd %xmm2, %xmm3
addsd %xmm0, %xmm2
andpd %xmm2, %xmm6
orpd %xmm3, %xmm6
incq %r8
cmpq %r8, %rcx
jne 0x410c
xorpd %xmm4, %xmm4
xorl %r8d, %r8d
movsd 0x3ef7(%rip), %xmm1     # 0x8058
movsd (%rax,%r8,8), %xmm2
movapd %xmm4, %xmm3
addsd %xmm0, %xmm3
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm4, %xmm2
orpd %xmm3, %xmm2
movsd (%rdi,%r8,8), %xmm4
cmpltsd %xmm1, %xmm4
movapd %xmm4, %xmm3
andnpd %xmm2, %xmm3
addsd %xmm0, %xmm2
andpd %xmm2, %xmm4
orpd %xmm3, %xmm4
incq %r8
cmpq %r8, %rcx
jne 0x4161
movapd %xmm4, 0x20(%rsp)
xorpd %xmm4, %xmm4
xorl %r8d, %r8d
movsd 0x3ea4(%rip), %xmm1     # 0x8060
movsd (%rax,%r8,8), %xmm2
movapd %xmm4, %xmm3
addsd %xmm0, %xmm3
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm4, %xmm2
orpd %xmm3, %xmm2
movsd (%rdi,%r8,8), %xmm4
cmpltsd %xmm1, %xmm4
movapd %xmm4, %xmm3
andnpd %xmm2, %xmm3
addsd %xmm0, %xmm2
andpd %xmm2, %xmm4
orpd %xmm3, %xmm4
incq %r8
cmpq %r8, %rcx
jne 0x41bc
movapd %xmm5, 0x30(%rsp)
movapd %xmm6, 0x40(%rsp)
movapd %xmm4, 0x50(%rsp)
movq %rbx, %rdi
callq 0x7748
movsd %xmm0, 0x10(%rsp)
movq 0x6daf(%rip), %rbx      # 0xafd8
leaq 0x3edc(%rip), %rsi      # 0x810c
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2230
movapd 0x90(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
leaq 0x3ebe(%rip), %r14      # 0x8118
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x3ea9(%rip), %rsi      # 0x811a
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2230
movapd 0x80(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x3e7b(%rip), %rsi      # 0x8126
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2230
movapd 0x70(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x3e50(%rip), %rsi      # 0x8132
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2230
movapd 0x60(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x3e26(%rip), %rsi      # 0x813f
movl $0x9, %edx
movq %rbx, %rdi
callq 0x2230
movsd 0x18(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x3df9(%rip), %rsi      # 0x8149
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2230
movapd 0x30(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x3dd3(%rip), %rsi      # 0x815a
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2230
movapd 0x40(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x3dad(%rip), %rsi      # 0x816b
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2230
movapd 0x20(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x3d87(%rip), %rsi      # 0x817c
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2230
movapd 0x50(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x3d62(%rip), %rsi      # 0x818e
movl $0xe, %edx
movq %rbx, %rdi
callq 0x2230
movsd 0x10(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2230
nop