// File: manikandan5[P]Image-Matching-Stitching-Warping/./Homography.h
// Function: getInliners(cimg_library::CImg<double>&, std::vector<std::pair<SiftDescriptor, SiftDescriptor>, std::allocator<std::pair<SiftDescriptor, SiftDescriptor>>> const&)
int getInliners(CImg<double>& projection,const SiftDescriptorMap& mapping)
{
	int count = 0;
	
	//point in Second Image = [projection]* point in first 	
	for(int i = 0;i<mapping.size();++i)
	{
		double zz = projection(0,6) * mapping[i].first.col + projection(0,7) * mapping[i].first.row + 1;
		double xx = (projection(0,0) * mapping[i].first.col + projection(0,1) * mapping[i].first.row + projection(0,2))/zz;
		double yy = (projection(0,3) * mapping[i].first.col + projection(0,4) * mapping[i].first.row + projection(0,5))/zz;
		
		//cout<<i+1<<" x-x'= "<<xx-mapping[i].second.col<<" y-y' = "<<yy-mapping[i].second.row<<endl; 		

		if(abs(xx-mapping[i].second.col) <5.0 && abs(yy-mapping[i].second.row)<5.0)
			count++;
	}
	return count;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movl $0x0, 0x94(%rsp)
movl $0x0, 0x90(%rsp)
movslq 0x90(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x98(%rsp), %rdi
callq 0xb110
movq %rax, %rcx
movq 0x70(%rsp), %rax
cmpq %rcx, %rax
jae 0x7154
movq 0xa0(%rsp), %rdi
xorl %esi, %esi
movl $0x6, %edx
callq 0x9850
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xb130
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0xa0(%rsp), %rdi
xorl %esi, %esi
movl $0x7, %edx
callq 0x9850
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xb130
movsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm2
movss (%rax), %xmm3
cvtss2sd %xmm3, %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0xc112d(%rip), %xmm1    # 0xc8018
addsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
movq 0xa0(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x9850
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xb130
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0xa0(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x9850
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xb130
movsd 0x28(%rsp), %xmm1
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm2
movss (%rax), %xmm3
cvtss2sd %xmm3, %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0xa0(%rsp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x9850
movsd 0x40(%rsp), %xmm0
addsd (%rax), %xmm0
divsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movq 0xa0(%rsp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x9850
movsd (%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xb130
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0xa0(%rsp), %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x9850
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xb130
movsd 0x48(%rsp), %xmm1
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm2
movss (%rax), %xmm3
cvtss2sd %xmm3, %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0xa0(%rsp), %rdi
xorl %esi, %esi
movl $0x5, %edx
callq 0x9850
movsd 0x60(%rsp), %xmm0
addsd (%rax), %xmm0
divsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xb130
movsd 0x68(%rsp), %xmm0
movss 0x2c(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
subsd %xmm1, %xmm0
callq 0xb150
movaps %xmm0, %xmm1
movsd 0xc0f45(%rip), %xmm0    # 0xc8020
ucomisd %xmm1, %xmm0
jbe 0x713c
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xb130
movsd 0x8(%rsp), %xmm0
movss 0x28(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
subsd %xmm1, %xmm0
callq 0xb150
movaps %xmm0, %xmm1
movsd 0xc0efb(%rip), %xmm0    # 0xc8020
ucomisd %xmm1, %xmm0
jbe 0x713c
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x713e
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x6e1d
movl 0x94(%rsp), %eax
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)