// File: /workspace/github_cpp_makefile_star2_O3/CK7[P]abawaca/src/ClusterSeparatorSplitScafs.cpp
// Function: ClusterSeparatorSplitScafs::separate_specific(ClusterSeparatorSplitScafs::ClusterStats&, ClusterSeparatorSplitScafs::ClusterStats&, unsigned long, double, unsigned long, ClusterSeparatorSplitScafs::ClusteringResult&)
void ClusterSeparatorSplitScafs::separate_specific(ClusterStats& curr_cluster1, ClusterStats& curr_cluster2, size_t dimension_index, double tested_value, size_t nuseful_scafs,
	ClusterSeparatorSplitScafs::ClusteringResult& best_dimension_separation)
{
	// First we will move the dps from cluster2 to cluster1. This includes updating in1, in2, separated, cluster1_useful_ndps and cluster2_useful_ndps.
	size_t separated = nuseful_scafs - curr_cluster1.num_scafs_in_this_cluster() - curr_cluster2.num_scafs_in_this_cluster();

	// Which one is smaller in terms of the number of datapoints that will be considered 
	// for the clustering?
	if((curr_cluster1.ndps_this_cluster_scafs() < this->cluster_ndps_threshold) || (curr_cluster2.ndps_this_cluster_scafs() < this->cluster_ndps_threshold))
		return;

	// Now pick the smaller cluster, we will compute sensitivity and specificity on that one
	const ClusterStats& small_cluster = (curr_cluster1.num_useful_ndps() < curr_cluster2.num_useful_ndps())? curr_cluster1 : curr_cluster2;
	const ClusterStats& large_cluster = (curr_cluster1.num_useful_ndps() >= curr_cluster2.num_useful_ndps())? curr_cluster1 : curr_cluster2;

	double separated_to_cluster1_ratio = double(separated)/double(small_cluster.num_scafs_in_this_cluster());
	double cluster_size_ratio = double(small_cluster.num_scafs_in_this_cluster())/large_cluster.num_scafs_in_this_cluster();
	if(cluster_size_ratio<1)
		cluster_size_ratio = 1/cluster_size_ratio;

	ClusterSeparatorSplitScafs::ClusteringResult	cr(dimension_index, tested_value, separated_to_cluster1_ratio, cluster_size_ratio);
	if(cr.is_better(best_dimension_separation))
		best_dimension_separation.copy(cr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbx
movslq 0x14(%rsi), %r9
movq 0xb0(%rdi), %rax
cmpq %r9, %rax
ja 0x15029
movslq 0x14(%rdx), %rdi
cmpq %rdi, %rax
ja 0x15029
movslq 0x18(%rsi), %rax
movslq 0x18(%rdx), %rdi
addq %rax, %rdi
subq %rdi, %r8
movl 0x10(%rsi), %eax
cmpl 0x10(%rdx), %eax
movq %rdx, %rax
cmovlq %rsi, %rax
cmovlq %rdx, %rsi
movq %r8, %xmm1
punpckldq 0x51f9(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x5201(%rip), %xmm1     # 0x1a1a0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtsi2sdl 0x18(%rax), %xmm1
divsd %xmm1, %xmm2
cvtsi2sdl 0x18(%rsi), %xmm3
divsd %xmm3, %xmm1
movsd 0x51c0(%rip), %xmm3     # 0x1a188
movapd %xmm1, %xmm4
cmpltsd %xmm3, %xmm4
divsd %xmm1, %xmm3
andpd %xmm4, %xmm3
andnpd %xmm1, %xmm4
orpd %xmm3, %xmm4
leaq -0x38(%rbp), %rdi
movq %rcx, 0x8(%rdi)
movsd %xmm0, 0x10(%rdi)
leaq 0xcce3(%rip), %rax      # 0x21cd8
movq %rax, (%rdi)
movsd %xmm2, 0x18(%rdi)
movlpd %xmm4, 0x20(%rdi)
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, 0x28(%rdi)
movq %rbx, %rsi
callq 0x15062
testb %al, %al
je 0x15029
movq (%rbx), %rax
leaq -0x38(%rbp), %rsi
movq %rbx, %rdi
callq *0x8(%rax)
addq $0x38, %rsp
popq %rbx
popq %rbp
retq