// File: /workspace/github_cpp_makefile_star2_O2/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 0x57f5
movq 0x8a802(%rip), %rdi     # 0x8ffc0
leaq 0x502dd(%rip), %rsi     # 0x55aa2
callq 0x4520
movq %rax, %rdi
callq 0x4200
movq 0x8a7e7(%rip), %rdi     # 0x8ffc0
leaq 0x502f2(%rip), %rsi     # 0x55ad2
callq 0x4520
movq %rax, %rdi
callq 0x4200
pushq $-0x1
popq %rbx
jmp 0x5bec
movq %rsi, %rbx
movl %edi, %ebp
movq 0x8(%rsi), %rsi
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x41c0
leaq 0x502d4(%rip), %rsi     # 0x55ae8
leaq 0x38(%rsp), %rdi
callq 0x7565
movl %eax, %r14d
testb %al, %al
je 0x58da
cmpl $0x4, %ebp
jb 0x58f8
movq 0x10(%rbx), %rsi
leaq 0x198(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
callq 0x41c0
leaq 0x58(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x78e0
leaq 0x198(%rsp), %rdi
callq 0x4aa8
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movl %ebp, %ebp
pushq $0x3
popq %r14
leaq 0x1f8(%rsp), %r15
leaq 0xf(%rsp), %r12
leaq 0xc8(%rsp), %r13
cmpq %r14, %rbp
je 0x5a4c
movq (%rbx,%r14,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x41c0
movq %r13, %rdi
movq %r15, %rsi
callq 0x78e0
movq %r15, %rdi
callq 0x4aa8
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x7a1e
movq %r13, %rdi
callq 0x7a4a
incq %r14
jmp 0x5895
leaq 0x5020d(%rip), %rsi     # 0x55aee
leaq 0x38(%rsp), %rdi
callq 0x7565
testb %al, %al
je 0x590a
cmpl $0x3, %ebp
ja 0x5a60
xorb $0x1, %r14b
movzbl %r14b, %edi
callq 0x7572
jmp 0x5a44
leaq 0x501e7(%rip), %rsi     # 0x55af8
leaq 0x38(%rsp), %rdi
callq 0x7565
testb %al, %al
je 0x5c00
cmpl $0x3, %ebp
ja 0x5b08
leaq 0x501cb(%rip), %rsi     # 0x55afe
leaq 0x158(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
callq 0x41c0
leaq 0x58(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x78e0
leaq 0x158(%rsp), %rdi
callq 0x4aa8
leaq 0xc8(%rsp), %rdi
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
movl %edx, %esi
movl %ecx, %r8d
callq 0x6caa
movq 0xe0(%rsp), %rax
movaps 0x4e762(%rip), %xmm0    # 0x540f0
movups %xmm0, (%rax)
movabsq $-0x3f99400000000000, %rcx # imm = 0xC066C00000000000
movq %rcx, 0x10(%rax)
movl 0xc8(%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 0x4e720(%rip), %xmm0    # 0x54100
movups %xmm0, (%rax,%rdx,8)
leal 0x2(%rcx,%rcx), %ecx
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movq %rdx, (%rax,%rcx,8)
leaq 0x5010d(%rip), %rsi     # 0x55b0a
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x41c0
leaq 0x58(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x4c5c
leaq 0x10(%rsp), %rdi
callq 0x4aa8
leaq 0xc8(%rsp), %rdi
callq 0x6c96
leaq 0x58(%rsp), %rdi
callq 0x7a4a
pushq $-0x1
popq %rbx
jmp 0x5be2
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7a72
jmp 0x5bcc
movq 0x10(%rbx), %rsi
leaq 0x178(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
callq 0x41c0
leaq 0x58(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x78e0
leaq 0x178(%rsp), %rdi
callq 0x4aa8
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movl %ebp, %ebp
pushq $0x3
popq %r14
leaq 0x1d8(%rsp), %r15
leaq 0xf(%rsp), %r12
leaq 0xc8(%rsp), %r13
cmpq %r14, %rbp
je 0x5bac
movq (%rbx,%r14,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x41c0
movq %r13, %rdi
movq %r15, %rsi
callq 0x78e0
movq %r15, %rdi
callq 0x4aa8
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x7a1e
movq %r13, %rdi
callq 0x7a4a
incq %r14
jmp 0x5ac3
movq 0x10(%rbx), %rsi
leaq 0x138(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
callq 0x41c0
leaq 0x58(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x78e0
leaq 0x138(%rsp), %rdi
callq 0x4aa8
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movl %ebp, %ebp
pushq $0x3
popq %r14
leaq 0x1b8(%rsp), %r15
leaq 0xf(%rsp), %r12
leaq 0xc8(%rsp), %r13
cmpq %r14, %rbp
je 0x5bbd
movq (%rbx,%r14,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x41c0
movq %r13, %rdi
movq %r15, %rsi
callq 0x78e0
movq %r15, %rdi
callq 0x4aa8
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x7a1e
movq %r13, %rdi
callq 0x7a4a
incq %r14
jmp 0x5b6b
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7cce
jmp 0x5bcc
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x55ea
leaq 0x10(%rsp), %rdi
callq 0x7cac
leaq 0x58(%rsp), %rdi
callq 0x7a4a
xorl %ebx, %ebx
leaq 0x38(%rsp), %rdi
callq 0x4aa8
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rdi
callq 0x4210
movq %rax, %r15
leaq 0x4ff0e(%rip), %rsi     # 0x55b20
leaq 0x58(%rsp), %rdx
movq %rax, %rdi
callq 0x41c0
leaq 0x89ffa(%rip), %rsi     # 0x8fc20
movq 0x8a37b(%rip), %rdx     # 0x8ffa8
movq %r15, %rdi
callq 0x4910
jmp 0x5d15
jmp 0x5d15
movq %rdx, %rbx
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x4aa8
jmp 0x5c57
movq %rdx, %rbx
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
callq 0x6c96
jmp 0x5d4f
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5d4f
movq %rdx, %rbx
movq %rax, %r14
leaq 0x138(%rsp), %rdi
jmp 0x5ccf
movq %rdx, %rbx
movq %rax, %r14
leaq 0x158(%rsp), %rdi
jmp 0x5ccf
jmp 0x5cdb
movq %rdx, %rbx
movq %rax, %r14
leaq 0x178(%rsp), %rdi
jmp 0x5ccf
jmp 0x5cdb
jmp 0x5cdb
movq %rdx, %rbx
movq %rax, %r14
movq %r15, %rdi
callq 0x4390
jmp 0x5d59
jmp 0x5cdb
jmp 0x5d15
movq %rdx, %rbx
movq %rax, %r14
leaq 0x198(%rsp), %rdi
callq 0x4aa8
jmp 0x5d59
jmp 0x5cdb
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5d59
jmp 0x5d0d
jmp 0x5d15
jmp 0x5d15
movq %rdx, %rbx
movq %rax, %r14
leaq 0x1b8(%rsp), %rdi
jmp 0x5d2b
movq %rdx, %rbx
movq %rax, %r14
leaq 0x1d8(%rsp), %rdi
jmp 0x5d2b
jmp 0x5d32
jmp 0x5d32
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5d63
movq %rdx, %rbx
movq %rax, %r14
jmp 0x5d45
movq %rdx, %rbx
movq %rax, %r14
leaq 0x1f8(%rsp), %rdi
callq 0x4aa8
jmp 0x5d45
movq %rdx, %rbx
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
callq 0x7a4a
leaq 0x10(%rsp), %rdi
callq 0x7cac
leaq 0x58(%rsp), %rdi
callq 0x7a4a
leaq 0x38(%rsp), %rdi
callq 0x4aa8
cmpl $0x1, %ebx
jne 0x5dad
movq %r14, %rdi
callq 0x41d0
movq %rax, %rbx
movq 0x8a276(%rip), %rdi     # 0x8fff0
leaq 0x4fdad(%rip), %rsi     # 0x55b2e
callq 0x4520
movq %rax, %rdi
movq %rbx, %rsi
callq 0x44a0
movq %rax, %rdi
callq 0x4200
callq 0x48d0
xorl %ebx, %ebx
jmp 0x5bec
movq %rax, %r14
callq 0x48d0
movq %r14, %rdi
callq 0x4950
movq %rax, %rdi
callq 0x7f6f
nop