// File: CK7[P]abawaca/src/ClusterSeparator.cpp
// Function: ClusterSeparator::reconstruct_best_clusters()
void ClusterSeparator::reconstruct_best_clusters()
{
	if(!this->is_best_separation_legal())
		return;

	const Dimension& 		dimension = clustering_db.get_dimension(this->get_separating_dimension());

	this->cluster1 = new Cluster(scaf_db);
	this->cluster2 = new Cluster(scaf_db);

	size_t cluster1_useful_ndps=0, cluster2_useful_ndps=0;
	for(vector<Dimension::DataPoint>::const_iterator vit = dimension.begin(); vit!=dimension.end(); vit++) {
		int useful = (scaf_db.ndps(scaf_db.dp2scaf(vit->dp)) > 1)? 1 : 0;

		if(vit->value <= this->get_separating_value()) {
			*(this->cluster1) += vit->dp;
			cluster1_useful_ndps += useful;
		}
		else {
			*(this->cluster2) += vit->dp;
			cluster2_useful_ndps += useful;
		}
	}

	if(cluster2_useful_ndps < cluster1_useful_ndps) {
		Cluster* temp = this->cluster1;
		this->cluster1 = this->cluster2;
		this->cluster2 = temp;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x60(%rbp)
callq 0x265d0
testb $0x1, %al
jne 0x258b5
jmp 0x25aaf
movq -0x60(%rbp), %rdi
movq 0x18(%rdi), %rax
movq %rax, -0x70(%rbp)
callq 0x26600
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x1e9d0
movq %rax, -0x10(%rbp)
movl $0xa0, %edi
callq 0x5410
movq %rax, %rdi
movq -0x60(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x68(%rbp)
movq 0x8(%rax), %rsi
callq 0xac40
jmp 0x258f9
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, 0x28(%rax)
movl $0xa0, %edi
callq 0x5410
movq %rax, %rdi
movq -0x60(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x78(%rbp)
movq 0x8(%rax), %rsi
callq 0xac40
jmp 0x25928
movq -0x60(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24aa0
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24b10
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x24ad0
testb $0x1, %al
jne 0x25974
jmp 0x25a89
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rcx
movq %rcx, -0x88(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x24b40
movq -0x90(%rbp), %rdi
movq (%rax), %rsi
callq 0x13a40
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x13b50
movq %rax, %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x1, %rdx
cmoval %ecx, %eax
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x24b40
movq -0x60(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
callq 0x26630
movsd -0x80(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x25a4b
leaq -0x38(%rbp), %rdi
callq 0x24b40
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq (%rcx), %rsi
movq 0x28(%rax), %rdi
callq 0x24800
movslq -0x44(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x25a73
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x53a0
jmp 0x25ab8
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x53a0
jmp 0x25ab8
leaq -0x38(%rbp), %rdi
callq 0x24b40
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq (%rcx), %rsi
movq 0x30(%rax), %rdi
callq 0x24800
movslq -0x44(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x25a75
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x24b60
movq %rax, -0x50(%rbp)
jmp 0x25951
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x25aaf
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x30(%rax), %rcx
movq %rcx, 0x28(%rax)
movq -0x58(%rbp), %rcx
movq %rcx, 0x30(%rax)
addq $0x90, %rsp
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x5750
nopw %cs:(%rax,%rax)