// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/svmsolve.c
// Function: nu_select_working_set
int nu_select_working_set(Solverptr s, int* out_i, int* out_j)
{
	/*Last Changed 29.04.2005*/
	double Gmax1 = -DBL_MAX, Gmax2 = -DBL_MAX, Gmax3 = -DBL_MAX, Gmax4 = -DBL_MAX;	
	int Gmax1_idx = -1, Gmax2_idx = -1, Gmax3_idx = -1, Gmax4_idx = -1, i;
	for (i = 0; i < s->active_size;i++)
	 {
		 if (s->y[i] == +1)	
			 {
			  if (!is_upper_bound(s, i))	
					 {
				   if (-s->G[i] >= Gmax1)
							 {
					    Gmax1 = -s->G[i];
					    Gmax1_idx = i;
							 }
					 }
			  if (!is_lower_bound(s, i))	
					 {
				   if (s->G[i] >= Gmax2)
							 {
					    Gmax2 = s->G[i];
					    Gmax2_idx = i;
							 }
					 }
			 }
		 else		
			 {
			  if (!is_upper_bound(s, i))	
					 {
				   if (-s->G[i] >= Gmax3)
							 {  
					    Gmax3 = -s->G[i];
					    Gmax3_idx = i;
							 }
					 }
			  if (!is_lower_bound(s, i))	
					 {
				   if (s->G[i] >= Gmax4)
							 {
					    Gmax4 = s->G[i];
					    Gmax4_idx = i;
							 }
					 }
			 }
	 }
	if (fmax(Gmax1 + Gmax2, Gmax3 + Gmax4) < s->eps)
 		return 1;
	if (Gmax1 + Gmax2 > Gmax3 + Gmax4)
	 {
 		*out_i = Gmax1_idx;
 		*out_j = Gmax2_idx;
	 }
	else
	 {
		 *out_i = Gmax3_idx;
		 *out_j = Gmax4_idx;
	 }
	return 0;
}

// Assembly:
movslq (%rdi), %rax
testq %rax, %rax
jle 0x93739
pushq %rbp
pushq %r14
pushq %rbx
movq 0x8(%rdi), %r11
movsd 0x14408(%rip), %xmm2    # 0xa7a68
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %ebx, %ebx
movapd 0xfb61(%rip), %xmm3     # 0xa31d0
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movapd %xmm2, %xmm1
movapd %xmm2, %xmm4
movapd %xmm2, %xmm0
cmpb $0x1, (%r11,%rbx)
jne 0x936db
movq 0x18(%rdi), %r14
movb (%r14,%rbx), %bpl
cmpb $0x1, %bpl
je 0x936bd
movq 0x10(%rdi), %r14
movsd (%r14,%rbx,8), %xmm5
xorpd %xmm3, %xmm5
ucomisd %xmm0, %xmm5
jb 0x936bd
movapd %xmm5, %xmm0
movl %ebx, %r9d
testb %bpl, %bpl
je 0x9371f
movq 0x10(%rdi), %r14
movsd (%r14,%rbx,8), %xmm5
ucomisd %xmm4, %xmm5
jb 0x9371f
movapd %xmm5, %xmm4
movl %ebx, %r10d
jmp 0x9371f
movq 0x18(%rdi), %r14
movb (%r14,%rbx), %bpl
cmpb $0x1, %bpl
je 0x93704
movq 0x10(%rdi), %r14
movsd (%r14,%rbx,8), %xmm5
xorpd %xmm3, %xmm5
ucomisd %xmm1, %xmm5
jb 0x93704
movapd %xmm5, %xmm1
movl %ebx, %r8d
testb %bpl, %bpl
je 0x9371f
movq 0x10(%rdi), %r14
movsd (%r14,%rbx,8), %xmm5
ucomisd %xmm2, %xmm5
jb 0x9371f
movapd %xmm5, %xmm2
movl %ebx, %ecx
incq %rbx
cmpq %rbx, %rax
jne 0x9368d
addsd %xmm4, %xmm0
addsd %xmm2, %xmm1
popq %rbx
popq %r14
popq %rbp
jmp 0x9375c
movsd 0x1b4b7(%rip), %xmm0    # 0xaebf8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movapd %xmm0, %xmm1
movapd %xmm0, %xmm2
cmpunordsd %xmm0, %xmm2
movapd %xmm2, %xmm3
andpd %xmm1, %xmm3
movapd %xmm1, %xmm4
maxsd %xmm0, %xmm4
andnpd %xmm4, %xmm2
orpd %xmm3, %xmm2
movsd 0x48(%rdi), %xmm3
movl $0x1, %eax
ucomisd %xmm2, %xmm3
ja 0x937a0
ucomisd %xmm1, %xmm0
cmoval %r9d, %r8d
cmoval %r10d, %ecx
movl %r8d, (%rsi)
movl %ecx, (%rdx)
xorl %eax, %eax
retq