// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/svmsolve.c
// Function: nu_calculate_rho
double nu_calculate_rho(Solverptr s, Solutioninfoptr si)
{
	/*Last Changed 29.04.2005*/
	int nr_free1 = 0, nr_free2 = 0, i;
	double ub1 = DBL_MAX, ub2 = DBL_MAX, lb1 = -DBL_MAX, lb2 = -DBL_MAX, sum_free1 = 0, sum_free2 = 0, r1, r2;
	for (i = 0; i < s->active_size; i++)
	 {
	 	if (s->y[i] == +1)
			 {
			  if (is_lower_bound(s, i))
				   ub1 = fmin(ub1, s->G[i]);
			  else 
						 if (is_upper_bound(s, i))
				     lb1 = fmax(lb1, s->G[i]);
			    else
							 {
				     ++nr_free1;
				     sum_free1 += s->G[i];
							 }
			 }
		 else
			 {
		  	if (is_lower_bound(s, i))
				   ub2 = fmin(ub2, s->G[i]);
			  else 
						 if (is_upper_bound(s, i))
				     lb2 = fmax(lb2, s->G[i]);
			    else
							 {
				     ++nr_free2;
				     sum_free2 += s->G[i];
							 }
			 }
	 }
	if (nr_free1 > 0)
		 r1 = sum_free1 / nr_free1;
	else
		 r1 = (ub1 + lb1) / 2;	
	if (nr_free2 > 0)
		 r2 = sum_free2 / nr_free2;
	else
		 r2 = (ub2 + lb2) / 2;	
	si->r = (r1 + r2) / 2;
	return (r1 - r2) / 2;
}

// Assembly:
movslq (%rdi), %rdx
testq %rdx, %rdx
jle 0x93e86
movq 0x8(%rdi), %r8
xorl %r9d, %r9d
movsd 0x13d44(%rip), %xmm2    # 0xa7a70
movsd 0x13d34(%rip), %xmm4    # 0xa7a68
xorpd %xmm1, %xmm1
xorpd %xmm3, %xmm3
movapd %xmm4, %xmm5
movapd %xmm2, %xmm0
xorl %eax, %eax
xorl %ecx, %ecx
cmpb $0x1, (%r8,%r9)
jne 0x93d9e
movq 0x18(%rdi), %r10
movzbl (%r10,%r9), %r10d
cmpl $0x1, %r10d
je 0x93de6
testl %r10d, %r10d
jne 0x93e46
movq 0x10(%rdi), %r10
movsd (%r10,%r9,8), %xmm6
movapd %xmm0, %xmm7
cmpunordsd %xmm0, %xmm7
movapd %xmm7, %xmm8
andpd %xmm6, %xmm8
minsd %xmm0, %xmm6
andnpd %xmm6, %xmm7
orpd %xmm8, %xmm7
movapd %xmm7, %xmm0
jmp 0x93e60
movq 0x18(%rdi), %r10
movzbl (%r10,%r9), %r10d
cmpl $0x1, %r10d
je 0x93e16
testl %r10d, %r10d
jne 0x93e54
movq 0x10(%rdi), %r10
movsd (%r10,%r9,8), %xmm6
movapd %xmm2, %xmm7
cmpunordsd %xmm2, %xmm7
movapd %xmm7, %xmm8
andpd %xmm6, %xmm8
minsd %xmm2, %xmm6
andnpd %xmm6, %xmm7
orpd %xmm8, %xmm7
movapd %xmm7, %xmm2
jmp 0x93e60
movq 0x10(%rdi), %r10
movsd (%r10,%r9,8), %xmm6
movapd %xmm5, %xmm7
cmpunordsd %xmm5, %xmm7
movapd %xmm7, %xmm8
andpd %xmm6, %xmm8
maxsd %xmm5, %xmm6
andnpd %xmm6, %xmm7
orpd %xmm8, %xmm7
movapd %xmm7, %xmm5
jmp 0x93e60
movq 0x10(%rdi), %r10
movsd (%r10,%r9,8), %xmm6
movapd %xmm4, %xmm7
cmpunordsd %xmm4, %xmm7
movapd %xmm7, %xmm8
andpd %xmm6, %xmm8
maxsd %xmm4, %xmm6
andnpd %xmm6, %xmm7
orpd %xmm8, %xmm7
movapd %xmm7, %xmm4
jmp 0x93e60
incl %ecx
movq 0x10(%rdi), %r10
addsd (%r10,%r9,8), %xmm3
jmp 0x93e60
incl %eax
movq 0x10(%rdi), %r10
addsd (%r10,%r9,8), %xmm1
incq %r9
cmpq %r9, %rdx
jne 0x93d48
addsd %xmm5, %xmm0
movsd 0xeea0(%rip), %xmm5     # 0xa2d18
mulsd %xmm5, %xmm0
addsd %xmm4, %xmm2
mulsd %xmm5, %xmm2
jmp 0x93e9a
xorl %ecx, %ecx
xorpd %xmm3, %xmm3
xorl %eax, %eax
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
xorpd %xmm2, %xmm2
testl %ecx, %ecx
jle 0x93ead
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
divsd %xmm0, %xmm3
movapd %xmm3, %xmm0
testl %eax, %eax
jle 0x93ec0
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
divsd %xmm2, %xmm1
movapd %xmm1, %xmm2
movapd %xmm0, %xmm1
addsd %xmm2, %xmm1
movsd 0xee48(%rip), %xmm3     # 0xa2d18
mulsd %xmm3, %xmm1
movsd %xmm1, 0x20(%rsi)
subsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
retq