// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/univariatetree.c
// Function: find_best_split_for_feature_i
int find_best_split_for_feature_i(Instanceptr instances, int currentfeature, double* split, double* bestgain)
{
 int j, k, counts[2][MAXCLASSES], size, isbetter = NO;
 Instanceptr sorted;
 double gain, value, valuebefore;
 switch (current_dataset->features[currentfeature].type)
  {
   case REAL   :
   case INTEGER:sorted = sort_instances(instances, currentfeature, &size);
                for (j = 0; j < current_dataset->classno; j++)
                 {
                  counts[0][j]=0;
                  counts[1][j]=0;
                 }
                for (k = 0; k < size; k++)
                 {
                  j = give_classno(&(sorted[k]));
                  counts[0][j]++;
                 }
                k = 0;
                valuebefore = -INT_MAX;
                while (k < size)
                 {
                  if (current_dataset->features[currentfeature].type == INTEGER)
                    value = sorted[k].values[currentfeature].intvalue;
                  else
                    value = sorted[k].values[currentfeature].floatvalue;
                  if (value != valuebefore)
                   {
                    if (valuebefore != -INT_MAX)
                     {
                      gain = information_gain(counts);
                      if (dless(gain, *bestgain))
                       {
                        *bestgain = gain;
                        isbetter = YES;
                        (*split) = (value + valuebefore)/2;
                        if (*bestgain == 0)
                         {
                          safe_free(sorted);
                          return YES;
                         }
                       }
                     }
                    valuebefore = value;
                   }
                  j = give_classno(&(sorted[k]));
                  counts[0][j]--;
                  counts[1][j]++;
                  k++;
                 }
                safe_free(sorted);
                break;
   case STRING :gain = information_gain_for_discrete_feature(instances, currentfeature);
                if (dless(gain, *bestgain))
                 {
                  *bestgain = gain;
                  isbetter = YES;
                  (*split) = 0;
                  if (gain == 0)
                    return YES;
                 }
                break;
  }
 return isbetter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4e68, %rsp           # imm = 0x4E68
movq %rcx, %r13
movq %rdx, 0x20(%rsp)
leaq 0x34ff9(%rip), %r12     # 0xd5870
movq (%r12), %rax
movslq %esi, %rbx
imulq $0x340, %rbx, %rbp      # imm = 0x340
movl 0x30f08(%rax,%rbp), %eax
cmpl $0x2, %eax
je 0xa08a5
xorl %r14d, %r14d
cmpl $0x1, %eax
je 0xa0a57
testl %eax, %eax
jne 0xa0a9f
leaq 0x1c(%rsp), %rdx
callq 0xa0055
movq %rax, %r15
movq (%r12), %rax
movslq 0x10(%rax), %rax
testq %rax, %rax
jle 0xa08d6
xorl %ecx, %ecx
xorl %edx, %edx
movl %ecx, 0x40(%rsp,%rdx,4)
movl %ecx, 0x108(%rsp,%rdx,4)
incq %rdx
cmpq %rax, %rdx
jb 0xa08c3
movslq 0x1c(%rsp), %r14
testq %r14, %r14
jle 0xa0a40
movq %rbp, 0x10(%rsp)
movq %r13, 0x28(%rsp)
movq %r14, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %r13
xorl %ebp, %ebp
leaq (%r15,%rbp), %rdi
callq 0x2f33a
cltq
incl 0x40(%rsp,%rax,4)
addq $0x30, %rbp
cmpq %rbp, %r13
jne 0xa08fb
testl %r14d, %r14d
jle 0xa0a40
xorl %r14d, %r14d
movsd 0x4be9(%rip), %xmm1     # 0xa5510
movl $0x0, 0x4(%rsp)
movq 0x10(%rsp), %rbp
movq (%r12), %rax
cmpl $0x0, 0x30f08(%rax,%rbp)
movq (%r15,%r14), %rax
je 0xa094d
movsd (%rax,%rbx,8), %xmm0
jmp 0xa0955
xorps %xmm0, %xmm0
cvtsi2sdl (%rax,%rbx,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0xa0961
jnp 0xa0a0f
movsd %xmm0, 0x8(%rsp)
ucomisd 0x4ba1(%rip), %xmm1     # 0xa5510
jne 0xa0977
jnp 0xa0a09
movsd %xmm1, 0x38(%rsp)
movq %rbx, %rbp
movq %r12, %rbx
leaq 0x40(%rsp), %rdi
callq 0x1df2d
movq 0x28(%rsp), %r12
movsd (%r12), %xmm1
movsd %xmm0, 0x30(%rsp)
callq 0x39aee
testl %eax, %eax
je 0xa09fe
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%r12)
movsd 0x8(%rsp), %xmm1
movsd 0x38(%rsp), %xmm0
addsd %xmm1, %xmm0
mulsd 0x534d(%rip), %xmm0     # 0xa5d18
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
movsd (%r12), %xmm0
movl $0x1, 0x4(%rsp)
ucomisd 0x531e(%rip), %xmm0     # 0xa5d08
movq %rbx, %r12
movq %rbp, %rbx
movq 0x10(%rsp), %rbp
jne 0xa0a0f
jp 0xa0a0f
jmp 0xa0ab4
movq %rbx, %r12
movq %rbp, %rbx
movq 0x10(%rsp), %rbp
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
leaq (%r15,%r14), %rdi
callq 0x2f33a
cltq
decl 0x40(%rsp,%rax,4)
incl 0x108(%rsp,%rax,4)
addq $0x30, %r14
movsd 0x8(%rsp), %xmm1
cmpq %r14, %r13
jne 0xa0934
jmp 0xa0a48
movl $0x0, 0x4(%rsp)
movq %r15, %rdi
callq 0x3a180
movl 0x4(%rsp), %r14d
jmp 0xa0a9f
leaq 0x40(%rsp), %r15
movq %r15, %rdx
callq 0x9fcd9
movq %r15, %rdi
callq 0x1dc4b
movsd (%r13), %xmm1
movsd %xmm0, 0x8(%rsp)
callq 0x39aee
testl %eax, %eax
je 0xa0a9f
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r13)
movq 0x20(%rsp), %rax
movq $0x0, (%rax)
movl $0x1, %r14d
movl %r14d, %eax
addq $0x4e68, %rsp           # imm = 0x4E68
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x3a180
jmp 0xa0a99