// File: 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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0x81d0
movq %rax, %rsi
leaq 0xf585(%rip), %rdi      # 0x78d2b
movb $0x0, %al
callq 0x8080
movq -0x78(%rbp), %rax
testb $0x1, 0x40(%rax)
jne 0x697de
movl $0x8, %edi
callq 0x8230
movq %rax, %rdi
leaq 0xf58b(%rip), %rax      # 0x78d56
movq %rax, (%rdi)
movq 0x40773(%rip), %rsi     # 0xa9f48
xorl %eax, %eax
movl %eax, %edx
callq 0x8820
movq -0x78(%rbp), %rdi
addq $0x48, %rdi
callq 0x60a70
movq %rax, -0x10(%rbp)
movq -0x78(%rbp), %rdi
addq $0x48, %rdi
callq 0x60900
movq %rax, -0x18(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x6ca70
testb $0x1, %al
jne 0x69813
jmp 0x6984d
leaq -0x10(%rbp), %rdi
callq 0x6cab0
movq (%rax), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
je 0x69840
movq -0x80(%rbp), %rdi
callq 0x553c0
movq -0x80(%rbp), %rdi
movl $0x158, %esi            # imm = 0x158
callq 0x84d0
jmp 0x69842
leaq -0x10(%rbp), %rdi
callq 0x6cad0
jmp 0x697ef
movq -0x78(%rbp), %rdi
addq $0x60, %rdi
callq 0x60a70
movq %rax, -0x20(%rbp)
movq -0x78(%rbp), %rdi
addq $0x60, %rdi
callq 0x60900
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6ca70
testb $0x1, %al
jne 0x69882
jmp 0x698c5
leaq -0x20(%rbp), %rdi
callq 0x6cab0
movq (%rax), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x698b8
movq -0x88(%rbp), %rdi
callq 0x553c0
movq -0x88(%rbp), %rdi
movl $0x158, %esi            # imm = 0x158
callq 0x84d0
jmp 0x698ba
leaq -0x20(%rbp), %rdi
callq 0x6cad0
jmp 0x6985e
movq -0x78(%rbp), %rdi
addq $0x48, %rdi
callq 0x6cc60
movq -0x78(%rbp), %rdi
addq $0x60, %rdi
callq 0x6cc60
movq -0x78(%rbp), %rdi
addq $0x78, %rdi
callq 0x6cc60
movq -0x78(%rbp), %rdi
addq $0x90, %rdi
callq 0x6cc60
movq -0x78(%rbp), %rdi
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x98(%rbp)
movl $0x2, %esi
callq 0x69aa0
movq -0x98(%rbp), %rdi
movslq %eax, %rsi
callq 0x6c970
movq -0x78(%rbp), %rdi
movq %rdi, %rax
addq $0x60, %rax
movq %rax, -0x90(%rbp)
movl $0x3, %esi
callq 0x69aa0
movq -0x90(%rbp), %rdi
movslq %eax, %rsi
callq 0x6c970
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
leaq 0x40b99(%rip), %rcx     # 0xaa4fc
cmpl (%rcx), %eax
jge 0x69a83
movq -0x78(%rbp), %rax
movq 0xa8(%rax), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x60a70
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0x38(%rbp)
movq 0xa8(%rax), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x60900
movq -0x78(%rbp), %rdi
movq %rax, -0x40(%rbp)
addq $0x48, %rdi
callq 0x6ccf0
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x6cc80
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0x50(%rbp)
movq 0xb0(%rax), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x60a70
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0x58(%rbp)
movq 0xb0(%rax), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x60900
movq -0x78(%rbp), %rdi
movq %rax, -0x60(%rbp)
addq $0x60, %rdi
callq 0x6ccf0
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdx
callq 0x6cc80
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0x70(%rbp)
movq 0xa8(%rax), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x6cc60
movq -0x78(%rbp), %rax
movq 0xb0(%rax), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x6cc60
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x69959
movq -0x78(%rbp), %rax
movb $0x0, 0x40(%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)