// File: /workspace/github_cpp_makefile_star2_O2/melop[P]admixem/Population.cpp
// Function: Population::KillOldGen()
void Population::KillOldGen() { //

	printf("Pop %s's old generation was killed off...\n", _sPopName.c_str());

	if (!this->_bBred) { // the pop hasn't bred yet. don't kill the old ones!!
		throw "There is no new generation, so cannot kill the olds";
	}

	for (vector<Individual *>::iterator itMale = _mpMales.begin(); itMale!=_mpMales.end(); ++itMale) {
		delete (*itMale);
	}

	for (vector<Individual *>::iterator itFemale = _mpFemales.begin(); itFemale!=_mpFemales.end(); ++itFemale) {
		delete (*itFemale);
	}

	_mpMales.clear();
	_mpFemales.clear();
	_mpImCacheMales.clear();
	_mpImCacheFemales.clear();

	//printf("_mpNewGenMales.size() %d\n", _mpNewGenMales.size());
	//printf("_mpNewGenFemales.size() %d\n", _mpNewGenFemales.size());
	_mpMales.reserve(this->GetPopSize(2));
	_mpFemales.reserve(this->GetPopSize(3));

	for(int nCpu=0; nCpu<nTotalCPUCore;nCpu++) {
		copy(_mpvNewGenMales[nCpu].begin(), _mpvNewGenMales[nCpu].end(), back_inserter(_mpMales));
		copy(_mpvNewGenFemales[nCpu].begin(), _mpvNewGenFemales[nCpu].end(), back_inserter(_mpFemales));

		_mpvNewGenMales[nCpu].clear();
		_mpvNewGenFemales[nCpu].clear();
	}
	//printf("_mpMales.size() %d\n", _mpMales.size());
	//printf("_mpFemales.size() %d\n", _mpFemales.size());
	
	this->_bBred = false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rsi
leaq 0x7e86(%rip), %rdi      # 0x2fa2a
xorl %eax, %eax
callq 0x7050
cmpb $0x0, 0x40(%rbx)
je 0x27d19
leaq 0x48(%rbx), %r14
movq 0x48(%rbx), %r12
cmpq 0x50(%rbx), %r12
je 0x27be7
movq (%r12), %r15
testq %r15, %r15
je 0x27bd4
movq %r15, %rdi
callq 0x1fc0e
movl $0x158, %esi            # imm = 0x158
movq %r15, %rdi
callq 0x7400
addq $0x8, %r12
jmp 0x27bbd
leaq 0x60(%rbx), %r15
movq 0x60(%rbx), %r13
cmpq 0x68(%rbx), %r13
je 0x27c19
movq (%r13), %r12
testq %r12, %r12
je 0x27c06
movq %r12, %rdi
callq 0x1fc0e
movl $0x158, %esi            # imm = 0x158
movq %r12, %rdi
callq 0x7400
addq $0x8, %r13
jmp 0x27bef
movq 0x48(%rbx), %rax
cmpq %rax, 0x50(%rbx)
je 0x27c27
movq %rax, 0x50(%rbx)
movq (%r15), %rax
cmpq %rax, %r13
je 0x27c33
movq %rax, 0x68(%rbx)
movq 0x78(%rbx), %rax
cmpq %rax, 0x80(%rbx)
je 0x27c47
movq %rax, 0x80(%rbx)
movq 0x90(%rbx), %rax
cmpq %rax, 0x98(%rbx)
je 0x27c5e
movq %rax, 0x98(%rbx)
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x27d3c
movslq %eax, %rsi
movq %r14, %rdi
callq 0x29544
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x27d3c
movslq %eax, %rsi
movq %r15, %rdi
callq 0x29544
pushq $0x8
popq %r12
xorl %r13d, %r13d
leaq 0x1d74c(%rip), %rbp     # 0x453e4
movslq (%rbp), %rax
cmpq %rax, %r13
jge 0x27d06
movq 0xa8(%rbx), %rax
movq -0x8(%rax,%r12), %rdi
movq (%rax,%r12), %rsi
movq %r14, %rdx
callq 0x29736
movq 0xb0(%rbx), %rax
movq -0x8(%rax,%r12), %rdi
movq (%rax,%r12), %rsi
movq %r15, %rdx
callq 0x29736
movq 0xa8(%rbx), %rax
movq -0x8(%rax,%r12), %rcx
cmpq %rcx, (%rax,%r12)
je 0x27ce7
movq %rcx, (%rax,%r12)
movq 0xb0(%rbx), %rax
movq -0x8(%rax,%r12), %rcx
cmpq %rcx, (%rax,%r12)
je 0x27cfd
movq %rcx, (%rax,%r12)
incq %r13
addq $0x18, %r12
jmp 0x27c98
movb $0x0, 0x40(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x71d0
leaq 0x7d2d(%rip), %rcx      # 0x2fa55
movq %rcx, (%rax)
movq 0x1d21e(%rip), %rsi     # 0x44f50
movq %rax, %rdi
xorl %edx, %edx
callq 0x76a0