// File: /workspace/github_cpp_makefile_star2_O2/rishabh-battulwar[P]imageprocessing/./src/Main.cpp
// Function: main
int main(int argc, char* argv[])
{
	int width = 512, height = 512;
	int window_size = 3, region_size = 5;
	int sigma = 1, h = 1, sigma_sim = 20;
	float threshold = 20.0, tau = 0.99, epsilon = 0.3, phi = 2;
	int target_width = 700, target_height = 700;
	int iter = 6, percentage = 10;
	//char *type = "color";
	char *method_name = "color_to_bw";
	char *infile = "../images/mandril.raw";
	char *outfile = "../images/mandril_bw.raw";
	if (argc < 3)
		usage(argv[0]);

	for(int i = 1; i < argc; i++)
	{
		if     (!(strcmp(argv[i], "-prob"))) method_name = argv[++i];
		else if(!(strcmp(argv[i], "-i"))) infile = argv[++i];
		else if(!(strcmp(argv[i], "-o"))) outfile = argv[++i];
		//else if(!(strcmp(argv[i], "bw")) || !(strcmp(argv[i], "color"))) type = argv[i];
		else if(!(strcmp(argv[i], "-w"))) width = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-h"))) height = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-tw"))) target_width = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-th"))) target_height = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-ws"))) window_size = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-rs"))) region_size = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-sigma"))) sigma = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-sigma_sim"))) sigma_sim = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-iter"))) iter = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-perc"))) percentage = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-h"))) h = atoi(argv[++i]);
		else if(!(strcmp(argv[i], "-thresh"))) threshold = atof(argv[++i]);
		else if(!(strcmp(argv[i], "-tau"))) tau = atof(argv[++i]);
		else if(!(strcmp(argv[i], "-epsilon"))) epsilon = atof(argv[++i]);
		else if(!(strcmp(argv[i], "-phi"))) phi = atof(argv[++i]);
		else
		{
			std::cerr << "\n Unknown Option : " << argv[i] << std::endl;
			usage(argv[0]);
		}
	}


	if     (!(strcmp(method_name, "color_to_bw"))) 			ImageProc::color_to_bw(infile, outfile, width, height);
	else if(!(strcmp(method_name, "image_resize")))			ImageProc::image_resize(infile, outfile, width, height, target_width, target_height);
	else if(!(strcmp(method_name, "hist_eq_cum")))			ImageProc::hist_equal_cumulative(infile, outfile, width, height);
	else if(!(strcmp(method_name, "hist_equal")))			ImageProc::hist_equal(infile, outfile, width, height);
	else if(!(strcmp(method_name, "oil_paint_effect")))		ImageProc::oil_painting(infile, outfile, width, height, window_size);
	else if(!(strcmp(method_name, "special_effect")))		ImageProc::film_special_effect(infile, outfile, width, height);
	else if(!(strcmp(method_name, "denoising")))			ImageProc::denoising(infile, outfile, width, height, window_size, sigma, threshold);
	else if(!(strcmp(method_name, "bilateral_filter")))		ImageProc::apply_bilateral_filter(infile, outfile, width, height, window_size, sigma, sigma_sim, iter);
	else if(!(strcmp(method_name, "non_local_mean")))		ImageProc::apply_non_local_mean(infile, outfile, width, height, window_size, region_size, sigma, h);
	else if(!(strcmp(method_name, "sobel")))				ImageProc::apply_sobel_operator(infile, outfile, width, height, percentage);
	else if(!(strcmp(method_name, "LoG")))					ImageProc::apply_LoG_operator(infile, outfile, width, height);
	else if(!(strcmp(method_name, "halftone")))				ImageProc::halftoning(infile, width, height);
	else if(!(strcmp(method_name, "color_halftone")))		ImageProc::color_halftoning(infile, outfile, width, height);
	else if(!(strcmp(method_name, "art_effect")))			ImageProc::apply_artistic_effect(infile, outfile, width, height, tau, epsilon, phi, window_size, sigma, sigma_sim, iter);
	else if(!(strcmp(method_name, "fingerprint")))			ImageProc::apply_morphology(infile, outfile, width, height);
	else if(!(strcmp(method_name, "binary")))				ImageProc::apply_binarization(infile, outfile, width, height);
	else if(!(strcmp(method_name, "minutiae")))				ImageProc::apply_minutae_extraction(infile, outfile, width, height);

	else
	{
		std::cout << "method_name doesn't match any method!" << std::endl;
		usage(argv[0]);
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r15
cmpl $0x3, %edi
jl 0xefe8
movl %edi, %ebx
leaq 0x2e3f(%rip), %rax      # 0x116cd
movq %rax, 0x18(%rsp)
leaq 0x2e1d(%rip), %rax      # 0x116b7
movq %rax, 0x10(%rsp)
leaq 0x2e05(%rip), %rax      # 0x116ab
movq %rax, 0x60(%rsp)
pushq $0xa
popq %rax
movl %eax, 0x40(%rsp)
pushq $0x6
popq %rax
movq %rax, 0x50(%rsp)
movl $0x2bc, 0x4c(%rsp)      # imm = 0x2BC
movss 0x1df2(%rip), %xmm0     # 0x106bc
movss %xmm0, 0x3c(%rsp)
movss 0x1de8(%rip), %xmm0     # 0x106c0
movss %xmm0, 0x34(%rsp)
movss 0x1dde(%rip), %xmm0     # 0x106c4
movss %xmm0, 0x38(%rsp)
pushq $0x14
popq %rax
movq %rax, 0x58(%rsp)
pushq $0x1
popq %rax
pushq $0x5
popq %rcx
movl %ecx, 0x44(%rsp)
pushq $0x3
popq %rcx
movl %ecx, 0x24(%rsp)
movl $0x200, 0xc(%rsp)       # imm = 0x200
leaq 0x2dd2(%rip), %r14      # 0x116e6
movl $0x200, 0x8(%rsp)       # imm = 0x200
movl $0x2bc, 0x48(%rsp)      # imm = 0x2BC
movq %rax, 0x28(%rsp)
movl %eax, %r12d
cmpl %ebx, %r12d
jge 0xec0b
movslq %r12d, %r13
movq (%r15,%r13,8), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x21e0
testl %eax, %eax
je 0xeac5
cmpb $0x2d, (%rbp)
jne 0xe995
cmpb $0x69, 0x1(%rbp)
jne 0xe965
cmpb $0x0, 0x2(%rbp)
je 0xeb19
cmpb $0x6f, 0x1(%rbp)
jne 0xe975
cmpb $0x0, 0x2(%rbp)
je 0xeb2b
cmpb $0x77, 0x1(%rbp)
jne 0xe985
cmpb $0x0, 0x2(%rbp)
je 0xeb53
cmpb $0x68, 0x1(%rbp)
jne 0xe995
cmpb $0x0, 0x2(%rbp)
je 0xeb69
movq %rbp, %rdi
leaq 0x2d4d(%rip), %rsi      # 0x116ec
callq 0x21e0
testl %eax, %eax
je 0xead7
movq %rbp, %rdi
leaq 0x2d3a(%rip), %rsi      # 0x116f0
callq 0x21e0
testl %eax, %eax
je 0xeaed
movq %rbp, %rdi
leaq 0x2d27(%rip), %rsi      # 0x116f4
callq 0x21e0
testl %eax, %eax
je 0xeb03
movq %rbp, %rdi
leaq 0x2d14(%rip), %rsi      # 0x116f8
callq 0x21e0
testl %eax, %eax
je 0xeb3d
movq %rbp, %rdi
leaq 0x2d01(%rip), %rsi      # 0x116fc
callq 0x21e0
testl %eax, %eax
je 0xeb7f
movq %rbp, %rdi
leaq 0x2cf1(%rip), %rsi      # 0x11703
callq 0x21e0
testl %eax, %eax
je 0xeb93
movq %rbp, %rdi
leaq 0x2ce5(%rip), %rsi      # 0x1170e
callq 0x21e0
testl %eax, %eax
je 0xeba7
movq %rbp, %rdi
leaq 0x2cd4(%rip), %rsi      # 0x11714
callq 0x21e0
testl %eax, %eax
je 0xebbb
movq %rbp, %rdi
leaq 0x2cc3(%rip), %rsi      # 0x1171a
callq 0x21e0
testl %eax, %eax
je 0xebce
movq %rbp, %rdi
leaq 0x2cb4(%rip), %rsi      # 0x11722
callq 0x21e0
testl %eax, %eax
je 0xebd3
movq %rbp, %rdi
leaq 0x2ca2(%rip), %rsi      # 0x11727
callq 0x21e0
testl %eax, %eax
je 0xebec
movq %rbp, %rdi
leaq 0x2c94(%rip), %rsi      # 0x11730
callq 0x21e0
testl %eax, %eax
jne 0xefc1
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x21b0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x3c(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rax
movq %rax, 0x60(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movl %eax, 0x4c(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movl %eax, 0x48(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movl %eax, 0x24(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rax
movq %rax, 0x10(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rax
movq %rax, 0x18(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movl %eax, 0x44(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movl %eax, 0xc(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movl %eax, 0x8(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movq %rax, 0x28(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movq %rax, 0x58(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movq %rax, 0x50(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x2220
movl %eax, 0x40(%rsp)
jmp 0xec03
incl %r12d
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x21b0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x38(%rsp)
jmp 0xec03
incl %r12d
movq 0x8(%r15,%r13,8), %rdi
callq 0x21b0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x34(%rsp)
incl %r12d
jmp 0xe92c
leaq 0x2a99(%rip), %rsi      # 0x116ab
movq 0x60(%rsp), %rbx
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xedae
leaq 0x2b1b(%rip), %rsi      # 0x11749
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xedca
leaq 0x2b11(%rip), %rsi      # 0x11756
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xedf0
leaq 0x2b06(%rip), %rsi      # 0x11762
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xee0c
leaq 0x2afa(%rip), %rsi      # 0x1176d
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xee28
leaq 0x2af4(%rip), %rsi      # 0x1177e
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xee49
leaq 0x2aec(%rip), %rsi      # 0x1178d
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xee62
leaq 0x2adf(%rip), %rsi      # 0x11797
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xee85
leaq 0x2ad9(%rip), %rsi      # 0x117a8
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xeeb0
leaq 0x2ad1(%rip), %rsi      # 0x117b7
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xeeea
leaq 0x2ac0(%rip), %rsi      # 0x117bd
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xef08
leaq 0x2ab3(%rip), %rsi      # 0x117c7
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xef21
leaq 0x2a96(%rip), %rsi      # 0x117c1
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xef35
leaq 0x2a8e(%rip), %rsi      # 0x117d0
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xef4e
leaq 0x2a82(%rip), %rsi      # 0x117db
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xef8e
leaq 0x2a77(%rip), %rsi      # 0x117e7
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
je 0xefa5
leaq 0x2a67(%rip), %rsi      # 0x117ee
movq %rbx, %rdi
callq 0x21e0
testl %eax, %eax
jne 0xeff0
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0xe1d8
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x62be
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movl 0x4c(%rsp), %r8d
movl 0x48(%rsp), %r9d
callq 0x6418
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x66f8
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x68be
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movl 0x24(%rsp), %r8d
callq 0x6af8
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x6e58
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movl 0x24(%rsp), %r8d
movq 0x28(%rsp), %r9
callq 0x6fc6
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movl 0x24(%rsp), %r8d
movq 0x28(%rsp), %r9
pushq 0x50(%rsp)
pushq 0x60(%rsp)
callq 0x84ca
jmp 0xeed7
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movl 0x24(%rsp), %r8d
movl 0x44(%rsp), %r9d
pushq $0x1
pushq 0x30(%rsp)
callq 0x8c16
popq %rax
popq %rcx
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movl 0x40(%rsp), %r8d
callq 0x943a
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x9df4
jmp 0xeed9
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
movl 0x8(%rsp), %edx
callq 0xa6ca
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0xaf0e
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movss 0x38(%rsp), %xmm0
movss 0x34(%rsp), %xmm1
movss 0x3c(%rsp), %xmm2
movl 0x24(%rsp), %r8d
movq 0x28(%rsp), %r9
pushq 0x50(%rsp)
pushq 0x60(%rsp)
callq 0xbd6c
jmp 0xeed7
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0xc8a4
jmp 0xeed9
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0xe160
jmp 0xeed9
movq 0x6028(%rip), %rdi      # 0x14ff0
leaq 0x2766(%rip), %rsi      # 0x11735
callq 0x2170
movq (%r15,%r13,8), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20c0
movq (%r15), %rdi
callq 0xe42a
movq 0x5fd9(%rip), %rdi      # 0x14fd0
leaq 0x27f9(%rip), %rsi      # 0x117f7
jmp 0xefdb