// File: cssartori[P]ga-qap/src/geneticalgorithm.cpp
// Function: GeneticAlgorithm::run()
Solution GeneticAlgorithm::run(){
	/*Creates an objective function evaluator and a population creator*/
	ObjectiveFunction of(data);

	/*Creates random population as initial set*/
	std::vector<Solution> population = PopulationCreator::random(pop_size, data.n, of, generator);

	/*Local search object*/
	LocalSearch ls(data, of);

	/*Improves locally all the initial solutions*/
	for(size_t i=0;i<population.size();i++){
		population[i] = ls.all_pair_changes(population[i]);
	}
	/*Sorts population in increasing order*/
	sort(population.begin(), population.end());//, comp);
	/*Selects the best solution*/
	Solution best_solution = population[0];
	
	if(prints) printf("Best solution in generation 0:  %i\n", best_solution.fitness());
	
	/*Updates basic information attributes*/
	this->best_solution = best_solution;
	this->initial_solution = best_solution;
	this->iter_best = 0;
	
	/*Initialize basic variables of the GA*/
	size_t u = 1;
	size_t last_mutation = 0;
	int mutation_type = 1;
    size_t generation = 0;
	
	/*GA main loop*/
	while(generation < max_generations){
		generation++;
		std::vector<Solution> offspring;
		while(offspring.size() < pop_size*0.5){
			int except = -1;
			/*Tournament to select parents*/
			Solution p1 = tournament(population, k, except);
			Solution p2 = tournament(population, k, except);

			/*crossover of parents*/
			Solution c = crossover_opt(p1, p2, of);

			/*Evaluate c*/
			//c.set_fitness(of.eval(c));
			
			/*Run a limited local search on the new child*/
			c = ls.limited_iterated_search(c, data.n, generator);	

			offspring.push_back(c);
		}

		/*Sorts offspring in increasing order*/
		sort(offspring.begin(), offspring.end());//, comp);
		/*Inserts the best individuals from offspring in the population as long as they are better than the latter*/
		for(size_t i=0;i<offspring.size();i++){
			if(offspring[i] < population[pop_size-1-i])
				population[pop_size-1-i] = offspring[i];
		}
		
		/*Sorts population in increasing order*/
		sort(population.begin(), population.end());//, comp);
		
		/*In case population has converged*/
		if(population[0] >= best_solution && generation - last_mutation > 100 && generation - iter_best > 200 && mutation_type==1){ 
			/*First try the shift mutation approach*/
			for(size_t i=0;i<pop_size;i++){
				shift_mutation(population[i], u);
				population[i].set_fitness(of.eval(population[i]));
			}
			if(prints) printf("Mutated population with u = %li\n", u);

			u++;
			if(u > data.n){
				/*In case the shift mutation has not done the job, go to the second type*/
				u=1;
				mutation_type=2;
			}

			sort(population.begin(), population.end());//, comp);
			last_mutation = generation;
		}else if(population[0] >= best_solution && generation - last_mutation > 100 && generation - iter_best > 200 && mutation_type==2){
			/*The second approach executes several perturbations in the solutions*/
			if(prints) printf("Perturbing solutions...\n");

			std::uniform_int_distribution<int> rand_place (0,data.n-1);
			
			for(size_t i=0;i<pop_size;i++){
				for(size_t j=0;j<data.n*0.2;j++){
					int r = rand_place(generator);
					int s = rand_place(generator);
					while(r == s) r = rand_place(generator);

					population[i].set_fitness(of.eval_pair_change(population[i], r, s));
				
					int temp = population[i][r];
					population[i][r] = population[i][s];
					population[i][s] = temp;
				}
				
				/*Improves the solutions locally*/
				population[i] = ls.all_pair_changes(population[i]);
			}
			
			sort(population.begin(), population.end());//, comp);
			last_mutation = generation;
			mutation_type = 1;
		}
		
		/*If the new best solution is better than the current one*/
		if(population[0] < best_solution){
			/*Update the current best solution*/
			best_solution = population[0];
			this->best_solution = best_solution;
			this->iter_best = generation;
			u = 1;
			if(prints) printf("Best solution in generation %li:  %i\n", generation, best_solution.fitness());
		}
	}

	/*Finally, return the best solution found*/
	return best_solution;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movq %rdi, -0x268(%rbp)
movq %rdi, %rax
movq %rax, -0x260(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x258(%rbp)
movq (%rax), %rsi
leaq -0x18(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x6510
movq -0x258(%rbp), %r8
movq -0x250(%rbp), %rcx
movq (%r8), %rax
movq 0x10(%r8), %rsi
movq 0x30(%rax), %rdx
subq $-0x80, %r8
leaq -0x30(%rbp), %rdi
callq 0x7060
movq -0x258(%rbp), %rax
movq -0x250(%rbp), %rdx
movq (%rax), %rsi
leaq -0x40(%rbp), %rdi
callq 0x9300
jmp 0x9c04
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x270(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x73c0
movq %rax, %rcx
movq -0x270(%rbp), %rax
cmpq %rcx, %rax
jae 0x9cd4
movq -0x58(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x8c00
jmp 0x9c51
leaq -0x78(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x98(%rbp), %rdx
callq 0x9330
jmp 0x9c67
movq -0x58(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq %rax, %rdi
leaq -0x78(%rbp), %rsi
callq 0x9840
leaq -0x78(%rbp), %rdi
callq 0x5840
leaq -0x98(%rbp), %rdi
callq 0x5840
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x9c0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa90c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5840
jmp 0xa90c
leaq -0x30(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x8d60
movq -0x278(%rbp), %rdi
movq %rax, -0xa0(%rbp)
callq 0x8ba0
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0xb8a0
jmp 0x9d13
movb $0x0, -0xa9(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq -0x268(%rbp), %rdi
movq %rax, %rsi
callq 0x8c00
jmp 0x9d38
movq -0x258(%rbp), %rax
testb $0x1, 0x30(%rax)
je 0x9d82
movq -0x268(%rbp), %rdi
callq 0x5fc0
movl %eax, -0x27c(%rbp)
jmp 0x9d59
movl -0x27c(%rbp), %esi
leaq 0x5522(%rip), %rdi      # 0xf288
xorl %eax, %eax
callq 0x2030
jmp 0x9d6f
jmp 0x9d82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa900
movq -0x268(%rbp), %rsi
movq -0x258(%rbp), %rdi
addq $0x38, %rdi
callq 0x9880
jmp 0x9d9b
movq -0x268(%rbp), %rsi
movq -0x258(%rbp), %rdi
addq $0x58, %rdi
callq 0x9880
jmp 0x9db4
movq -0x258(%rbp), %rax
movq $0x0, 0x78(%rax)
movq $0x1, -0xb8(%rbp)
movq $0x0, -0xc0(%rbp)
movl $0x1, -0xc4(%rbp)
movq $0x0, -0xd0(%rbp)
movq -0x258(%rbp), %rcx
movq -0xd0(%rbp), %rax
cmpq 0x20(%rcx), %rax
jae 0xa8cb
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x7370
leaq -0xe8(%rbp), %rdi
callq 0x73c0
movq %rax, %rcx
movq -0x258(%rbp), %rax
movq %rcx, %xmm1
movaps 0x523a(%rip), %xmm3     # 0xf080
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x523e(%rip), %xmm2     # 0xf090
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq 0x10(%rax), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
movsd 0x53df(%rip), %xmm2     # 0xf260
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xa03a
movq -0x258(%rbp), %rsi
movl $0xffffffff, -0xec(%rbp) # imm = 0xFFFFFFFF
movq 0x18(%rsi), %rcx
leaq -0x110(%rbp), %rdi
leaq -0x30(%rbp), %rdx
leaq -0xec(%rbp), %r8
callq 0xa920
jmp 0x9ebd
movq -0x258(%rbp), %rsi
movq 0x18(%rsi), %rcx
leaq -0x130(%rbp), %rdi
leaq -0x30(%rbp), %rdx
leaq -0xec(%rbp), %r8
callq 0xa920
jmp 0x9ee1
movq -0x258(%rbp), %rsi
leaq -0x150(%rbp), %rdi
leaq -0x110(%rbp), %rdx
leaq -0x130(%rbp), %rcx
leaq -0x18(%rbp), %r8
callq 0xaad0
jmp 0x9f08
leaq -0x190(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x8c00
jmp 0x9f1d
movq -0x258(%rbp), %r8
movq (%r8), %rax
movl 0x30(%rax), %ecx
subq $-0x80, %r8
leaq -0x170(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x190(%rbp), %rdx
callq 0x9470
jmp 0x9f47
leaq -0x150(%rbp), %rdi
movq %rdi, -0x288(%rbp)
leaq -0x170(%rbp), %rsi
movq %rsi, -0x290(%rbp)
callq 0x9840
movq -0x290(%rbp), %rdi
callq 0x5840
leaq -0x190(%rbp), %rdi
callq 0x5840
movq -0x288(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x7620
jmp 0x9f95
leaq -0x150(%rbp), %rdi
callq 0x5840
leaq -0x130(%rbp), %rdi
callq 0x5840
leaq -0x110(%rbp), %rdi
callq 0x5840
jmp 0x9e24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa8bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa029
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa01d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa011
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x5840
leaq -0x150(%rbp), %rdi
callq 0x5840
leaq -0x130(%rbp), %rdi
callq 0x5840
leaq -0x110(%rbp), %rdi
callq 0x5840
jmp 0xa8bd
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x8d60
movq -0x298(%rbp), %rdi
movq %rax, -0x198(%rbp)
callq 0x8ba0
movq %rax, -0x1a0(%rbp)
movq -0x198(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
callq 0xb8a0
jmp 0xa07c
movq $0x0, -0x1a8(%rbp)
movq -0x1a8(%rbp), %rax
movq %rax, -0x2a0(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x73c0
movq %rax, %rcx
movq -0x2a0(%rbp), %rax
cmpq %rcx, %rax
jae 0xa17f
movq -0x1a8(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0xb880
movq %rax, %rcx
movq -0x258(%rbp), %rax
movq %rcx, -0x2b0(%rbp)
movq 0x10(%rax), %rax
movq -0x1a8(%rbp), %rsi
notq %rsi
addq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq -0x2b0(%rbp), %rdi
movq %rax, %rsi
callq 0x6000
movb %al, -0x2a1(%rbp)
jmp 0xa109
movb -0x2a1(%rbp), %al
testb $0x1, %al
jne 0xa115
jmp 0xa166
movq -0x1a8(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0xb880
movq %rax, %rcx
movq -0x258(%rbp), %rax
movq %rcx, -0x2b8(%rbp)
movq 0x10(%rax), %rax
movq -0x1a8(%rbp), %rsi
notq %rsi
addq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq -0x2b8(%rbp), %rsi
movq %rax, %rdi
callq 0x9880
jmp 0xa164
jmp 0xa166
jmp 0xa168
movq -0x1a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1a8(%rbp)
jmp 0xa087
leaq -0x30(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x8d60
movq -0x2c0(%rbp), %rdi
movq %rax, -0x1b0(%rbp)
callq 0x8ba0
movq %rax, -0x1b8(%rbp)
movq -0x1b0(%rbp), %rdi
movq -0x1b8(%rbp), %rsi
callq 0xb8a0
jmp 0xa1be
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq -0x268(%rbp), %rsi
movq %rax, %rdi
callq 0x60c0
movb %al, -0x2c1(%rbp)
jmp 0xa1e2
movb -0x2c1(%rbp), %al
testb $0x1, %al
jne 0xa1f1
jmp 0xa3a7
movq -0xd0(%rbp), %rax
subq -0xc0(%rbp), %rax
cmpq $0x64, %rax
jbe 0xa3a7
movq -0x258(%rbp), %rcx
movq -0xd0(%rbp), %rax
subq 0x78(%rcx), %rax
cmpq $0xc8, %rax
jbe 0xa3a7
cmpl $0x1, -0xc4(%rbp)
jne 0xa3a7
movq $0x0, -0x1c0(%rbp)
movq -0x258(%rbp), %rcx
movq -0x1c0(%rbp), %rax
cmpq 0x10(%rcx), %rax
jae 0xa2f1
movq -0x1c0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq -0x258(%rbp), %rdi
movq %rax, %rsi
movq -0xb8(%rbp), %rdx
callq 0xb4f0
jmp 0xa27f
movq -0x1c0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0xb880
movq -0x2d8(%rbp), %rdi
movq %rax, -0x2d0(%rbp)
movq -0x1c0(%rbp), %rsi
callq 0xb880
movq %rax, %rsi
leaq -0x18(%rbp), %rdi
callq 0x6530
movl %eax, -0x2c8(%rbp)
jmp 0xa2c4
movl -0x2c8(%rbp), %esi
movq -0x2d0(%rbp), %rdi
callq 0x5fe0
jmp 0xa2d8
jmp 0xa2da
movq -0x1c0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1c0(%rbp)
jmp 0xa23f
movq -0x258(%rbp), %rax
testb $0x1, 0x30(%rax)
je 0xa317
movq -0xb8(%rbp), %rsi
leaq 0x4fa0(%rip), %rdi      # 0xf2ac
xorl %eax, %eax
callq 0x2030
jmp 0xa315
jmp 0xa317
movq -0x258(%rbp), %rcx
movq -0xb8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq (%rcx), %rcx
cmpq 0x30(%rcx), %rax
jbe 0xa355
movq $0x1, -0xb8(%rbp)
movl $0x2, -0xc4(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x8d60
movq -0x2e0(%rbp), %rdi
movq %rax, -0x1c8(%rbp)
callq 0x8ba0
movq %rax, -0x1d0(%rbp)
movq -0x1c8(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
callq 0xb8a0
jmp 0xa394
movq -0xd0(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0xa7dc
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq -0x268(%rbp), %rsi
movq %rax, %rdi
callq 0x60c0
movb %al, -0x2e1(%rbp)
jmp 0xa3cb
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0xa3da
jmp 0xa7da
movq -0xd0(%rbp), %rax
subq -0xc0(%rbp), %rax
cmpq $0x64, %rax
jbe 0xa7da
movq -0x258(%rbp), %rcx
movq -0xd0(%rbp), %rax
subq 0x78(%rcx), %rax
cmpq $0xc8, %rax
jbe 0xa7da
cmpl $0x2, -0xc4(%rbp)
jne 0xa7da
movq -0x258(%rbp), %rax
testb $0x1, 0x30(%rax)
je 0xa43c
leaq 0x4e9c(%rip), %rdi      # 0xf2cd
xorl %eax, %eax
callq 0x2030
jmp 0xa43a
jmp 0xa43c
movq -0x258(%rbp), %rax
movq (%rax), %rax
movl 0x30(%rax), %edx
decl %edx
leaq -0x1d8(%rbp), %rdi
xorl %esi, %esi
callq 0x7390
jmp 0xa45b
movq $0x0, -0x1e0(%rbp)
movq -0x258(%rbp), %rcx
movq -0x1e0(%rbp), %rax
cmpq 0x10(%rcx), %rax
jae 0xa783
movq $0x0, -0x1e8(%rbp)
movq -0x258(%rbp), %rax
movq -0x1e8(%rbp), %xmm1
movaps 0x4be1(%rip), %xmm3     # 0xf080
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x4be5(%rip), %xmm2     # 0xf090
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq (%rax), %rax
movq 0x30(%rax), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
movsd 0x4d8b(%rip), %xmm2     # 0xf268
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xa6de
movq -0x258(%rbp), %rsi
subq $-0x80, %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x74a0
movl %eax, -0x2e8(%rbp)
jmp 0xa50a
movq -0x258(%rbp), %rsi
movl -0x2e8(%rbp), %eax
movl %eax, -0x1ec(%rbp)
subq $-0x80, %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x74a0
movl %eax, -0x2ec(%rbp)
jmp 0xa535
movl -0x2ec(%rbp), %eax
movl %eax, -0x1f0(%rbp)
movl -0x1ec(%rbp), %eax
cmpl -0x1f0(%rbp), %eax
jne 0xa57c
movq -0x258(%rbp), %rsi
subq $-0x80, %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x74a0
movl %eax, -0x2f0(%rbp)
jmp 0xa56e
movl -0x2f0(%rbp), %eax
movl %eax, -0x1ec(%rbp)
jmp 0xa541
movq -0x1e0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0xb880
movq -0x308(%rbp), %rdi
movq %rax, -0x300(%rbp)
movq -0x1e0(%rbp), %rsi
callq 0xb880
movq %rax, %rsi
movslq -0x1ec(%rbp), %rdx
movslq -0x1f0(%rbp), %rcx
leaq -0x18(%rbp), %rdi
callq 0x6640
movl %eax, -0x2f4(%rbp)
jmp 0xa5cf
movl -0x2f4(%rbp), %esi
movq -0x300(%rbp), %rdi
callq 0x5fe0
jmp 0xa5e3
movq -0x1e0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq %rax, %rdi
movl -0x1ec(%rbp), %esi
callq 0x5f60
movq %rax, -0x310(%rbp)
jmp 0xa60a
movq -0x310(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1f4(%rbp)
movq -0x1e0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq %rax, %rdi
movl -0x1f0(%rbp), %esi
callq 0x5f60
movq %rax, -0x318(%rbp)
jmp 0xa640
movq -0x318(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x324(%rbp)
movq -0x1e0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq %rax, %rdi
movl -0x1ec(%rbp), %esi
callq 0x5f60
movq %rax, -0x320(%rbp)
jmp 0xa676
movq -0x320(%rbp), %rax
movl -0x324(%rbp), %ecx
movl %ecx, (%rax)
movl -0x1f4(%rbp), %eax
movl %eax, -0x334(%rbp)
movq -0x1e0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq %rax, %rdi
movl -0x1f0(%rbp), %esi
callq 0x5f60
movq %rax, -0x330(%rbp)
jmp 0xa6b8
movq -0x330(%rbp), %rax
movl -0x334(%rbp), %ecx
movl %ecx, (%rax)
movq -0x1e8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1e8(%rbp)
jmp 0xa489
movq -0x1e0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x8c00
jmp 0xa6ff
leaq -0x218(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x238(%rbp), %rdx
callq 0x9330
jmp 0xa718
movq -0x1e0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq %rax, %rdi
leaq -0x218(%rbp), %rsi
callq 0x9840
leaq -0x218(%rbp), %rdi
callq 0x5840
leaq -0x238(%rbp), %rdi
callq 0x5840
movq -0x1e0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1e0(%rbp)
jmp 0xa466
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x5840
jmp 0xa8bd
leaq -0x30(%rbp), %rdi
movq %rdi, -0x340(%rbp)
callq 0x8d60
movq -0x340(%rbp), %rdi
movq %rax, -0x240(%rbp)
callq 0x8ba0
movq %rax, -0x248(%rbp)
movq -0x240(%rbp), %rdi
movq -0x248(%rbp), %rsi
callq 0xb8a0
jmp 0xa7c2
movq -0xd0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl $0x1, -0xc4(%rbp)
jmp 0xa7dc
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq -0x268(%rbp), %rsi
movq %rax, %rdi
callq 0x6000
movb %al, -0x341(%rbp)
jmp 0xa800
movb -0x341(%rbp), %al
testb $0x1, %al
jne 0xa80f
jmp 0xa8ac
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xb880
movq -0x268(%rbp), %rdi
movq %rax, %rsi
callq 0x9880
jmp 0xa82d
movq -0x268(%rbp), %rsi
movq -0x258(%rbp), %rdi
addq $0x38, %rdi
callq 0x9880
jmp 0xa846
movq -0x258(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rcx, 0x78(%rax)
movq $0x1, -0xb8(%rbp)
testb $0x1, 0x30(%rax)
je 0xa8aa
movq -0x268(%rbp), %rdi
movq -0xd0(%rbp), %rax
movq %rax, -0x350(%rbp)
callq 0x5fc0
movl %eax, -0x348(%rbp)
jmp 0xa88b
movl -0x348(%rbp), %edx
movq -0x350(%rbp), %rsi
leaq 0x4a47(%rip), %rdi      # 0xf2e6
xorl %eax, %eax
callq 0x2030
jmp 0xa8a8
jmp 0xa8aa
jmp 0xa8ac
leaq -0xe8(%rbp), %rdi
callq 0x76b0
jmp 0x9dee
leaq -0xe8(%rbp), %rdi
callq 0x76b0
jmp 0xa900
movb $0x1, -0xa9(%rbp)
testb $0x1, -0xa9(%rbp)
jne 0xa8e7
movq -0x268(%rbp), %rdi
callq 0x5840
leaq -0x30(%rbp), %rdi
callq 0x76b0
movq -0x260(%rbp), %rax
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
movq -0x268(%rbp), %rdi
callq 0x5840
leaq -0x30(%rbp), %rdi
callq 0x76b0
movq -0x48(%rbp), %rdi
callq 0x22d0
nop