// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
pushq $-0x1
popq %rbp
movsd 0x12f2a(%rip), %xmm0    # 0x9aa48
movapd 0xe6aa(%rip), %xmm6     # 0x961d0
movapd %xmm0, %xmm2
movapd %xmm0, %xmm1
movapd %xmm0, %xmm7
movl %ebp, %r13d
movl %ebp, %r12d
movl %ebp, %ebx
cmpq %rcx, %rax
je 0x87c08
movq 0x8(%r15), %rdx
movq 0x18(%r15), %rsi
cmpb $0x1, (%rdx,%rcx)
movb (%rsi,%rcx), %dl
jne 0x87ba2
cmpb $0x1, %dl
je 0x87b8e
movq 0x10(%r15), %rsi
movsd (%rsi,%rcx,8), %xmm3
xorpd %xmm6, %xmm3
ucomisd %xmm0, %xmm3
movapd %xmm0, %xmm4
cmpnlesd %xmm3, %xmm4
movapd %xmm4, %xmm5
andnpd %xmm3, %xmm5
andpd %xmm0, %xmm4
orpd %xmm5, %xmm4
movapd %xmm4, %xmm0
cmovael %ecx, %ebp
testb %dl, %dl
je 0x87bec
movq 0x10(%r15), %rdx
movsd (%rdx,%rcx,8), %xmm3
ucomisd %xmm2, %xmm3
jb 0x87bec
movl %ecx, %r13d
jmp 0x87bfc
cmpb $0x1, %dl
je 0x87bdd
movq 0x10(%r15), %rsi
movsd (%rsi,%rcx,8), %xmm3
xorpd %xmm6, %xmm3
ucomisd %xmm1, %xmm3
movapd %xmm1, %xmm4
cmpnlesd %xmm3, %xmm4
movapd %xmm4, %xmm5
andnpd %xmm3, %xmm5
andpd %xmm1, %xmm4
orpd %xmm5, %xmm4
movapd %xmm4, %xmm1
cmovael %ecx, %r12d
testb %dl, %dl
je 0x87bec
movq 0x10(%r15), %rdx
movsd (%rdx,%rcx,8), %xmm4
ucomisd %xmm7, %xmm4
jae 0x87bf2
movapd %xmm2, %xmm3
jmp 0x87bfc
movapd %xmm2, %xmm3
movapd %xmm4, %xmm7
movl %ecx, %ebx
incq %rcx
movapd %xmm3, %xmm2
jmp 0x87b3a
addsd %xmm2, %xmm0
movapd %xmm0, 0x20(%rsp)
addsd %xmm7, %xmm1
movapd %xmm1, 0x10(%rsp)
callq 0x34c90
movsd 0x48(%r15), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x87c32
pushq $0x1
popq %rax
jmp 0x87c52
movapd 0x20(%rsp), %xmm0
ucomisd 0x10(%rsp), %xmm0
cmoval %ebp, %r12d
cmoval %r13d, %ebx
movl %r12d, (%r14)
movq 0x8(%rsp), %rax
movl %ebx, (%rax)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq