// File: /workspace/github_c_makefile_star2_O3/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), %rcx
testq %rcx, %rcx
jle 0x969fb
movq 0x8(%rdi), %rdx
movq 0x18(%rdi), %r8
xorl %r9d, %r9d
movsd 0x14271(%rip), %xmm1    # 0xaab20
movsd 0x14261(%rip), %xmm3    # 0xaab18
xorpd %xmm2, %xmm2
xorpd %xmm0, %xmm0
movapd %xmm3, %xmm5
movapd %xmm1, %xmm4
xorl %eax, %eax
xorl %r10d, %r10d
cmpb $0x1, (%rdx,%r9)
movzbl (%r8,%r9), %r11d
jne 0x9691a
cmpl $0x1, %r11d
je 0x96959
testl %r11d, %r11d
jne 0x969b9
movq 0x10(%rdi), %r11
movsd (%r11,%r9,8), %xmm6
movapd %xmm4, %xmm7
cmpunordsd %xmm4, %xmm7
movapd %xmm7, %xmm8
andpd %xmm6, %xmm8
minsd %xmm4, %xmm6
andnpd %xmm6, %xmm7
orpd %xmm8, %xmm7
movapd %xmm7, %xmm4
jmp 0x969d4
cmpl $0x1, %r11d
je 0x96989
testl %r11d, %r11d
jne 0x969c8
movq 0x10(%rdi), %r11
movsd (%r11,%r9,8), %xmm6
movapd %xmm1, %xmm7
cmpunordsd %xmm1, %xmm7
movapd %xmm7, %xmm8
andpd %xmm6, %xmm8
minsd %xmm1, %xmm6
andnpd %xmm6, %xmm7
orpd %xmm8, %xmm7
movapd %xmm7, %xmm1
jmp 0x969d4
movq 0x10(%rdi), %r11
movsd (%r11,%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 0x969d4
movq 0x10(%rdi), %r11
movsd (%r11,%r9,8), %xmm6
movapd %xmm3, %xmm7
cmpunordsd %xmm3, %xmm7
movapd %xmm7, %xmm8
andpd %xmm6, %xmm8
maxsd %xmm3, %xmm6
andnpd %xmm6, %xmm7
orpd %xmm8, %xmm7
movapd %xmm7, %xmm3
jmp 0x969d4
incl %r10d
movq 0x10(%rdi), %r11
addsd (%r11,%r9,8), %xmm0
jmp 0x969d4
incl %eax
movq 0x10(%rdi), %r11
addsd (%r11,%r9,8), %xmm2
incq %r9
cmpq %r9, %rcx
jne 0x968cc
movsd 0xf330(%rip), %xmm6     # 0xa5d18
testl %r10d, %r10d
jg 0x96a05
addsd %xmm5, %xmm4
mulsd %xmm6, %xmm4
movapd %xmm4, %xmm0
jmp 0x96a11
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
jmp 0x96a2e
xorps %xmm4, %xmm4
cvtsi2sd %r10d, %xmm4
divsd %xmm4, %xmm0
testl %eax, %eax
jle 0x96a26
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm2
movapd %xmm2, %xmm1
jmp 0x96a2e
addsd %xmm3, %xmm1
mulsd %xmm6, %xmm1
movapd %xmm0, %xmm2
addsd %xmm1, %xmm2
movsd 0xf2da(%rip), %xmm3     # 0xa5d18
mulsd %xmm3, %xmm2
movsd %xmm2, 0x20(%rsi)
subsd %xmm1, %xmm0
mulsd %xmm3, %xmm0
retq