// File: isaacbrodsky[P]K-means-plus-plus/k-means-multi.cpp
// Function: Cluster_set::Calculate_cluster_means()
void Cluster_set::Calculate_cluster_means(void){

	// local variables
	int iK_index, iAttribute_index;
	unsigned uInstance_index, uInstance_sz;
	vector<int> viCounts(iK_count);

	uInstance_sz = vclInput_data.size();
	
	for (uInstance_index = 0; uInstance_index < uInstance_sz; uInstance_index++)
	{
		iK_index = vclInput_data[uInstance_index].iCluster;
		//loop through each vector attribute
		for (iAttribute_index = 0; iAttribute_index < iAttribute_ct; iAttribute_index++){
			vvfMeans[iK_index][iAttribute_index] += vclInput_data[uInstance_index].vfAttribute[iAttribute_index];
		} // for

		viCounts[iK_index]++;
	}
	
	// loop thru each cluster
	for (iK_index = 0; iK_index < iK_count; iK_index++){
		//loop through each vector attribute
		for (iAttribute_index = 0; iAttribute_index < iAttribute_ct; iAttribute_index++) {
			//If no elements, default to origin as per old code.
			if (viCounts[iK_index] == 0)
				vvfMeans[iK_index][iAttribute_index] = 0;
			else
				vvfMeans[iK_index][iAttribute_index] /= (float)viCounts[iK_index];
		}
	} // for

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movslq 0x30(%rax), %rax
movq %rax, -0x58(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x50(%rbp)
callq 0xabc0
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0xabe0
jmp 0x621c
leaq -0x31(%rbp), %rdi
callq 0xac50
movq -0x60(%rbp), %rdi
addq $0x80, %rdi
callq 0xa5b0
movl %eax, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x6313
movq -0x60(%rbp), %rdi
addq $0x80, %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0xa5f0
movl 0x38(%rax), %eax
movl %eax, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x60(%rbp), %rcx
movl -0x10(%rbp), %eax
cmpl 0x9c(%rcx), %eax
jge 0x62f1
movq -0x60(%rbp), %rdi
addq $0x80, %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0xa5f0
movq %rax, %rdi
movslq -0x10(%rbp), %rsi
callq 0xa3c0
movq -0x60(%rbp), %rdi
movss (%rax), %xmm0
movss %xmm0, -0x64(%rbp)
movslq -0xc(%rbp), %rsi
callq 0xa4e0
movq %rax, %rdi
movslq -0x10(%rbp), %rsi
callq 0xa3c0
movss -0x64(%rbp), %xmm0
addss (%rax), %xmm0
movss %xmm0, (%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x626d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0xac50
jmp 0x63e7
movslq -0xc(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xac70
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x623f
movl $0x0, -0xc(%rbp)
movq -0x60(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x30(%rcx), %eax
jge 0x63d8
movl $0x0, -0x10(%rbp)
movq -0x60(%rbp), %rcx
movl -0x10(%rbp), %eax
cmpl 0x9c(%rcx), %eax
jge 0x63c8
movslq -0xc(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xac70
cmpl $0x0, (%rax)
jne 0x6378
movq -0x60(%rbp), %rdi
movslq -0xc(%rbp), %rsi
callq 0xa4e0
movq %rax, %rdi
movslq -0x10(%rbp), %rsi
callq 0xa3c0
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
jmp 0x63b8
movslq -0xc(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xac70
movq -0x60(%rbp), %rdi
cvtsi2ssl (%rax), %xmm0
movss %xmm0, -0x68(%rbp)
movslq -0xc(%rbp), %rsi
callq 0xa4e0
movq %rax, %rdi
movslq -0x10(%rbp), %rsi
callq 0xa3c0
movss -0x68(%rbp), %xmm1
movss (%rax), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%rax)
jmp 0x63ba
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x6331
jmp 0x63ca
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x631a
leaq -0x30(%rbp), %rdi
callq 0xac90
addq $0x70, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x4530