// File: /workspace/github_cpp_makefile_star2_O3/manikandan5[P]Image-Matching-Stitching-Warping/a2.cpp
// Function: main
int main(int argc, char **argv)
{
  try {

		if(argc < 2)
		{
			cout << "Insufficent number of arguments; correct usage:" << endl;
			cout << "    a2-p1 part_id ..." << endl;
			return -1;
		}	

		
		string part = argv[1];
		
		if(part == "part1")
		{
			if(argc < 4)
			{
				//Ranking of each image from a group chosen randomly.
				Image::randomRanking();
				return -1;
			}			
			Image queryImage(argv[2]);
			vector<Image> images;
			for(int i = 3;i < argc;++i)
			{
				Image I(argv[i]);
				images.push_back(I);
			}
			
			//1 - ranking of all the images with respect to query images
			Image::descriptorMatching1(queryImage,images);
						
				
		}
		else if(part == "part1fast")
		{
			if(argc < 4)
			{
				//Ranking of each image from a group chosen randomly.
				Image::randomRanking(true);
				return -1;
			}
			
			Image queryImage(argv[2]);
			vector<Image> images;
			for(int i = 3;i < argc;++i)
			{
				Image I(argv[i]);
				images.push_back(I);
			}
			
			//3 - ranking of all the images with respect to query images - quantized projection function
			Image::descriptorMatching2(queryImage,images);
		}
		else if(part == "part2")
		{
			if(argc < 4)
			{
				//Lincoln Transformation
				Image I("lincoln.png");
				CImg<double> projection(3,3);
				projection(0,0) = 0.907;
				projection(1,0) = 0.258;
				projection(2,0) = -182;
				projection(0,1) = -0.153;
				projection(1,1) = 1.44;
				projection(2,1) = 58;
				projection(0,2) = -0.000306;
				projection(1,2) = 0.000731;
				projection(2,2) = 1;
			
				string lincolnName = "lincoln_transform.jpg";
				projectiveTransform(I,projection,lincolnName);
				
				return -1;
			}
			
			// Warping of query image in terms of all other images
			Image queryImage(argv[2]);
			vector<Image> images;
			for(int i = 3;i < argc;++i)
			{
				Image I(argv[i]);
				images.push_back(I);
			}
			
			warpingApplication(queryImage,images);
		}
		else
		throw std::string("unknown part!");

	}catch(const string &err) 
	{
		cerr << "Error: " << err << endl;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
cmpl $0x1, %edi
jg 0x696e
movq 0xa16d9(%rip), %rbx     # 0xa7fb8
leaq 0x6923c(%rip), %rsi     # 0x6fb22
movl $0x2f, %edx
movq %rbx, %rdi
callq 0x45b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4530
movsbl %al, %esi
movq 0xa16a7(%rip), %rdi     # 0xa7fb8
callq 0x4050
movq %rax, %rdi
callq 0x4380
movq 0xa1693(%rip), %rbx     # 0xa7fb8
leaq 0x69226(%rip), %rsi     # 0x6fb52
movl $0x15, %edx
movq %rbx, %rdi
callq 0x45b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4530
movsbl %al, %esi
movq 0xa1661(%rip), %rdi     # 0xa7fb8
callq 0x4050
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x4380
jmp 0x6f62
movq %rsi, %rbx
movl %edi, %ebp
movq 0x8(%rsi), %rsi
leaq 0x118(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x41c0
leaq 0x691d5(%rip), %rsi     # 0x6fb68
leaq 0x118(%rsp), %rdi
callq 0x4110
movl %eax, %r14d
testl %eax, %eax
je 0x6b7f
leaq 0x691bc(%rip), %rsi     # 0x6fb6e
leaq 0x118(%rsp), %rdi
callq 0x4110
testl %eax, %eax
je 0x6ca2
leaq 0x691aa(%rip), %rsi     # 0x6fb78
leaq 0x118(%rsp), %rdi
callq 0x4110
testl %eax, %eax
jne 0x6f76
cmpl $0x3, %ebp
ja 0x6cc3
leaq 0x168(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x6917f(%rip), %rsi     # 0x6fb7e
leaq 0x69183(%rip), %rdx     # 0x6fb89
leaq 0x158(%rsp), %rdi
callq 0x5ad12
leaq 0xa8(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x974e
movq 0x158(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a3a
callq 0x44f0
leaq 0x38(%rsp), %rdi
movl $0x3, %esi
movl $0x3, %edx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x8666
movq 0x50(%rsp), %rax
movaps 0x6769b(%rip), %xmm0    # 0x6e100
movups %xmm0, (%rax)
movabsq $-0x3f99400000000000, %rcx # imm = 0xC066C00000000000
movq %rcx, 0x10(%rax)
movl 0x38(%rsp), %ecx
movabsq $-0x403c6a7ef9db22d1, %rdx # imm = 0xBFC395810624DD2F
movq %rdx, (%rax,%rcx,8)
leal 0x1(%rcx), %edx
movabsq $0x3ff70a3d70a3d70a, %rsi # imm = 0x3FF70A3D70A3D70A
movq %rsi, (%rax,%rdx,8)
leal 0x2(%rcx), %edx
movabsq $0x404d000000000000, %rsi # imm = 0x404D000000000000
movq %rsi, (%rax,%rdx,8)
leal (%rcx,%rcx), %edx
movaps 0x6765c(%rip), %xmm0    # 0x6e110
movups %xmm0, (%rax,%rdx,8)
leal 0x2(%rcx,%rcx), %ecx
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movq %rdx, (%rax,%rcx,8)
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x690b0(%rip), %rsi     # 0x6fb8a
leaq 0x690be(%rip), %rdx     # 0x6fb9f
leaq 0x10(%rsp), %rdi
callq 0x5ad12
leaq 0xa8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x5a8c
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x6b11
callq 0x44f0
cmpb $0x0, 0x48(%rsp)
jne 0x6b27
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6b27
callq 0x4690
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
callq 0xa038
cmpb $0x0, -0x10(%rbx)
jne 0x6b4f
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x6b4f
callq 0x4690
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa038
movq -0x20(%rbx), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x6b75
callq 0x44f0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x6f4c
cmpl $0x4, %ebp
jb 0x6cab
movq 0x10(%rbx), %rsi
leaq 0x1f8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x41c0
leaq 0xa8(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x974e
leaq 0x208(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6bc9
callq 0x44f0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl %ebp, %r12d
movl $0x3, %r14d
leaq 0x198(%rsp), %r13
leaq 0xf(%rsp), %rbp
leaq 0x38(%rsp), %r15
movq (%rbx,%r14,8), %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0x41c0
movq %r15, %rdi
movq %r13, %rsi
callq 0x974e
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x6c2b
callq 0x44f0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x9990
leaq 0x90(%rsp), %rdi
callq 0xa038
cmpb $0x0, 0x80(%rsp)
jne 0x6c61
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x6c61
callq 0x4690
leaq 0x58(%rsp), %rdi
callq 0xa038
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x6c7f
callq 0x44f0
incq %r14
cmpq %r14, %r12
jne 0x6bf7
leaq 0xa8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x99f8
jmp 0x6ef2
cmpl $0x3, %ebp
ja 0x6ddd
xorl %edi, %edi
testl %r14d, %r14d
setne %dil
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
callq 0x8ff6
jmp 0x6f4c
movq 0x10(%rbx), %rsi
leaq 0x1b8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x41c0
leaq 0xa8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x974e
leaq 0x1c8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6d04
callq 0x44f0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl %ebp, %r12d
movl $0x3, %r14d
leaq 0x138(%rsp), %r13
leaq 0xf(%rsp), %rbp
leaq 0x38(%rsp), %r15
movq (%rbx,%r14,8), %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0x41c0
movq %r15, %rdi
movq %r13, %rsi
callq 0x974e
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x6d66
callq 0x44f0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x9990
leaq 0x90(%rsp), %rdi
callq 0xa038
cmpb $0x0, 0x80(%rsp)
jne 0x6d9c
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x6d9c
callq 0x4690
leaq 0x58(%rsp), %rdi
callq 0xa038
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x6dba
callq 0x44f0
incq %r14
cmpq %r14, %r12
jne 0x6d32
leaq 0xa8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x65f8
jmp 0x6ef2
movq 0x10(%rbx), %rsi
leaq 0x1d8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x41c0
leaq 0xa8(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x974e
leaq 0x1e8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6e1e
callq 0x44f0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl %ebp, %r12d
movl $0x3, %r14d
leaq 0x178(%rsp), %r13
leaq 0xf(%rsp), %rbp
leaq 0x38(%rsp), %r15
movq (%rbx,%r14,8), %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0x41c0
movq %r15, %rdi
movq %r13, %rsi
callq 0x974e
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
cmpq %rax, %rdi
je 0x6e80
callq 0x44f0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x9990
leaq 0x90(%rsp), %rdi
callq 0xa038
cmpb $0x0, 0x80(%rsp)
jne 0x6eb6
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x6eb6
callq 0x4690
leaq 0x58(%rsp), %rdi
callq 0xa038
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x6ed4
callq 0x44f0
incq %r14
cmpq %r14, %r12
jne 0x6e4c
leaq 0xa8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9cf6
leaq 0x10(%rsp), %rdi
callq 0x9cce
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
callq 0xa038
cmpb $0x0, -0x10(%rbx)
jne 0x6f24
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x6f24
callq 0x4690
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa038
movq -0x20(%rbx), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x6f4a
callq 0x44f0
xorl %ebx, %ebx
leaq 0x128(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6f62
callq 0x44f0
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
addq $0x10, %rax
movq %rax, (%r15)
leaq 0x68c0f(%rip), %rsi     # 0x6fba0
leaq 0x68c15(%rip), %rdx     # 0x6fbad
movq %r15, %rdi
callq 0x5ad12
leaq 0xa0c69(%rip), %rsi     # 0xa7c10
movq 0xa0fea(%rip), %rdx     # 0xa7f98
movq %r15, %rdi
callq 0x4910
jmp 0x70d8
movq %rdx, %rbx
movq %rax, %r14
leaq 0x1e8(%rsp), %rax
jmp 0x7048
jmp 0x7090
jmp 0x70d8
movq %rdx, %rbx
movq %rax, %r14
leaq 0x208(%rsp), %rax
jmp 0x7048
jmp 0x7090
jmp 0x70d8
movq %rdx, %rbx
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x700c
callq 0x44f0
jmp 0x700c
movq %rdx, %rbx
movq %rax, %r14
cmpb $0x0, 0x48(%rsp)
jne 0x711c
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x711c
callq 0x4690
jmp 0x711c
movq %rdx, %rbx
movq %rax, %r14
jmp 0x711c
movq %rdx, %rbx
movq %rax, %r14
leaq 0x1c8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x706d
jmp 0x7129
movq %rdx, %rbx
movq %rax, %r14
movq 0x158(%rsp), %rdi
cmpq %r15, %rdi
je 0x7129
callq 0x44f0
jmp 0x7129
jmp 0x7090
jmp 0x7090
jmp 0x7090
movq %rdx, %rbx
movq %rax, %r14
movq %r15, %rdi
callq 0x43c0
jmp 0x7129
movq %rdx, %rbx
movq %rax, %r14
jmp 0x7129
jmp 0x7141
jmp 0x70d8
movq %rdx, %rbx
movq %rax, %r14
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
jmp 0x70f6
jmp 0x7102
jmp 0x70d8
movq %rdx, %rbx
movq %rax, %r14
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
jmp 0x70f6
jmp 0x7102
movq %rdx, %rbx
movq %rax, %r14
jmp 0x7112
movq %rdx, %rbx
movq %rax, %r14
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x7112
callq 0x44f0
jmp 0x7112
movq %rdx, %rbx
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x99ba
leaq 0x10(%rsp), %rdi
callq 0x9cce
leaq 0xa8(%rsp), %rdi
callq 0x99ba
leaq 0x128(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7147
callq 0x44f0
jmp 0x7147
movq %rdx, %rbx
movq %rax, %r14
cmpl $0x1, %ebx
jne 0x719e
movq %r14, %rdi
callq 0x41d0
movq %rax, %rbx
movq 0xa0e8a(%rip), %rdi     # 0xa7fe8
leaq 0x68a49(%rip), %rsi     # 0x6fbae
movl $0x7, %edx
callq 0x45b0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xa0e6b(%rip), %rdi     # 0xa7fe8
callq 0x45b0
movq %rax, %rdi
callq 0x4200
callq 0x48d0
xorl %ebx, %ebx
jmp 0x6f62
movq %rax, %r14
callq 0x48d0
movq %r14, %rdi
callq 0x4960
movq %rax, %rdi
callq 0xa02c