// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/dataset.c
// Function: feature_efficiency
double feature_efficiency(Datasetptr d, double *overlap)
{
 /* multiclass is handled by one vs one */
 Instanceptr traindata;
 int i, j, k, ccount=0;
 double result = 0, maxefficiency, min1, max1, min2, max2;
 double efficiency, binoverlap;
 read_from_train_file(d, &traindata);
 realize(traindata);
 exchange_classdefno(d);
 maxefficiency = 0;
 *overlap = 1;
 for (i = 0; i < d->multifeaturecount; i++)
  {
   if (i != d->classdefno)
    {
     binoverlap = 0;
     efficiency = 0;
     for (j = 0; j < d->classno; j++)
      {
       for (k = j + 1; k < d->classno; k++)
        {
         find_bounds_of_feature_class(traindata, i, j, &min1, &max1);
         find_bounds_of_feature_class(traindata, i, k, &min2, &max2);
         ccount = 0;
         if (max1 > max2)
           ccount += find_thresholded_class_count(traindata, j, i, max2, UPPER);
         else
           ccount += find_thresholded_class_count(traindata, k, i, max1, UPPER);     
         if (min1 > min2)
           ccount += find_thresholded_class_count(traindata, k, i, min1, LOWER);
         else
           ccount += find_thresholded_class_count(traindata, j, i, min2, LOWER);     
         binoverlap += (fmin(max1, max2) - fmax(min1, min2)) / (fmax(max1, max2) + fmin(min1, min2));
         efficiency += ((double) ccount / (d->classcounts[j] + d->classcounts[k]));     
        }
      }
     *overlap *= (binoverlap / (d->classno * (d->classno - 1) / 2));
     if (efficiency > maxefficiency)
       maxefficiency = efficiency;
    }
  }
 result = (maxefficiency / (d->classno * (d->classno - 1) / 2));
 exchange_classdefno(d);
 deallocate(traindata);
 traindata = NULL;
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x5577a
movq (%r14), %rdi
callq 0xfc81
movq %rbx, %rdi
callq 0x11d5c
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %r15, 0x70(%rsp)
movq %rax, (%r15)
leaq 0x1407144(%rbx), %rax
movq %rax, 0x68(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r15d, %r15d
cmpl 0x1c0(%rbx), %r15d
jge 0x184cf
cmpl 0x1407128(%rbx), %r15d
je 0x184c7
movl 0x10(%rbx), %ecx
xorpd %xmm2, %xmm2
movq 0x68(%rsp), %rax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
pushq $0x1
popq %rax
movq %rax, 0x28(%rsp)
movslq %ecx, %rax
cmpq %rax, %r13
jge 0x18490
xorl %r12d, %r12d
movq 0x28(%rsp), %rax
leaq (%rax,%r12), %rbp
cmpl %ebp, %ecx
jle 0x1847d
movapd %xmm2, 0x90(%rsp)
movq 0x10(%rsp), %rdi
movl %r15d, %esi
movl %r13d, %edx
leaq 0x48(%rsp), %rcx
leaq 0x40(%rsp), %r8
callq 0x10267
movq 0x10(%rsp), %rdi
movl %r15d, %esi
movl %ebp, %edx
leaq 0x38(%rsp), %rcx
leaq 0x30(%rsp), %r8
callq 0x10267
movsd 0x40(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movq 0x10(%rsp), %rdi
jbe 0x18369
movl %r13d, %esi
movl %r15d, %edx
movapd %xmm1, %xmm0
jmp 0x1836e
movl %ebp, %esi
movl %r15d, %edx
pushq $0x1
popq %rcx
callq 0x102e1
movl %eax, %r14d
movsd 0x48(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movq 0x10(%rsp), %rdi
jbe 0x18397
movl %ebp, %esi
movl %r15d, %edx
jmp 0x183a1
movl %r13d, %esi
movl %r15d, %edx
movapd %xmm1, %xmm0
xorl %ecx, %ecx
callq 0x102e1
movl %eax, %ebp
addl %r14d, %ebp
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x30(%rsp), %xmm1
movsd %xmm1, 0x88(%rsp)
callq 0x34c95
movaps %xmm0, 0x50(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x38(%rsp), %xmm1
movsd %xmm1, 0x78(%rsp)
callq 0x34c90
movapd 0x50(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, 0x50(%rsp)
movsd 0x18(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
callq 0x34c90
movsd %xmm0, 0x18(%rsp)
movsd 0x80(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
callq 0x34c95
cvtsi2sd %ebp, %xmm1
addsd 0x18(%rsp), %xmm0
movq 0x20(%rsp), %rax
movl (%rax,%r12,4), %eax
addl 0x1407140(%rbx,%r13,4), %eax
movapd 0x50(%rsp), %xmm2
unpcklpd %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
cvtsi2sd %eax, %xmm1
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
divpd %xmm0, %xmm2
movapd %xmm2, %xmm0
movapd 0x90(%rsp), %xmm2
addpd %xmm0, %xmm2
movl 0x10(%rbx), %ecx
incq %r12
jmp 0x182f9
incq %r13
incq 0x28(%rsp)
addq $0x4, 0x20(%rsp)
jmp 0x182ea
leal -0x1(%rcx), %eax
imull %ecx, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
cvtsi2sd %eax, %xmm0
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
movq 0x70(%rsp), %rax
mulsd (%rax), %xmm1
movsd %xmm1, (%rax)
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
ucomisd 0x8(%rsp), %xmm2
jbe 0x184c7
movsd %xmm2, 0x8(%rsp)
incl %r15d
jmp 0x182b4
movl 0x10(%rbx), %ecx
leal -0x1(%rcx), %eax
imull %ecx, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
cvtsi2sd %eax, %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq %rbx, %rdi
callq 0x11d5c
movq 0x10(%rsp), %rdi
callq 0x2c010
movsd 0x8(%rsp), %xmm0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq