// File: /workspace/github_c_makefile_star2_O3/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 $0x88, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0x5dcbd
movq (%rbx), %rdi
callq 0x10954
leaq 0x1407128(%r14), %rbx
leaq 0x1407138(%r14), %rsi
movq %rbx, %rdi
movq %rsi, 0x40(%rsp)
callq 0x3a5af
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%r15)
cmpl $0x0, 0x1c0(%r14)
jle 0x1a24a
leaq 0x1407144(%r14), %rax
movq %rax, 0x48(%rsp)
xorl %r13d, %r13d
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x8b516(%rip), %xmm0    # 0xa5520
movq %rbx, 0x58(%rsp)
movq %r15, 0x50(%rsp)
movq %r14, 0x68(%rsp)
cmpl (%rbx), %r13d
je 0x1a238
movl 0x10(%r14), %eax
xorpd %xmm3, %xmm3
testl %eax, %eax
jle 0x1a1fb
movl $0x1, %r12d
movq 0x48(%rsp), %rcx
movq %rcx, 0x18(%rsp)
xorl %edx, %edx
movq %rdx, %rbp
incq %rdx
movslq %eax, %rcx
cmpq %rcx, %rdx
jge 0x1a1da
movq %rdx, 0x60(%rsp)
xorl %r15d, %r15d
movapd %xmm3, 0x70(%rsp)
movq 0x10(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x38(%rsp), %rcx
leaq 0x30(%rsp), %r8
callq 0x10f4d
movq 0x10(%rsp), %rdi
movq %r12, %rbx
addq %r15, %r12
movl %r13d, %esi
movl %r12d, %edx
leaq 0x28(%rsp), %rcx
leaq 0x20(%rsp), %r8
callq 0x10f4d
movsd 0x30(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movq 0x10(%rsp), %rdi
jbe 0x1a0bf
movl %ebp, %esi
movl %r13d, %edx
movapd %xmm1, %xmm0
jmp 0x1a0c5
movl %r12d, %esi
movl %r13d, %edx
movl $0x1, %ecx
callq 0x10fc6
movl %eax, %r14d
movsd 0x38(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movq 0x10(%rsp), %rdi
jbe 0x1a0f1
movl %r12d, %esi
movl %r13d, %edx
jmp 0x1a0fa
movl %ebp, %esi
movl %r13d, %edx
movapd %xmm1, %xmm0
xorl %ecx, %ecx
callq 0x10fc6
movq %rbx, %r12
movsd 0x30(%rsp), %xmm6
movsd 0x20(%rsp), %xmm5
movsd 0x38(%rsp), %xmm3
movsd 0x28(%rsp), %xmm1
ucomisd %xmm6, %xmm6
movapd %xmm5, %xmm0
jp 0x1a12e
movapd %xmm5, %xmm0
maxsd %xmm6, %xmm0
ucomisd %xmm3, %xmm3
movapd %xmm1, %xmm4
jp 0x1a140
movapd %xmm1, %xmm4
minsd %xmm3, %xmm4
addl %r14d, %eax
movapd %xmm6, %xmm2
cmpunordsd %xmm6, %xmm2
movapd %xmm2, %xmm7
andpd %xmm5, %xmm7
minsd %xmm6, %xmm5
andnpd %xmm5, %xmm2
orpd %xmm7, %xmm2
movapd %xmm3, %xmm5
cmpunordsd %xmm3, %xmm5
movapd %xmm5, %xmm6
andpd %xmm1, %xmm6
maxsd %xmm3, %xmm1
andnpd %xmm1, %xmm5
orpd %xmm6, %xmm5
subsd %xmm5, %xmm2
addsd %xmm4, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movq 0x18(%rsp), %rax
movl (%rax,%r15,4), %eax
movq 0x68(%rsp), %r14
addl 0x1407140(%r14,%rbp,4), %eax
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
unpcklpd %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
unpcklpd %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0]
divpd %xmm0, %xmm2
movapd 0x70(%rsp), %xmm3
addpd %xmm2, %xmm3
movl 0x10(%r14), %eax
incq %r15
leal (%r12,%r15), %ecx
cmpl %ecx, %eax
jg 0x1a05e
movslq %eax, %rcx
movq 0x60(%rsp), %rdx
incq %r12
addq $0x4, 0x18(%rsp)
cmpq %rcx, %rdx
jl 0x1a044
movq 0x50(%rsp), %r15
movsd (%r15), %xmm0
movq 0x58(%rsp), %rbx
leal -0x1(%rax), %ecx
imull %eax, %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movapd %xmm0, %xmm2
movapd %xmm3, %xmm0
divsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, (%r15)
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
ucomisd 0x8(%rsp), %xmm3
jbe 0x1a238
movsd %xmm3, 0x8(%rsp)
incl %r13d
cmpl 0x1c0(%r14), %r13d
jl 0x1a019
jmp 0x1a254
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x10(%r14), %eax
leal -0x1(%rax), %ecx
imull %eax, %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
callq 0x3a5af
movq 0x10(%rsp), %rdi
callq 0x2ff55
movsd 0x8(%rsp), %xmm0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq