// File: /workspace/github_cpp_makefile_star2_O1/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 0xb650(%rip), %rdi      # 0x37a52
xorl %eax, %eax
callq 0x7060
cmpb $0x0, 0x40(%rbx)
je 0x2c5cf
movq 0x48(%rbx), %r15
cmpq 0x50(%rbx), %r15
je 0x2c440
movq (%r15), %r14
testq %r14, %r14
je 0x2c43a
movq %r14, %rdi
callq 0x21dfc
movl $0x158, %esi            # imm = 0x158
movq %r14, %rdi
callq 0x7390
addq $0x8, %r15
jmp 0x2c417
movq 0x60(%rbx), %r15
cmpq 0x68(%rbx), %r15
je 0x2c46d
movq (%r15), %r14
testq %r14, %r14
je 0x2c467
movq %r14, %rdi
callq 0x21dfc
movl $0x158, %esi            # imm = 0x158
movq %r14, %rdi
callq 0x7390
addq $0x8, %r15
jmp 0x2c444
movq 0x48(%rbx), %rax
cmpq %rax, 0x50(%rbx)
je 0x2c47b
movq %rax, 0x50(%rbx)
movq 0x60(%rbx), %rax
cmpq %rax, 0x68(%rbx)
je 0x2c489
movq %rax, 0x68(%rbx)
movq 0x78(%rbx), %rax
cmpq %rax, 0x80(%rbx)
je 0x2c49d
movq %rax, 0x80(%rbx)
movq 0x90(%rbx), %rax
cmpq %rax, 0x98(%rbx)
je 0x2c4b4
movq %rax, 0x98(%rbx)
leaq 0x48(%rbx), %r14
leaq 0x1cefd(%rip), %r12     # 0x493bc
movslq (%r12), %rcx
xorl %esi, %esi
testq %rcx, %rcx
jle 0x2c4f6
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 0x2c4db
movslq %esi, %rsi
leaq 0x60(%rbx), %r15
movq %r14, %rdi
callq 0x2e7cc
movslq (%r12), %rcx
xorl %esi, %esi
testq %rcx, %rcx
jle 0x2c539
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 0x2c51e
movslq %esi, %rsi
movq %r15, %rdi
callq 0x2e7cc
cmpl $0x0, (%r12)
jle 0x2c5bc
movl $0x8, %r13d
xorl %ebp, %ebp
movq 0xa8(%rbx), %rax
movq -0x8(%rax,%r13), %rdi
movq (%rax,%r13), %rsi
movq %r14, %rdx
callq 0x2e95a
movq 0xb0(%rbx), %rax
movq -0x8(%rax,%r13), %rdi
movq (%rax,%r13), %rsi
movq %r15, %rdx
callq 0x2e95a
movq 0xa8(%rbx), %rax
movq -0x8(%rax,%r13), %rcx
cmpq %rcx, (%rax,%r13)
je 0x2c596
movq %rcx, (%rax,%r13)
movq 0xb0(%rbx), %rax
movq -0x8(%rax,%r13), %rcx
cmpq %rcx, (%rax,%r13)
je 0x2c5ac
movq %rcx, (%rax,%r13)
incq %rbp
movslq (%r12), %rax
addq $0x18, %r13
cmpq %rax, %rbp
jl 0x2c550
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 0xb49d(%rip), %rcx      # 0x37a7d
movq %rcx, (%rax)
movq 0x1c94e(%rip), %rsi     # 0x48f38
movq %rax, %rdi
xorl %edx, %edx
callq 0x7660