// File: cssartori[P]ga-qap/src/populationcreator.cpp
// Function: PopulationCreator::random(unsigned long, unsigned long, ObjectiveFunction const&, std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul>&)
std::vector<Solution> PopulationCreator::random(const size_t max_pop_size, const size_t n, const ObjectiveFunction& of, std::default_random_engine& generator){
	std::vector<Solution> population;
	std::uniform_int_distribution<int> randn(0, n-1);
	
	/*While population is smaller than the parameter 'population size'*/
	while(population.size() < max_pop_size){
		std::vector<int> individual;
		std::vector<bool> used(n, false);
		
		/*While individual doesn't have n locations in it*/
		while(individual.size() < n){
			int r = randn(generator);
			if(not used[r]){
				individual.push_back(r);
				used[r] = true;
			}
		}

		Solution si(individual);
		si.set_fitness(of.eval(si));
		population.push_back(si);
	}
	
	return population;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0xf8(%rbp)
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
callq 0x7370
movl -0x18(%rbp), %edx
decl %edx
leaq -0x34(%rbp), %rdi
xorl %esi, %esi
callq 0x7390
jmp 0x70ab
jmp 0x70ad
movq -0xf8(%rbp), %rdi
callq 0x73c0
cmpq -0x10(%rbp), %rax
jae 0x7335
leaq -0x60(%rbp), %rdi
callq 0x6100
movq -0x18(%rbp), %rax
movq %rax, -0x108(%rbp)
movb $0x0, -0x89(%rbp)
leaq -0x8a(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x73e0
movq -0x108(%rbp), %rsi
movq -0x100(%rbp), %rcx
leaq -0x88(%rbp), %rdi
leaq -0x89(%rbp), %rdx
callq 0x7400
jmp 0x7114
leaq -0x8a(%rbp), %rdi
callq 0x7480
leaq -0x60(%rbp), %rdi
callq 0x42c0
cmpq -0x18(%rbp), %rax
jae 0x7252
movq -0x28(%rbp), %rsi
leaq -0x34(%rbp), %rdi
callq 0x74a0
movl %eax, -0x10c(%rbp)
jmp 0x7148
movl -0x10c(%rbp), %eax
movl %eax, -0x90(%rbp)
movslq -0x90(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x74d0
movq %rdx, -0x120(%rbp)
movq %rax, -0x118(%rbp)
jmp 0x7177
movq -0x120(%rbp), %rax
movq -0x118(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movq %rax, -0x98(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x7530
xorb $-0x1, %al
testb $0x1, %al
jne 0x71aa
jmp 0x724d
leaq -0x60(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x7560
jmp 0x71bc
movslq -0x90(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x74d0
movq %rdx, -0x130(%rbp)
movq %rax, -0x128(%rbp)
jmp 0x71df
movq -0x130(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x75d0
jmp 0x724d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x735b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x8a(%rbp), %rdi
callq 0x7480
jmp 0x732a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x731e
jmp 0x7120
leaq -0xe8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4cc0
jmp 0x7264
leaq -0xd0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x5ed0
jmp 0x7279
leaq -0xe8(%rbp), %rdi
callq 0x2c50
movq -0x20(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x6530
movl %eax, -0x134(%rbp)
jmp 0x729d
movl -0x134(%rbp), %esi
leaq -0xd0(%rbp), %rdi
callq 0x5fe0
jmp 0x72b1
movq -0xf8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x7620
jmp 0x72c6
leaq -0xd0(%rbp), %rdi
callq 0x5840
leaq -0x88(%rbp), %rdi
callq 0x7690
leaq -0x60(%rbp), %rdi
callq 0x2c50
jmp 0x70ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x2c50
jmp 0x731e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x5840
leaq -0x88(%rbp), %rdi
callq 0x7690
leaq -0x60(%rbp), %rdi
callq 0x2c50
jmp 0x735b
movb $0x1, -0x29(%rbp)
testb $0x1, -0x29(%rbp)
jne 0x734b
movq -0xf8(%rbp), %rdi
callq 0x76b0
movq -0xf0(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0xf8(%rbp), %rdi
callq 0x76b0
movq -0x40(%rbp), %rdi
callq 0x22d0