// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rsp, %rdi
leaq 0x28(%rsp), %rdx
callq 0x5936
leaq 0x28(%rsp), %rdi
callq 0x3420
movq 0x80(%rbx), %rax
cmpq %rax, 0x88(%rbx)
je 0x47ca
movl $0x1, %ebp
xorl %ecx, %ecx
shlq $0x6, %rcx
leaq (%rax,%rcx), %rsi
movslq 0x38(%rax,%rcx), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x3, %rdi
addq (%rsp), %rdi
callq 0x589c
movl %ebp, %ecx
movq 0x80(%rbx), %rax
movq 0x88(%rbx), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x478e
leaq 0x58(%rbx), %rsi
leaq 0x28(%rsp), %rdi
movl $0x10, %edx
callq 0x3110
cmpl $0x0, 0x30(%rbx)
jle 0x49c0
xorl %r14d, %r14d
leaq 0x28(%rsp), %r15
movslq 0x30(%rbx), %rax
cmpq %rax, %r14
jge 0x4a57
movl $0x9, %edx
movq %r15, %rdi
leaq 0x39cd(%rip), %rsi      # 0x81d8
callq 0x3330
leaq 0x1(%r14), %r12
movq %r15, %rdi
movl %r12d, %esi
callq 0x3430
movl $0xb, %edx
movq %rax, %rdi
leaq 0x39b4(%rip), %rsi      # 0x81e2
callq 0x3330
cmpl $0x0, 0x9c(%rbx)
leaq (%r14,%r14,2), %rbp
jle 0x487e
xorl %r14d, %r14d
movq (%rbx), %rax
movq (%rax,%rbp,8), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%r14,4), %xmm0
movq %r15, %rdi
callq 0x33c0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3a34(%rip), %rsi      # 0x829e
callq 0x3330
incq %r14
movslq 0x9c(%rbx), %rax
cmpq %rax, %r14
jl 0x4843
movl $0x11, %edx
movq %r15, %rdi
leaq 0x3961(%rip), %rsi      # 0x81ee
callq 0x3330
movq (%rsp), %rax
movq 0x8(%rax,%rbp,8), %rsi
subq (%rax,%rbp,8), %rsi
sarq $0x6, %rsi
movq %r15, %rdi
callq 0x31d0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3946(%rip), %rsi      # 0x8200
callq 0x3330
movq %r12, 0x18(%rsp)
movq (%rsp), %rax
movq 0x8(%rax,%rbp,8), %rcx
cmpq (%rax,%rbp,8), %rcx
je 0x49a2
xorl %r14d, %r14d
xorl %eax, %eax
movq %rax, 0x20(%rsp)
movq %rbx, %r13
cmpl $0x0, 0x9c(%rbx)
jle 0x4935
movq %r14, %r12
shlq $0x6, %r12
xorl %ebx, %ebx
movq (%rsp), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%r12), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rbx,4), %xmm0
movq %r15, %rdi
callq 0x33c0
movl $0x1, %edx
movq %r15, %rdi
leaq 0x397d(%rip), %rsi      # 0x829e
callq 0x3330
incq %rbx
movslq 0x9c(%r13), %rax
cmpq %rax, %rbx
jl 0x48f6
movl $0x1, %edx
movq %r15, %rdi
leaq 0x395a(%rip), %rsi      # 0x829e
callq 0x3330
movq (%rsp), %rax
movq (%rax,%rbp,8), %rax
shlq $0x6, %r14
movq 0x18(%rax,%r14), %rsi
movq 0x20(%rax,%r14), %rdx
movq %r15, %rdi
callq 0x3330
movl $0x1, %edx
movq %r15, %rdi
leaq 0x388a(%rip), %rsi      # 0x8200
callq 0x3330
movq (%rsp), %rax
movq 0x8(%rax,%rbp,8), %rcx
subq (%rax,%rbp,8), %rcx
movq 0x20(%rsp), %rax
incl %eax
sarq $0x6, %rcx
movq %rax, %r14
cmpq %rax, %rcx
movq %r13, %rbx
ja 0x48dc
movl $0x1, %edx
movq %r15, %rdi
leaq 0x384f(%rip), %rsi      # 0x8200
callq 0x3330
movq 0x18(%rsp), %r14
jmp 0x47ef
movq 0x75f9(%rip), %rdi      # 0xbfc0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq 0x75de(%rip), %rdi      # 0xbfc0
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq %rax, %rbx
leaq 0x37bb(%rip), %rsi      # 0x81b4
movl $0x23, %edx
movq %rax, %rdi
callq 0x3330
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
leaq 0x28(%rsp), %rdi
callq 0x3380
movq 0x7538(%rip), %rax      # 0xbfa0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x30(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x28(%rsp,%rcx)
callq 0x3230
leaq 0x120(%rsp), %rdi
callq 0x30b0
movq %rsp, %rdi
callq 0x59be
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4af1
jmp 0x4abc
jmp 0x4abc
jmp 0x4abc
jmp 0x4abc
jmp 0x4abc
movq %rax, %rbx
movq 0x74da(%rip), %rax      # 0xbfa0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x30(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x28(%rsp,%rcx)
callq 0x3230
leaq 0x120(%rsp), %rdi
callq 0x30b0
movq %rsp, %rdi
callq 0x59be
movq %rbx, %rdi
callq 0x3450
nop