// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/svmsolve.c
// Function: calculate_rho
double calculate_rho(Solverptr s)
{
 /*Last Changed 28.04.2005*/
	double r, ub = DBL_MAX, lb = -DBL_MAX, sum_free = 0, yG;
	int i, nr_free = 0;
	for (i = 0; i < s->active_size; i++)
	 {
		 yG = s->y[i] * s->G[i];
		 if (is_lower_bound(s, i))
		  {
		  	if (s->y[i] > 0)
				   ub = fmin(ub, yG);
			  else
				   lb = fmax(lb, yG);
			 }
		 else 
				 if (is_upper_bound(s, i))
					 {
			    if (s->y[i] < 0)
				     ub = fmin(ub, yG);
			    else
				     lb = fmax(lb, yG);
					 }
		   else
					 {
			    ++nr_free;
			    sum_free += yG;
					 }
	 }
	if (nr_free > 0)
		 r = sum_free / nr_free;
	else
		 r = (ub + lb) / 2;
	return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movsd 0x18334(%rip), %xmm0    # 0xe7578
movsd %xmm0, -0x18(%rbp)
movsd 0x1831f(%rip), %xmm0    # 0xe7570
movsd %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xcf3da
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cvtsi2sd %eax, %xmm0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0xcdc50
cmpl $0x0, %eax
je 0xcf32c
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jle 0xcf2fa
movsd -0x18(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm0
cmpunordsd %xmm0, %xmm0
movaps %xmm0, %xmm1
pand %xmm4, %xmm1
minsd %xmm3, %xmm2
pandn %xmm2, %xmm0
por %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0xcf327
movsd -0x20(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm0
cmpunordsd %xmm0, %xmm0
movaps %xmm0, %xmm1
pand %xmm4, %xmm1
maxsd %xmm3, %xmm2
pandn %xmm2, %xmm0
por %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0xcf3ca
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0xcdc10
cmpl $0x0, %eax
je 0xcf3b0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jge 0xcf381
movsd -0x18(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm0
cmpunordsd %xmm0, %xmm0
movaps %xmm0, %xmm1
pand %xmm4, %xmm1
minsd %xmm3, %xmm2
pandn %xmm2, %xmm0
por %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0xcf3ae
movsd -0x20(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm0
cmpunordsd %xmm0, %xmm0
movaps %xmm0, %xmm1
pand %xmm4, %xmm1
maxsd %xmm3, %xmm2
pandn %xmm2, %xmm0
por %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0xcf3c8
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0xcf3ca
jmp 0xcf3cc
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xcf26c
cmpl $0x0, -0x38(%rbp)
jle 0xcf3f5
movsd -0x28(%rbp), %xmm0
cvtsi2sdl -0x38(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
jmp 0xcf410
movsd -0x18(%rbp), %xmm0
addsd -0x20(%rbp), %xmm0
movsd 0x13899(%rip), %xmm1    # 0xe2ca0
divsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)