// File: /workspace/github_cpp_makefile_star2_O3/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 0xaaca(%rip), %rdi      # 0x36a5a
xorl %eax, %eax
callq 0x7060
cmpb $0x0, 0x40(%rbx)
je 0x2c163
movq 0x48(%rbx), %r12
cmpq 0x50(%rbx), %r12
je 0x2bfcf
movq (%r12), %r14
testq %r14, %r14
je 0x2bfbc
movq %r14, %rdi
callq 0x21e10
movl $0x158, %esi            # imm = 0x158
movq %r14, %rdi
callq 0x7390
addq $0x8, %r12
jmp 0x2bfa5
leaq 0x48(%rbx), %r14
movq 0x60(%rbx), %r13
cmpq 0x68(%rbx), %r13
je 0x2c009
movq (%r13), %r15
testq %r15, %r15
je 0x2bfee
movq %r15, %rdi
callq 0x21e10
movl $0x158, %esi            # imm = 0x158
movq %r15, %rdi
callq 0x7390
addq $0x8, %r13
cmpq 0x68(%rbx), %r13
jne 0x2bfdd
movq 0x50(%rbx), %r12
leaq 0x60(%rbx), %r15
movq (%r14), %rax
cmpq %rax, %r12
je 0x2c019
movq %rax, 0x50(%rbx)
movq (%r15), %rax
cmpq %rax, %r13
je 0x2c025
movq %rax, 0x68(%rbx)
movq 0x78(%rbx), %rax
cmpq %rax, 0x80(%rbx)
je 0x2c039
movq %rax, 0x80(%rbx)
movq 0x90(%rbx), %rax
cmpq %rax, 0x98(%rbx)
je 0x2c050
movq %rax, 0x98(%rbx)
leaq 0x1c365(%rip), %r12     # 0x483bc
movslq (%r12), %rcx
xorl %esi, %esi
testq %rcx, %rcx
jle 0x2c08e
movq 0xa8(%rbx), %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
movq 0x8(%rax,%rdx), %rdi
subq (%rax,%rdx), %rdi
shrq $0x3, %rdi
addl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x2c073
movslq %esi, %rsi
movq %r14, %rdi
callq 0x2e33a
movslq (%r12), %rcx
xorl %esi, %esi
testq %rcx, %rcx
jle 0x2c0cd
movq 0xb0(%rbx), %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
movq 0x8(%rax,%rdx), %rdi
subq (%rax,%rdx), %rdi
shrq $0x3, %rdi
addl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x2c0b2
movslq %esi, %rsi
movq %r15, %rdi
callq 0x2e33a
cmpl $0x0, (%r12)
jle 0x2c150
movq 0xa8(%rbx), %rax
movl $0x8, %r13d
xorl %ebp, %ebp
movq -0x8(%rax,%r13), %rdi
movq (%rax,%r13), %rsi
movq %r14, %rdx
callq 0x2e4ce
movq 0xb0(%rbx), %rax
movq -0x8(%rax,%r13), %rdi
movq (%rax,%r13), %rsi
movq %r15, %rdx
callq 0x2e4ce
movq 0xa8(%rbx), %rax
movq -0x8(%rax,%r13), %rcx
cmpq %rcx, (%rax,%r13)
je 0x2c12a
movq %rcx, (%rax,%r13)
movq 0xb0(%rbx), %rcx
movq -0x8(%rcx,%r13), %rdx
cmpq %rdx, (%rcx,%r13)
je 0x2c140
movq %rdx, (%rcx,%r13)
incq %rbp
movslq (%r12), %rcx
addq $0x18, %r13
cmpq %rcx, %rbp
jl 0x2c0eb
movb $0x0, 0x40(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x7180
leaq 0xa911(%rip), %rcx      # 0x36a85
movq %rcx, (%rax)
movq 0x1bdba(%rip), %rsi     # 0x47f38
movq %rax, %rdi
xorl %edx, %edx
callq 0x7660