// File: cssartori[P]ga-qap/src/main.cpp
// Function: read_parameter(int, char**)
void read_parameter(int argc, char **argv){

	if(argc < 3){
		cout << "Usage:\n" << argv[0] << " -f [input file path]" << endl;
		exit(-1);
	}

	int i=1;
	if(argv[i][0] != '-'){
		cout << "Parameter " << argv[i] << "not defined." << endl;
		exit(-1);
	}else if(argv[i][1] != 'f'){
		cout << "Expected first parameter -f [input file path], found " << argv[i] << "." << endl;
		exit(-1);
	}

	i++;
	input_file = argv[i]; //input file path

	for(i=3;i<argc;i++){
		if(argv[i][0] == '-'){
			switch(argv[i][1]){
				case 'p'://population size
					i++;
					pop_size = atoi(argv[i]);
					break;
				case 's'://random seed
					i++;
					seed = atoi(argv[i]);
					break;
				case 'i'://max iterations
					i++;
					max_iterations = atoi(argv[i]);
					break;
				case 'c'://crossover probability
					i++;
					cross_p = atof(argv[i]);
					break;
				case 'k'://tournament size
					i++;
					tournament_size = atoi(argv[i]);
					break;
				case 'o'://output file path
					i++;
					output_file = argv[i];
					break;
				case 'm'://print out allowed
					prints = true;
					break;
				default:
					cout << "Parameter " << argv[i] << "not defined." << endl;
					exit(-1);
			}
		}else{
			cout << "Parameter " << argv[i] << "not defined." << endl;
			exit(-1);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x3, -0x4(%rbp)
jge 0x53df
movq 0x10c3c(%rip), %rdi     # 0x15fd8
leaq 0x9e0b(%rip), %rsi      # 0xf1ae
callq 0x2190
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x2190
movq %rax, %rdi
leaq 0x9df5(%rip), %rsi      # 0xf1b6
callq 0x2190
movq %rax, %rdi
movq 0x10bf8(%rip), %rsi     # 0x15fc8
callq 0x21d0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2230
movl $0x1, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x5449
movq 0x10bd7(%rip), %rdi     # 0x15fd8
leaq 0x9dc4(%rip), %rsi      # 0xf1cc
callq 0x2190
movq %rax, %rdi
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2190
movq %rax, %rdi
leaq 0x9dac(%rip), %rsi      # 0xf1d7
callq 0x2190
movq %rax, %rdi
movq 0x10b8e(%rip), %rsi     # 0x15fc8
callq 0x21d0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2230
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x66, %eax
je 0x54ad
movq 0x10b73(%rip), %rdi     # 0x15fd8
leaq 0x9d78(%rip), %rsi      # 0xf1e4
callq 0x2190
movq %rax, %rdi
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2190
movq %rax, %rdi
leaq 0x9d53(%rip), %rsi      # 0xf1e2
callq 0x2190
movq %rax, %rdi
movq 0x10b2a(%rip), %rsi     # 0x15fc8
callq 0x21d0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2230
jmp 0x54af
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10d0d(%rip)     # 0x161d8
movl $0x3, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x56c4
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x5665
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
addl $-0x63, %eax
movl %eax, %ecx
movq %rcx, -0x20(%rbp)
subl $0x10, %eax
ja 0x5614
movq -0x20(%rbp), %rax
leaq 0x9b95(%rip), %rcx      # 0xf0b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2290
cltq
movq %rax, 0x10c99(%rip)     # 0x161e8
jmp 0x5663
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2290
movl %eax, 0x10c4c(%rip)     # 0x161c0
jmp 0x5663
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2290
cltq
movq %rax, 0x10c0c(%rip)     # 0x161a8
jmp 0x5663
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2250
movsd %xmm0, 0x10bf5(%rip)    # 0x161b8
jmp 0x5663
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2290
cltq
movq %rax, 0x10bc5(%rip)     # 0x161b0
jmp 0x5663
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10bd7(%rip)     # 0x161e0
jmp 0x5663
movb $0x1, 0x10bde(%rip)     # 0x161f0
jmp 0x5663
movq 0x109bd(%rip), %rdi     # 0x15fd8
leaq 0x9baa(%rip), %rsi      # 0xf1cc
callq 0x2190
movq %rax, %rdi
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2190
movq %rax, %rdi
leaq 0x9b92(%rip), %rsi      # 0xf1d7
callq 0x2190
movq %rax, %rdi
movq 0x10974(%rip), %rsi     # 0x15fc8
callq 0x21d0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2230
jmp 0x56b4
movq 0x1096c(%rip), %rdi     # 0x15fd8
leaq 0x9b59(%rip), %rsi      # 0xf1cc
callq 0x2190
movq %rax, %rdi
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2190
movq %rax, %rdi
leaq 0x9b41(%rip), %rsi      # 0xf1d7
callq 0x2190
movq %rax, %rdi
movq 0x10923(%rip), %rsi     # 0x15fc8
callq 0x21d0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2230
jmp 0x56b6
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x54d2
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)