// File: /workspace/github_cpp_makefile_star2_O1/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 0x695f
movq 0xa66e8(%rip), %rbx     # 0xacfb8
leaq 0x6dd1b(%rip), %rsi     # 0x745f2
movl $0x2f, %edx
movq %rbx, %rdi
callq 0x45a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4520
movsbl %al, %esi
movq 0xa66b6(%rip), %rdi     # 0xacfb8
callq 0x4050
movq %rax, %rdi
callq 0x4370
movq 0xa66a2(%rip), %rbx     # 0xacfb8
leaq 0x6dd05(%rip), %rsi     # 0x74622
movl $0x15, %edx
movq %rbx, %rdi
callq 0x45a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4520
movsbl %al, %esi
movq 0xa6670(%rip), %rdi     # 0xacfb8
callq 0x4050
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x4370
jmp 0x6f71
movq %rsi, %rbx
movl %edi, %ebp
movq 0x8(%rsi), %rsi
leaq 0x118(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x41c0
leaq 0x6dcb4(%rip), %rsi     # 0x74638
leaq 0x118(%rsp), %rdi
callq 0x4110
movl %eax, %r14d
testl %eax, %eax
je 0x6b70
leaq 0x6dc9b(%rip), %rsi     # 0x7463e
leaq 0x118(%rsp), %rdi
callq 0x4110
testl %eax, %eax
je 0x6c9d
leaq 0x6dc89(%rip), %rsi     # 0x74648
leaq 0x118(%rsp), %rdi
callq 0x4110
testl %eax, %eax
jne 0x6f85
cmpl $0x3, %ebp
jg 0x6cbe
leaq 0x168(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x6dc5e(%rip), %rsi     # 0x7464e
leaq 0x6dc62(%rip), %rdx     # 0x74659
leaq 0x158(%rsp), %rdi
callq 0x5d854
leaq 0xa8(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x97a8
movq 0x158(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a2b
callq 0x44e0
leaq 0x38(%rsp), %rdi
movl $0x3, %esi
movl $0x3, %edx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x86d2
movq 0x50(%rsp), %rax
movaps 0x6a6aa(%rip), %xmm0    # 0x71100
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 0x6a66b(%rip), %xmm0    # 0x71110
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 0x6db8f(%rip), %rsi     # 0x7465a
leaq 0x6db9d(%rip), %rdx     # 0x7466f
leaq 0x10(%rsp), %rdi
callq 0x5d854
leaq 0xa8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x5a7c
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x6b02
callq 0x44e0
cmpb $0x0, 0x48(%rsp)
jne 0x6b18
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6b18
callq 0x4680
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
callq 0xa09a
cmpb $0x0, -0x10(%rbx)
jne 0x6b40
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x6b40
callq 0x4680
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa09a
movq -0x20(%rbx), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x6b66
callq 0x44e0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x6f5b
cmpl $0x4, %ebp
jl 0x6ca6
movq 0x10(%rbx), %rsi
leaq 0x1f8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x41c0
leaq 0xa8(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x97a8
leaq 0x208(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6bba
callq 0x44e0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
cmpl $0x5, %ebp
movl $0x4, %r12d
cmovgel %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 0x97a8
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x6c26
callq 0x44e0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x99f8
leaq 0x90(%rsp), %rdi
callq 0xa09a
cmpb $0x0, 0x80(%rsp)
jne 0x6c5c
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x6c5c
callq 0x4680
leaq 0x58(%rsp), %rdi
callq 0xa09a
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x6c7a
callq 0x44e0
incq %r14
cmpq %r14, %r12
jne 0x6bf2
leaq 0xa8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9a60
jmp 0x6f01
cmpl $0x3, %ebp
jg 0x6de2
xorl %edi, %edi
testl %r14d, %r14d
setne %dil
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
callq 0x906e
jmp 0x6f5b
movq 0x10(%rbx), %rsi
leaq 0x1b8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x41c0
leaq 0xa8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x97a8
leaq 0x1c8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6cff
callq 0x44e0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
cmpl $0x5, %ebp
movl $0x4, %r12d
cmovgel %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 0x97a8
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x6d6b
callq 0x44e0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x99f8
leaq 0x90(%rsp), %rdi
callq 0xa09a
cmpb $0x0, 0x80(%rsp)
jne 0x6da1
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x6da1
callq 0x4680
leaq 0x58(%rsp), %rdi
callq 0xa09a
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x6dbf
callq 0x44e0
incq %r14
cmpq %r14, %r12
jne 0x6d37
leaq 0xa8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x65e9
jmp 0x6f01
movq 0x10(%rbx), %rsi
leaq 0x1d8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x41c0
leaq 0xa8(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x97a8
leaq 0x1e8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6e23
callq 0x44e0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
cmpl $0x5, %ebp
movl $0x4, %r12d
cmovgel %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 0x97a8
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
cmpq %rax, %rdi
je 0x6e8f
callq 0x44e0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x99f8
leaq 0x90(%rsp), %rdi
callq 0xa09a
cmpb $0x0, 0x80(%rsp)
jne 0x6ec5
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x6ec5
callq 0x4680
leaq 0x58(%rsp), %rdi
callq 0xa09a
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x6ee3
callq 0x44e0
incq %r14
cmpq %r14, %r12
jne 0x6e5b
leaq 0xa8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9d5c
leaq 0x10(%rsp), %rdi
callq 0x9d34
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
callq 0xa09a
cmpb $0x0, -0x10(%rbx)
jne 0x6f33
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x6f33
callq 0x4680
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa09a
movq -0x20(%rbx), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x6f59
callq 0x44e0
xorl %ebx, %ebx
leaq 0x128(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6f71
callq 0x44e0
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)
movb $0x1, %bpl
leaq 0x6d6cd(%rip), %rsi     # 0x74670
leaq 0x6d6d3(%rip), %rdx     # 0x7467d
movq %r15, %rdi
callq 0x5d854
xorl %ebp, %ebp
leaq 0xa5c25(%rip), %rsi     # 0xacbe0
movq 0xa5fd6(%rip), %rdx     # 0xacf98
movq %r15, %rdi
callq 0x4900
jmp 0x70f3
movq %rdx, %rbx
movq %rax, %r14
leaq 0x1e8(%rsp), %rax
jmp 0x705c
jmp 0x708f
jmp 0x70f3
movq %rdx, %rbx
movq %rax, %r14
leaq 0x208(%rsp), %rax
jmp 0x705c
jmp 0x708f
jmp 0x70f3
movq %rdx, %rbx
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x7020
callq 0x44e0
jmp 0x7020
movq %rdx, %rbx
movq %rax, %r14
cmpb $0x0, 0x48(%rsp)
jne 0x7137
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x7137
callq 0x4680
jmp 0x7137
movq %rdx, %rbx
movq %rax, %r14
jmp 0x7137
movq %rdx, %rbx
movq %rax, %r14
leaq 0x1c8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x7081
jmp 0x7144
movq %rdx, %rbx
movq %rax, %r14
movq 0x158(%rsp), %rdi
cmpq %r15, %rdi
je 0x7144
callq 0x44e0
jmp 0x7144
jmp 0x708f
jmp 0x708f
movq %rdx, %rbx
movq %rax, %r14
jmp 0x7144
movq %rdx, %rbx
movq %rax, %r14
testb %bpl, %bpl
je 0x7144
movq %r15, %rdi
callq 0x43b0
jmp 0x7144
jmp 0x715c
jmp 0x70f3
movq %rdx, %rbx
movq %rax, %r14
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
jmp 0x7111
jmp 0x711d
jmp 0x70f3
movq %rdx, %rbx
movq %rax, %r14
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
jmp 0x7111
jmp 0x711d
movq %rdx, %rbx
movq %rax, %r14
jmp 0x712d
movq %rdx, %rbx
movq %rax, %r14
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x712d
callq 0x44e0
jmp 0x712d
movq %rdx, %rbx
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x9a22
leaq 0x10(%rsp), %rdi
callq 0x9d34
leaq 0xa8(%rsp), %rdi
callq 0x9a22
leaq 0x128(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7162
callq 0x44e0
jmp 0x7162
movq %rdx, %rbx
movq %rax, %r14
cmpl $0x1, %ebx
jne 0x71b9
movq %r14, %rdi
callq 0x41d0
movq %rax, %rbx
movq 0xa5e6f(%rip), %rdi     # 0xacfe8
leaq 0x6d4fe(%rip), %rsi     # 0x7467e
movl $0x7, %edx
callq 0x45a0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xa5e50(%rip), %rdi     # 0xacfe8
callq 0x45a0
movq %rax, %rdi
callq 0x4200
callq 0x48c0
xorl %ebx, %ebx
jmp 0x6f71
movq %rax, %r14
callq 0x48c0
movq %r14, %rdi
callq 0x4950
movq %rax, %rdi
callq 0xa08f
nop