// File: melop[P]admixem/Population.cpp
// Function: Population::fnSample(std::basic_ofstream<char, std::char_traits<char>>&, std::basic_ofstream<char, std::char_traits<char>>&, std::basic_ofstream<char, std::char_traits<char>>&, Individual::Sex)
void Population::fnSample(ofstream &fMarkerOutFile, ofstream &fGeneOutFile,  ofstream &fPhenotypeOutFile, Individual::Sex bSex) {

	bool bWriteMarkers = !(SimulConfig.GetConfig("MarkerOutput") == "Off");
	
	vector< Individual *> * pMpIndividuals = (bSex == Individual::Male)? &this->_mpMales : &this->_mpFemales;
	
	

	int i=0;

	for (vector< Individual *>::iterator itInd=pMpIndividuals->begin(); itInd!=pMpIndividuals->end(); ++ itInd) {

		if (bWriteMarkers) {
			this->fnWriteIndividualMarkers(fMarkerOutFile, *itInd);
		}
		this->fnWriteIndividualGenes(fGeneOutFile, *itInd);

		if (i==0) {
				// phenotype file needs header.
				fPhenotypeOutFile << "id\tpop\tsex\tFatherId\tMotherId\t";
				(*itInd)->WritePhenotypeHeader(fPhenotypeOutFile);
				fPhenotypeOutFile << endl;
		}

		this->fnWriteIndividualPhenotypes(fPhenotypeOutFile, *itInd);

		i++;
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x8870
movq -0xa8(%rbp), %rdx
leaq 0xeb4b(%rip), %rsi      # 0x78e23
leaq -0x68(%rbp), %rdi
callq 0xcb30
jmp 0x6a2e3
leaq 0x4076e(%rip), %rsi     # 0xaaa58
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x1c190
jmp 0x6a2f9
leaq 0xeb30(%rip), %rsi      # 0x78e30
leaq -0x48(%rbp), %rdi
callq 0xcbe0
movb %al, -0xb1(%rbp)
jmp 0x6a311
movb -0xb1(%rbp), %al
xorb $-0x1, %al
movb %al, -0xb2(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x82e0
leaq -0x68(%rbp), %rdi
callq 0x82e0
leaq -0x69(%rbp), %rdi
callq 0x8540
movb -0xb2(%rbp), %al
andb $0x1, %al
movb %al, -0x25(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x6a35f
movq -0xb0(%rbp), %rax
addq $0x48, %rax
movq %rax, -0xc0(%rbp)
jmp 0x6a371
movq -0xb0(%rbp), %rax
addq $0x60, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
movq -0x88(%rbp), %rdi
callq 0x60a70
movq %rax, -0x98(%rbp)
movq -0x88(%rbp), %rdi
callq 0x60900
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x6ca70
testb $0x1, %al
jne 0x6a3cb
jmp 0x6a503
testb $0x1, -0x25(%rbp)
je 0x6a448
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x6cab0
movq -0xb0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq (%rax), %rdx
callq 0x6c550
jmp 0x6a448
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x6a43a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x6a431
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x82e0
leaq -0x68(%rbp), %rdi
callq 0x82e0
leaq -0x69(%rbp), %rdi
callq 0x8540
jmp 0x6a50c
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x6cab0
movq -0xb0(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movq (%rax), %rdx
callq 0x6c5e0
cmpl $0x0, -0x8c(%rbp)
jne 0x6a4b6
movq -0x20(%rbp), %rdi
leaq 0xe9ab(%rip), %rsi      # 0x78e34
callq 0x84a0
leaq -0x98(%rbp), %rdi
callq 0x6cab0
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x5b3f0
movq -0x20(%rbp), %rdi
movq 0x3fa7f(%rip), %rsi     # 0xa9f30
callq 0x8520
movq -0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x6cab0
movq -0xb0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movq (%rax), %rdx
callq 0x6c670
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x6cad0
jmp 0x6a39c
addq $0xe0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x8860
nopw %cs:(%rax,%rax)