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

	DataFile data;
	if(data.read(input_file) == -1){
		printf("Error opening file \'%s\'.\n", input_file);
		return -1;
	}

	if(pop_size == 0) pop_size = data.n*0.1;

	if(seed == -1) seed = time(NULL);

	Timer t;
	t.start();

	//create and run GA
	GeneticAlgorithm ga(data, pop_size, max_iterations, tournament_size, cross_p, seed, prints);
	Solution best = ga.run();

	t.stop();
	
	if(prints){
		printf("Initial Solution = %i\n", ga.get_initial_solution().fitness());
		printf("Best Solution Found = %i \n", best.fitness());
		printf("Iterations = %li \n", ga.get_iter_best());
		printf("Time = %.2f \n", t.elapsed_seconds());
	}
	
	if(output_file != NULL){
		if(data.write_solution(output_file, best) < 0){
			printf("Failed to save solution to \'%s\'.\n", output_file);
			return -1;
		}
		if(prints)
			printf("Solution saved to \'%s\'.\n", output_file);
	}
	
	if(prints)
		printf("Success!\n");

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x5380
leaq -0x48(%rbp), %rdi
callq 0x24e0
movq 0x112e3(%rip), %rax     # 0x161d8
movq %rax, -0x198(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x22e0
movq -0x198(%rbp), %rsi
movq -0x190(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x56d0
jmp 0x4f25
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x2510
movl %eax, -0x19c(%rbp)
jmp 0x4f3a
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x69(%rbp), %rdi
callq 0x21f0
movl -0x19c(%rbp), %eax
cmpl $-0x1, %eax
jne 0x4fc3
movq 0x1127a(%rip), %rsi     # 0x161d8
leaq 0xa197(%rip), %rdi      # 0xf0fc
xorl %eax, %eax
callq 0x2030
jmp 0x4f6e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x80(%rbp)
jmp 0x5352
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x4fa4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x69(%rbp), %rdi
callq 0x21f0
jmp 0x5367
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5367
cmpq $0x0, 0x1121d(%rip)     # 0x161e8
jne 0x502d
movaps 0xa0ac(%rip), %xmm1     # 0xf080
movq -0x18(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xa0ab(%rip), %xmm1     # 0xf090
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0xa0a4(%rip), %xmm1     # 0xf0a0
mulsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0xa091(%rip), %xmm1     # 0xf0a8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x111bb(%rip)     # 0x161e8
cmpl $-0x1, 0x1118c(%rip)    # 0x161c0
jne 0x5045
xorl %eax, %eax
movl %eax, %edi
callq 0x2180
movl %eax, 0x1117b(%rip)     # 0x161c0
leaq -0x98(%rbp), %rdi
callq 0x5780
jmp 0x5053
leaq -0x98(%rbp), %rdi
callq 0x57c0
jmp 0x5061
movq 0x11180(%rip), %rdx     # 0x161e8
movq 0x11139(%rip), %rcx     # 0x161a8
movq 0x1113a(%rip), %r8      # 0x161b0
movsd 0x1113a(%rip), %xmm0    # 0x161b8
movslq 0x1113b(%rip), %r9      # 0x161c0
movzbl 0x11164(%rip), %esi     # 0x161f0
andl $0x1, %esi
movq %rsp, %rax
movl %esi, (%rax)
leaq -0x120(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9a40
jmp 0x50a6
leaq -0x140(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x9b80
jmp 0x50bb
leaq -0x98(%rbp), %rdi
callq 0x5800
jmp 0x50c9
testb $0x1, 0x11120(%rip)     # 0x161f0
je 0x51e6
leaq -0x160(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xb7b0
jmp 0x50eb
leaq -0x160(%rbp), %rdi
callq 0x5fc0
movl %eax, -0x1a0(%rbp)
jmp 0x50ff
movl -0x1a0(%rbp), %esi
leaq 0xa00a(%rip), %rdi      # 0xf116
xorl %eax, %eax
callq 0x2030
jmp 0x5115
leaq -0x160(%rbp), %rdi
callq 0x5840
leaq -0x140(%rbp), %rdi
callq 0x5fc0
movl %eax, -0x1a4(%rbp)
jmp 0x5135
movl -0x1a4(%rbp), %esi
leaq 0x9feb(%rip), %rdi      # 0xf12d
xorl %eax, %eax
callq 0x2030
jmp 0x514b
leaq -0x120(%rbp), %rdi
callq 0xb810
movq %rax, -0x1b0(%rbp)
jmp 0x5160
movq -0x1b0(%rbp), %rsi
leaq 0x9fda(%rip), %rdi      # 0xf148
xorl %eax, %eax
callq 0x2030
jmp 0x5177
leaq -0x98(%rbp), %rdi
callq 0x5860
movsd %xmm0, -0x1b8(%rbp)
jmp 0x518d
movsd -0x1b8(%rbp), %xmm0
leaq 0x9fbf(%rip), %rdi      # 0xf15b
movb $0x1, %al
callq 0x2030
jmp 0x51a5
jmp 0x51e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5344
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5338
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x5840
jmp 0x5338
cmpq $0x0, 0x10ff2(%rip)     # 0x161e0
je 0x52f5
movq 0x10fe5(%rip), %rax     # 0x161e0
movq %rax, -0x1c8(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x22e0
movq -0x1c8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
leaq -0x180(%rbp), %rdi
callq 0x56d0
jmp 0x5231
leaq -0x48(%rbp), %rdi
leaq -0x180(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x2870
movl %eax, -0x1cc(%rbp)
jmp 0x5250
leaq -0x180(%rbp), %rdi
callq 0x20f0
leaq -0x181(%rbp), %rdi
callq 0x21f0
movl -0x1cc(%rbp), %eax
cmpl $0x0, %eax
jge 0x52d1
movq 0x10f66(%rip), %rsi     # 0x161e0
leaq 0x9ee8(%rip), %rdi      # 0xf169
xorl %eax, %eax
callq 0x2030
jmp 0x528a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x80(%rbp)
jmp 0x531e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x52c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x20f0
leaq -0x181(%rbp), %rdi
callq 0x21f0
jmp 0x5338
testb $0x1, 0x10f18(%rip)     # 0x161f0
je 0x52f3
movq 0x10eff(%rip), %rsi     # 0x161e0
leaq 0x9ea3(%rip), %rdi      # 0xf18b
xorl %eax, %eax
callq 0x2030
jmp 0x52f1
jmp 0x52f3
jmp 0x52f5
testb $0x1, 0x10ef4(%rip)     # 0x161f0
je 0x5310
leaq 0x9e9f(%rip), %rdi      # 0xf1a4
xorl %eax, %eax
callq 0x2030
jmp 0x530e
jmp 0x5310
movl $0x0, -0x4(%rbp)
movl $0x1, -0x80(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x5840
leaq -0x120(%rbp), %rdi
callq 0x58d0
jmp 0x5352
leaq -0x140(%rbp), %rdi
callq 0x5840
leaq -0x120(%rbp), %rdi
callq 0x58d0
jmp 0x5367
leaq -0x48(%rbp), %rdi
callq 0x5900
movl -0x4(%rbp), %eax
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x5900
movq -0x78(%rbp), %rdi
callq 0x22d0
nopl (%rax)