// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl (%rdi), %r15d
xorl %r12d, %r12d
testl %r15d, %r15d
cmovlel %r12d, %r15d
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x12893(%rip), %xmm1    # 0x9aa48
movsd 0x12893(%rip), %xmm0    # 0x9aa50
xorl %r13d, %r13d
xorl %ebp, %ebp
movsd %xmm0, 0x20(%rsp)
movsd %xmm0, 0x30(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm1, 0x28(%rsp)
xorpd %xmm3, %xmm3
cmpq %r12, %r15
je 0x882eb
movq 0x8(%r14), %rax
movq 0x18(%r14), %rcx
cmpb $0x1, (%rax,%r12)
movzbl (%rcx,%r12), %eax
jne 0x88234
cmpl $0x1, %eax
je 0x8826a
testl %eax, %eax
jne 0x882bc
movq 0x10(%r14), %rax
movsd (%rax,%r12,8), %xmm1
movsd 0x20(%rsp), %xmm0
movsd %xmm3, 0x8(%rsp)
callq 0x34c95
movsd 0x8(%rsp), %xmm3
movsd %xmm0, 0x20(%rsp)
jmp 0x882e3
cmpl $0x1, %eax
je 0x88293
testl %eax, %eax
jne 0x882d7
movq 0x10(%r14), %rax
movsd (%rax,%r12,8), %xmm1
movsd 0x30(%rsp), %xmm0
movsd %xmm3, 0x8(%rsp)
callq 0x34c95
movsd 0x8(%rsp), %xmm3
movsd %xmm0, 0x30(%rsp)
jmp 0x882e3
movq 0x10(%r14), %rax
movsd (%rax,%r12,8), %xmm1
movsd 0x18(%rsp), %xmm0
movsd %xmm3, 0x8(%rsp)
callq 0x34c90
movsd 0x8(%rsp), %xmm3
movsd %xmm0, 0x18(%rsp)
jmp 0x882e3
movq 0x10(%r14), %rax
movsd (%rax,%r12,8), %xmm1
movsd 0x28(%rsp), %xmm0
movsd %xmm3, 0x8(%rsp)
callq 0x34c90
movsd 0x8(%rsp), %xmm3
movsd %xmm0, 0x28(%rsp)
jmp 0x882e3
incl %r13d
movq 0x10(%r14), %rax
movsd 0x10(%rsp), %xmm0
addsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x882e3
incl %ebp
movq 0x10(%r14), %rax
addsd (%rax,%r12,8), %xmm3
incq %r12
jmp 0x881de
movsd 0xda2d(%rip), %xmm2     # 0x95d20
testl %r13d, %r13d
jg 0x8830a
movsd 0x20(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
mulsd %xmm2, %xmm0
jmp 0x88319
cvtsi2sd %r13d, %xmm1
movsd 0x10(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
testl %ebp, %ebp
jg 0x88335
movsd 0x30(%rsp), %xmm3
addsd 0x28(%rsp), %xmm3
mulsd %xmm2, %xmm3
jmp 0x8833d
cvtsi2sd %ebp, %xmm1
divsd %xmm1, %xmm3
movsd 0x10(%rsp), %xmm0
movapd %xmm0, %xmm1
addsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd %xmm1, 0x20(%rbx)
subsd %xmm3, %xmm0
mulsd %xmm2, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq