// File: /workspace/github_cpp_makefile_star2_O2/isaacbrodsky[P]K-means-plus-plus/k-means-multi.cpp
// Function: Cluster_set::Write_output_data()
void Cluster_set::Write_output_data(void){

	// local variables
	unsigned uInstance_index;
	int iCluster_index, iAttribute_index;
	vector< vector<Cluster_instance> > vclThe_cluster_set(iK_count);

	// declare an output stream
	ofstream strResults_out_stream;

	// Sort the cluster results
	for (uInstance_index = 0; uInstance_index < vclInput_data.size(); uInstance_index++)
	{
		vclThe_cluster_set[vclInput_data[uInstance_index].iCluster].push_back(vclInput_data[uInstance_index]);
	}

	// open the stream to write the output plaintext
	strResults_out_stream.open(sOut_file);

	if(iK_count < 1) { // we have an empty cluster_set
		cout << endl << "No clusters to send to output file!" << endl << endl;
	} else { // output the cluster results
		// loop thru each cluster
		for (iCluster_index = 0; iCluster_index < iK_count; iCluster_index++){

			// output a cluster header - cluster #, cluster mean
			strResults_out_stream << "Cluster #" << iCluster_index + 1 << " with mean ";
			for (iAttribute_index = 0; iAttribute_index < iAttribute_ct; iAttribute_index++){
				strResults_out_stream << vvfMeans[iCluster_index][iAttribute_index] << " ";
			} // for
			strResults_out_stream << "and member count "
				<< vclThe_cluster_set[iCluster_index].size() << "\n";

			// loop thru the cluster members
			for (uInstance_index = 0;
				uInstance_index < vclThe_cluster_set[iCluster_index].size(); uInstance_index++){

				// output the cluster member data
				for (iAttribute_index = 0; iAttribute_index < iAttribute_ct; iAttribute_index++){
					strResults_out_stream
						<< vclThe_cluster_set[iCluster_index][uInstance_index].vfAttribute[iAttribute_index];
					strResults_out_stream << " ";
				} // for
				strResults_out_stream << " ";
				strResults_out_stream << vclThe_cluster_set[iCluster_index][uInstance_index].sClassification;

				// output a CR/LF
				strResults_out_stream << "\n";
			} // for

			// output CR/LF
			strResults_out_stream << "\n";
		} // for
	} // if

	strResults_out_stream.close();

	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rdi, %rbx
movslq 0x30(%rdi), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x53a2
leaq 0x28(%rsp), %rdi
callq 0x3420
xorl %r14d, %r14d
movl %r14d, %r14d
movq 0x80(%rbx), %rax
movq 0x88(%rbx), %rcx
subq %rax, %rcx
sarq $0x6, %rcx
cmpq %r14, %rcx
jbe 0x4416
movq %r14, %rcx
shlq $0x6, %rcx
leaq (%rax,%rcx), %rsi
movslq 0x38(%rax,%rcx), %rax
imulq $0x18, %rax, %rdi
addq 0x8(%rsp), %rdi
callq 0x5340
incl %r14d
jmp 0x43d6
leaq 0x58(%rbx), %rsi
leaq 0x28(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x3110
cmpl $0x0, 0x30(%rbx)
jle 0x45a8
xorl %r12d, %r12d
leaq 0x28(%rsp), %r15
movslq 0x30(%rbx), %rax
cmpq %rax, %r12
jge 0x45d3
movq %r15, %rdi
leaq 0x3d88(%rip), %rsi      # 0x81d8
callq 0x32d0
leaq 0x1(%r12), %rsi
movq %rax, %rdi
movq %rsi, 0x20(%rsp)
callq 0x3430
movq %rax, %rdi
leaq 0x3d71(%rip), %rsi      # 0x81e2
callq 0x32d0
imulq $0x18, %r12, %rbp
xorl %r14d, %r14d
movslq 0x9c(%rbx), %rax
cmpq %rax, %r14
jge 0x44b2
movq (%rbx), %rax
movq (%rax,%rbp), %rax
movss (%rax,%r14,4), %xmm0
movq %r15, %rdi
callq 0x3200
movq %rax, %rdi
leaq 0x3df6(%rip), %rsi      # 0x829e
callq 0x32d0
incq %r14
jmp 0x447d
movq %r15, %rdi
leaq 0x3d32(%rip), %rsi      # 0x81ee
callq 0x32d0
movq 0x8(%rsp), %rcx
movq 0x8(%rcx,%rbp), %rsi
subq (%rcx,%rbp), %rsi
sarq $0x6, %rsi
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
leaq 0x3d1b(%rip), %rsi      # 0x8200
callq 0x32d0
xorl %r14d, %r14d
movl %r14d, %r14d
movq 0x8(%rsp), %rax
movq 0x8(%rax,%rbp), %rcx
subq (%rax,%rbp), %rcx
sarq $0x6, %rcx
cmpq %r14, %rcx
jbe 0x458f
movq %r14, %r12
shlq $0x6, %r12
xorl %r13d, %r13d
movslq 0x9c(%rbx), %rax
cmpq %rax, %r13
jge 0x4550
movq 0x8(%rsp), %rax
movq (%rax,%rbp), %rax
movq (%rax,%r12), %rax
movss (%rax,%r13,4), %xmm0
movq %r15, %rdi
callq 0x3200
movq %r15, %rdi
leaq 0x3d58(%rip), %rsi      # 0x829e
callq 0x32d0
incq %r13
jmp 0x4515
movq %r15, %rdi
leaq 0x3d44(%rip), %rsi      # 0x829e
callq 0x32d0
movq 0x8(%rsp), %rax
movq (%rax,%rbp), %rax
leaq (%rax,%r12), %rsi
addq $0x18, %rsi
movq %r15, %rdi
callq 0x3270
movq %r15, %rdi
leaq 0x3c7e(%rip), %rsi      # 0x8200
callq 0x32d0
incl %r14d
jmp 0x44ed
movq %r15, %rdi
leaq 0x3c67(%rip), %rsi      # 0x8200
callq 0x32d0
movq 0x20(%rsp), %r12
jmp 0x4439
movq 0x8a11(%rip), %rdi      # 0xcfc0
callq 0x3120
leaq 0x3bf9(%rip), %rsi      # 0x81b4
movq %rax, %rdi
callq 0x32d0
movq %rax, %rdi
callq 0x3120
movq %rax, %rdi
callq 0x3120
leaq 0x28(%rsp), %rdi
callq 0x3390
leaq 0x28(%rsp), %rdi
callq 0x33b0
leaq 0x8(%rsp), %rdi
callq 0x53f4
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x461f
jmp 0x4612
jmp 0x4612
jmp 0x4612
jmp 0x4612
jmp 0x4612
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x33b0
leaq 0x8(%rsp), %rdi
callq 0x53f4
movq %rbx, %rdi
callq 0x3450
nop