// File: /workspace/github_cpp_makefile_star2_O3/melop[P]admixem/Population.cpp
// Function: Population::SummarizePhenotype(bool)
void Population::SummarizePhenotype(bool bSetPrevious) {
	vector< string > vPhenotypes;
	SimulConfig.pPhenotypeConfig->GetKeys(vPhenotypes);

	for(vector< string >::iterator it=vPhenotypes.begin(); it != vPhenotypes.end(); ++it) { // go over each key
		string sKey = *it;
		int nPop=0, nMale=0, nFemale=0;
		double nSum=0.0, nSumMale=0.0, nSumFemale=0.0;
		double nMean=0.0, nMeanMale=0.0, nMeanFemale=0.0;
		double nSqrDiffSum=0.0, nSqrDiffSumMale=0.0, nSqrDiffSumFemale=0.0;

		//go over males
		for(vector< Individual *>::iterator itInd = _mpMales.begin(); itInd !=_mpMales.end(); ++itInd ) {
			nPop++;
			nMale++;
			double nVal = (*itInd)->GetPhenotype(sKey);
			double nValSqr = nVal * nVal;
			nSum += nVal;
			nSumMale += nVal;
		}

				//go over females
		for(vector< Individual *>::iterator itInd = _mpFemales.begin(); itInd !=_mpFemales.end(); ++itInd ) {
			nPop++;
			nFemale++;
			double nVal = (*itInd)->GetPhenotype(sKey);
			double nValSqr = nVal * nVal;
			nSum += nVal;
			nSumFemale += nVal;
		}

		nMean = (nPop == 0)? 0.0:  nSum / nPop;
		nMeanMale = (nMale == 0)? 0.0: nSumMale / nMale;
		nMeanFemale = (nFemale == 0) ? 0.0:nSumFemale / nFemale;

		//go over males
		for(vector< Individual *>::iterator itInd = _mpMales.begin(); itInd !=_mpMales.end(); ++itInd ) {
			double nVal = (*itInd)->GetPhenotype(sKey);
			double nDiff = nVal - nMean;
			double nDiffMale = nVal - nMeanMale;
			nSqrDiffSum += nDiff * nDiff;
			nSqrDiffSumMale += nDiffMale * nDiffMale;
		}

				//go over females
		for(vector< Individual *>::iterator itInd = _mpFemales.begin(); itInd !=_mpFemales.end(); ++itInd ) {
			double nVal = (*itInd)->GetPhenotype(sKey);
			double nDiff = nVal - nMean;
			double nDiffFemale = nVal - nMeanFemale;
			nSqrDiffSum += nDiff * nDiff;
			nSqrDiffSumFemale += nDiffFemale * nDiffFemale;
		}

		/* Save the phenotype for the previous generation , used for oblique imprinting*/
		if (bSetPrevious) {
			this->_mpPrevGenSumPhenotype[sKey] = (_mpSumPhenotype.find(sKey) == _mpSumPhenotype.end())? pair< double, double> ( 0.0 , 0.0 ) : this->_mpSumPhenotype[sKey];
			this->_mpPrevGenSumPhenotypeMale[sKey] = (_mpSumPhenotypeMale.find(sKey) == _mpSumPhenotypeMale.end())? pair< double, double> ( 0.0 , 0.0 ) : this->_mpSumPhenotypeMale[sKey]; 
			this->_mpPrevGenSumPhenotypeFemale[sKey] = (_mpSumPhenotypeFemale.find(sKey) == _mpSumPhenotypeFemale.end())? pair< double, double> ( 0.0 , 0.0 ) : this->_mpSumPhenotypeFemale[sKey];  ; 
		}

		this->_mpSumPhenotype[sKey] = pair< double , double >( nMean  , sqrt((nPop==0)? 0.0:(nSqrDiffSum / nPop))); // mean, standard deviation
		this->_mpSumPhenotypeMale[sKey] = pair< double , double >( nMeanMale , sqrt((nMale==0)? 0.0:(nSqrDiffSumMale / nMale)) ); // mean, standard deviation
		this->_mpSumPhenotypeFemale[sKey] = pair< double , double >( nMeanFemale , sqrt((nFemale==0)? 0.0: (nSqrDiffSumFemale / nFemale)) ); // mean, standard deviation

	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movl %esi, 0x7c(%rsp)
movq %rdi, %r14
xorpd %xmm0, %xmm0
leaq 0xe0(%rsp), %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x1ea63(%rip), %rax     # 0x48908
movq 0x10(%rax), %rdi
callq 0x1423c
movq 0xe0(%rsp), %rbx
cmpq 0xe8(%rsp), %rbx
je 0x2a54e
leaq 0x150(%rsp), %r13
leaq 0xb8(%r14), %rax
movq %rax, 0x70(%rsp)
leaq 0xc0(%r14), %rax
movq %rax, 0x128(%rsp)
leaq 0x148(%r14), %rax
movq %rax, 0x120(%rsp)
leaq 0xe8(%r14), %rax
movq %rax, 0x68(%rsp)
leaq 0xf0(%r14), %rax
movq %rax, 0x118(%rsp)
leaq 0x178(%r14), %rax
movq %rax, 0x110(%rsp)
leaq 0x118(%r14), %rax
movq %rax, 0x60(%rsp)
leaq 0x120(%r14), %rax
movq %rax, 0x108(%rsp)
leaq 0x1a8(%r14), %rax
movq %rax, 0x100(%rsp)
leaq 0x40(%rsp), %r15
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xa9b2
movq %rbx, 0x138(%rsp)
movq 0x48(%r14), %r15
cmpq 0x50(%r14), %r15
je 0x2a00f
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
xorl %ebx, %ebx
movq (%r15), %rbp
movq %r13, 0x140(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x140(%rsp), %r12
movq %r12, %rdi
callq 0xa9b2
movq %rbp, %rdi
movq %r12, %rsi
callq 0x25634
movapd %xmm0, %xmm1
movq 0x140(%rsp), %rdi
cmpq %r13, %rdi
je 0x29fed
movq 0x150(%rsp), %rsi
incq %rsi
movapd %xmm1, 0x20(%rsp)
callq 0x7390
movapd 0x20(%rsp), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
movapd 0x10(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0x10(%rsp)
addq $0x8, %r15
incl %ebx
cmpq 0x50(%r14), %r15
jne 0x29f8d
jmp 0x2a01b
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
xorl %ebx, %ebx
movq 0x60(%r14), %r13
movd %ebx, %xmm0
pshufd $0x51, %xmm0, %xmm0     # xmm0 = xmm0[1,0,1,1]
movdqa %xmm0, 0x20(%rsp)
pxor %xmm0, %xmm0
shufpd $0x2, 0x10(%rsp), %xmm0 # xmm0 = xmm0[0],mem[1]
movapd %xmm0, 0x30(%rsp)
cmpq 0x68(%r14), %r13
je 0x2a0f2
movq (%r13), %rbp
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
callq 0xa9b2
movq %rbp, %rdi
movq %r15, %rsi
callq 0x25634
movapd %xmm0, %xmm1
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2a0b8
movq 0xb0(%rsp), %rsi
incq %rsi
movapd %xmm1, (%rsp)
callq 0x7390
movapd (%rsp), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
movapd 0x30(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
addq $0x8, %r13
movdqa 0x20(%rsp), %xmm0
psubd 0xc7b2(%rip), %xmm0     # 0x36890
movdqa %xmm0, 0x20(%rsp)
cmpq 0x68(%r14), %r13
jne 0x2a049
movq 0x50(%r14), %r15
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
xorpd %xmm0, %xmm0
movapd %xmm0, 0xc0(%rsp)
testl %ebx, %ebx
je 0x2a11d
movapd 0x10(%rsp), %xmm0
divsd %xmm1, %xmm0
movapd %xmm0, 0xc0(%rsp)
movsd %xmm1, 0x130(%rsp)
movdqa 0x20(%rsp), %xmm1
pshufd $0x50, %xmm1, %xmm2     # xmm2 = xmm1[0,0,1,1]
xorpd %xmm0, %xmm0
pcmpeqd %xmm0, %xmm2
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movdqa 0xc73b(%rip), %xmm0     # 0x36880
por %xmm0, %xmm1
subpd %xmm0, %xmm1
movapd %xmm1, 0x180(%rsp)
movapd 0x30(%rsp), %xmm0
divpd %xmm1, %xmm0
pandn %xmm0, %xmm2
movq 0x48(%r14), %r12
cmpq %r15, %r12
movdqa %xmm2, 0xd0(%rsp)
je 0x2a22c
movlps 0xc0(%rsp), %xmm2       # xmm2 = mem[0,1],xmm2[2,3]
movaps %xmm2, (%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
leaq 0x170(%rsp), %r15
leaq 0x160(%rsp), %r13
movq (%r12), %rbp
movq %r15, 0x160(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0xa9b2
movq %rbp, %rdi
movq %r13, %rsi
callq 0x25634
movapd %xmm0, %xmm1
movq 0x160(%rsp), %rdi
cmpq %r15, %rdi
je 0x2a1f9
movq 0x170(%rsp), %rsi
incq %rsi
movapd %xmm1, 0x30(%rsp)
callq 0x7390
movapd 0x30(%rsp), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
subpd (%rsp), %xmm1
mulpd %xmm1, %xmm1
movapd 0x10(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0x10(%rsp)
addq $0x8, %r12
cmpq 0x50(%r14), %r12
jne 0x2a1a0
movq 0x68(%r14), %r13
movapd 0x10(%rsp), %xmm0
jmp 0x2a230
xorpd %xmm0, %xmm0
movq 0x60(%r14), %r15
xorpd %xmm1, %xmm1
movapd %xmm0, 0x10(%rsp)
shufpd $0x2, %xmm0, %xmm1      # xmm1 = xmm1[0],xmm0[1]
movapd %xmm1, 0x30(%rsp)
cmpq %r13, %r15
leaq 0x150(%rsp), %r13
je 0x2a2f7
movq (%r15), %rbp
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %r12
movq %r12, %rdi
callq 0xa9b2
movq %rbp, %rdi
movq %r12, %rsi
callq 0x25634
movapd %xmm0, %xmm1
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x2a2c8
movq 0x90(%rsp), %rsi
incq %rsi
movapd %xmm1, (%rsp)
callq 0x7390
movapd (%rsp), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
subpd 0xd0(%rsp), %xmm1
mulpd %xmm1, %xmm1
movapd 0x30(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
addq $0x8, %r15
cmpq 0x68(%r14), %r15
jne 0x2a25a
cmpb $0x0, 0x7c(%rsp)
leaq 0x40(%rsp), %r15
je 0x2a3eb
movq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0x27446
cmpq 0x128(%rsp), %rax
je 0x2a331
movq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0x26884
movupd (%rax), %xmm0
jmp 0x2a335
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq 0x120(%rsp), %rdi
movq %r15, %rsi
callq 0x26884
movapd (%rsp), %xmm0
movupd %xmm0, (%rax)
movq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x27446
cmpq 0x118(%rsp), %rax
je 0x2a37d
movq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x26884
movupd (%rax), %xmm0
jmp 0x2a381
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq 0x110(%rsp), %rdi
movq %r15, %rsi
callq 0x26884
movapd (%rsp), %xmm0
movupd %xmm0, (%rax)
movq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0x27446
cmpq 0x108(%rsp), %rax
je 0x2a3c9
movq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0x26884
movupd (%rax), %xmm0
jmp 0x2a3cd
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq 0x100(%rsp), %rdi
movq %r15, %rsi
callq 0x26884
movapd (%rsp), %xmm0
movupd %xmm0, (%rax)
movdqa 0x20(%rsp), %xmm0
pcmpeqd 0xa637(%rip), %xmm0     # 0x34a30
movdqa %xmm0, 0x20(%rsp)
pextrw $0x2, %xmm0, %eax
xorpd %xmm1, %xmm1
pxor %xmm0, %xmm0
testb $0x1, %al
jne 0x2a42b
movapd 0x30(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movapd 0x180(%rsp), %xmm2
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x2a437
sqrtsd %xmm0, %xmm0
jmp 0x2a43c
callq 0x7728
movsd %xmm0, (%rsp)
movq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0x26884
movaps 0xd0(%rsp), %xmm0
movhps %xmm0, (%rax)
movsd (%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
testl %ebx, %ebx
je 0x2a47e
movapd 0x10(%rsp), %xmm0
divsd 0x130(%rsp), %xmm0
ucomisd %xmm1, %xmm0
movq 0x138(%rsp), %rbx
jb 0x2a492
sqrtsd %xmm0, %xmm0
jmp 0x2a497
callq 0x7728
movsd %xmm0, 0x10(%rsp)
movq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x26884
movaps 0xc0(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movdqa 0x20(%rsp), %xmm0
movd %xmm0, %eax
xorpd %xmm1, %xmm1
pxor %xmm0, %xmm0
testb $0x1, %al
jne 0x2a4e6
movapd 0x30(%rsp), %xmm0
divsd 0x180(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x2a4f2
sqrtsd %xmm0, %xmm0
jmp 0x2a4f7
callq 0x7728
movsd %xmm0, 0x20(%rsp)
movq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0x26884
movaps 0xd0(%rsp), %xmm0
movlps %xmm0, (%rax)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2a53c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x7390
addq $0x20, %rbx
cmpq 0xe8(%rsp), %rbx
jne 0x29f4f
leaq 0xe0(%rsp), %rdi
callq 0x1a6c6
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a581
jmp 0x2a5ed
jmp 0x2a5ed
jmp 0x2a5ed
jmp 0x2a5ed
jmp 0x2a5ed
jmp 0x2a5ed
jmp 0x2a5ed
jmp 0x2a5ed
jmp 0x2a5ed
movq %rax, %rbx
jmp 0x2a62e
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x2a612
movq 0x90(%rsp), %rsi
jmp 0x2a60a
jmp 0x2a5ed
movq %rax, %rbx
movq 0x160(%rsp), %rdi
cmpq %r15, %rdi
je 0x2a612
movq 0x170(%rsp), %rsi
jmp 0x2a60a
jmp 0x2a5ed
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2a612
movq 0xb0(%rsp), %rsi
jmp 0x2a60a
jmp 0x2a5ed
movq %rax, %rbx
jmp 0x2a612
movq %rax, %rbx
movq 0x140(%rsp), %rdi
cmpq %r13, %rdi
je 0x2a612
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x7390
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2a62e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x7390
leaq 0xe0(%rsp), %rdi
callq 0x1a6c6
movq %rbx, %rdi
callq 0x76a0
nop