// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1b8, %rsp            # imm = 0x1B8
movl %esi, 0x6c(%rsp)
movq %rdi, %r14
leaq 0xd0(%rsp), %rsi
andq $0x0, 0x10(%rsi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsi)
leaq 0x1f68c(%rip), %rax     # 0x45938
movq 0x10(%rax), %rdi
callq 0x125dc
movq 0xd0(%rsp), %rsi
leaq 0xb8(%r14), %rax
movq %rax, 0x60(%rsp)
leaq 0xc0(%r14), %rax
movq %rax, 0xb0(%rsp)
leaq 0x148(%r14), %rax
movq %rax, 0xa8(%rsp)
leaq 0xe8(%r14), %rax
movq %rax, 0x58(%rsp)
leaq 0xf0(%r14), %rax
movq %rax, 0xa0(%rsp)
leaq 0x178(%r14), %rax
movq %rax, 0x98(%rsp)
leaq 0x118(%r14), %rax
movq %rax, 0x50(%rsp)
leaq 0x120(%r14), %rax
movq %rax, 0x90(%rsp)
leaq 0x1a8(%r14), %rax
movq %rax, 0x88(%rsp)
leaq 0x198(%rsp), %rbx
movq %r14, 0xc8(%rsp)
cmpq 0xd8(%rsp), %rsi
je 0x267ec
movq %rbx, %rdi
movq %rsi, 0xc0(%rsp)
callq 0x7550
movq 0x48(%r14), %r13
xorpd %xmm1, %xmm1
xorl %ebp, %ebp
cmpq 0x50(%r14), %r13
movapd %xmm1, 0x30(%rsp)
je 0x263cb
movq (%r13), %r12
leaq 0x178(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7550
movq %r12, %rdi
movq %r15, %rsi
callq 0x2242e
movq %r15, %rdi
movapd %xmm0, 0x10(%rsp)
callq 0x71a0
movapd 0x10(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd 0x30(%rsp), %xmm1
addpd %xmm0, %xmm1
addq $0x8, %r13
incl %ebp
jmp 0x26373
movq 0x60(%r14), %r13
movl %ebp, 0x2c(%rsp)
movd %ebp, %xmm0
pshufd $0x51, %xmm0, %xmm0     # xmm0 = xmm0[1,0,1,1]
movdqa %xmm0, 0x10(%rsp)
xorpd %xmm3, %xmm3
shufpd $0x2, %xmm1, %xmm3      # xmm3 = xmm3[0],xmm1[1]
leaq 0x138(%rsp), %r15
leaq 0x158(%rsp), %rbp
cmpq 0x68(%r14), %r13
je 0x2645b
movapd %xmm3, 0x40(%rsp)
movq (%r13), %r12
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x7550
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2242e
movq %rbp, %rdi
movdqa %xmm0, (%rsp)
callq 0x71a0
movapd (%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd 0x40(%rsp), %xmm3
addpd %xmm0, %xmm3
addq $0x8, %r13
movdqa 0x10(%rsp), %xmm0
psubd 0x940d(%rip), %xmm0     # 0x2f860
movdqa %xmm0, 0x10(%rsp)
jmp 0x263fb
movl 0x2c(%rsp), %eax
cvtsi2sd %eax, %xmm0
xorpd %xmm2, %xmm2
testl %eax, %eax
je 0x26475
movapd 0x30(%rsp), %xmm2
divsd %xmm0, %xmm2
movsd %xmm0, 0xb8(%rsp)
movdqa 0x10(%rsp), %xmm0
pshufd $0x50, %xmm0, %xmm1     # xmm1 = xmm0[0,0,1,1]
pcmpeqd 0x754f(%rip), %xmm1     # 0x2d9e0
cvtdq2pd %xmm0, %xmm0
movapd %xmm0, 0xf0(%rsp)
divpd %xmm0, %xmm3
pandn %xmm3, %xmm1
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq 0x48(%r14), %r13
movdqa %xmm1, 0x70(%rsp)
movapd %xmm2, 0x100(%rsp)
movsd %xmm2, %xmm1            # xmm1 = xmm2[0],xmm1[1]
movapd %xmm1, (%rsp)
cmpq 0x50(%r14), %r13
je 0x26527
movq (%r13), %r12
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7550
movq %r12, %rdi
movq %r15, %rsi
callq 0x2242e
movq %r15, %rdi
movapd %xmm0, 0x40(%rsp)
callq 0x71a0
movapd 0x40(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
subpd (%rsp), %xmm0
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
movapd 0x30(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
addq $0x8, %r13
jmp 0x264cc
movq 0x60(%r14), %rax
xorpd %xmm0, %xmm0
shufpd $0x2, 0x30(%rsp), %xmm0 # xmm0 = xmm0[0],mem[1]
movapd %xmm0, 0x40(%rsp)
cmpq 0x68(%r14), %rax
je 0x265b7
movq %rbp, %r14
movq %rbx, %rsi
movq %r15, %rbp
movq %rax, %r13
movq (%rax), %r12
leaq 0x118(%rsp), %r15
movq %r15, %rdi
callq 0x7550
movq %r12, %rdi
movq %r15, %rsi
callq 0x2242e
movq %r15, %rdi
movapd %xmm0, (%rsp)
callq 0x71a0
movapd (%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
subpd 0x70(%rsp), %xmm0
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
movapd 0x40(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0x40(%rsp)
movq %r13, %rax
addq $0x8, %rax
movq %rbp, %r15
movq %r14, %rbp
movq 0xc8(%rsp), %r14
jmp 0x2653c
cmpb $0x0, 0x6c(%rsp)
movl 0x2c(%rsp), %r15d
je 0x266ab
movq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x24054
cmpq 0xb0(%rsp), %rax
je 0x265f1
movq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x2322c
movupd (%rax), %xmm0
jmp 0x265f5
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq 0xa8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2322c
movapd (%rsp), %xmm0
movupd %xmm0, (%rax)
movq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x24054
cmpq 0xa0(%rsp), %rax
je 0x2663d
movq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x2322c
movupd (%rax), %xmm0
jmp 0x26641
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq 0x98(%rsp), %rdi
movq %rbx, %rsi
callq 0x2322c
movapd (%rsp), %xmm0
movupd %xmm0, (%rax)
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x24054
cmpq 0x90(%rsp), %rax
je 0x26689
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x2322c
movupd (%rax), %xmm0
jmp 0x2668d
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq 0x88(%rsp), %rdi
movq %rbx, %rsi
callq 0x2322c
movapd (%rsp), %xmm0
movupd %xmm0, (%rax)
movdqa 0x10(%rsp), %xmm0
pcmpeqd 0x7327(%rip), %xmm0     # 0x2d9e0
movdqa %xmm0, 0x10(%rsp)
pextrw $0x2, %xmm0, %eax
xorpd %xmm1, %xmm1
pxor %xmm0, %xmm0
testb $0x1, %al
jne 0x266eb
movapd 0x40(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movapd 0xf0(%rsp), %xmm2
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x266f7
sqrtsd %xmm0, %xmm0
jmp 0x266fc
callq 0x7778
movsd %xmm0, (%rsp)
movq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x2322c
movaps 0x70(%rsp), %xmm0
movhps %xmm0, (%rax)
movsd (%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
testl %r15d, %r15d
je 0x2673c
movapd 0x30(%rsp), %xmm0
divsd 0xb8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x26748
sqrtsd %xmm0, %xmm0
jmp 0x2674d
callq 0x7778
movsd %xmm0, 0x30(%rsp)
movq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x2322c
movaps 0x100(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movdqa 0x10(%rsp), %xmm0
movd %xmm0, %eax
xorpd %xmm1, %xmm1
pxor %xmm0, %xmm0
testb $0x1, %al
jne 0x2679c
movapd 0x40(%rsp), %xmm0
divsd 0xf0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x267a8
sqrtsd %xmm0, %xmm0
jmp 0x267ad
callq 0x7778
movsd %xmm0, 0x10(%rsp)
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x2322c
movaps 0x70(%rsp), %xmm0
movlps %xmm0, (%rax)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movq %rbx, %rdi
callq 0x71a0
movq 0xc0(%rsp), %rsi
addq $0x20, %rsi
jmp 0x2634b
leaq 0xd0(%rsp), %rdi
callq 0x17632
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2681f
jmp 0x26851
jmp 0x26851
jmp 0x26851
jmp 0x26851
jmp 0x26851
jmp 0x26851
jmp 0x26851
jmp 0x26851
jmp 0x26851
movq %rax, %rbx
jmp 0x26873
jmp 0x26851
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
jmp 0x26861
jmp 0x26851
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0x26861
jmp 0x26851
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
jmp 0x26861
movq %rax, %rbx
jmp 0x26866
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0x71a0
leaq 0x198(%rsp), %rdi
callq 0x71a0
leaq 0xd0(%rsp), %rdi
callq 0x17632
movq %rbx, %rdi
callq 0x76d0