// File: /workspace/github_c_makefile_star2_O1/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, %r14
movq %rdx, 0x20(%rsp)
leaq 0x34ff5(%rip), %rbx     # 0xd2870
movq (%rbx), %rax
movslq %esi, %r13
imulq $0x340, %r13, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
cmpl $0x2, %eax
je 0x9d8a7
xorl %ebp, %ebp
cmpl $0x1, %eax
je 0x9da34
testl %eax, %eax
jne 0x9da97
movq %rcx, 0x10(%rsp)
movq %r14, 0x28(%rsp)
leaq 0x1c(%rsp), %rdx
callq 0x9d053
movq %rax, %r15
movq (%rbx), %rax
cmpl $0x0, 0x10(%rax)
jle 0x9d8e2
xorl %ecx, %ecx
xorl %edx, %edx
movl %ecx, 0x40(%rsp,%rdx,4)
movl %ecx, 0x108(%rsp,%rdx,4)
incq %rdx
movslq 0x10(%rax), %rsi
cmpq %rsi, %rdx
jl 0x9d8cb
movslq 0x1c(%rsp), %r14
testq %r14, %r14
jle 0x9d909
movq %r14, %rbp
movq %r15, %r12
movq %r12, %rdi
callq 0x2eaca
cltq
incl 0x40(%rsp,%rax,4)
addq $0x30, %r12
decq %rbp
jne 0x9d8f2
testl %r14d, %r14d
jle 0x9da74
shlq $0x4, %r14
leaq (%r14,%r14,2), %r12
xorl %r14d, %r14d
movsd 0x4beb(%rip), %xmm1     # 0xa2510
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %rbp
movq (%rbx), %rax
cmpl $0x0, 0x30f08(%rax,%rbp)
movq (%r15,%r14), %rax
je 0x9d94b
movsd (%rax,%r13,8), %xmm0
jmp 0x9d954
xorps %xmm0, %xmm0
cvtsi2sdl (%rax,%r13,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x9d960
jnp 0x9da05
movsd %xmm0, (%rsp)
ucomisd 0x4ba3(%rip), %xmm1     # 0xa2510
jne 0x9d975
jnp 0x9da00
movsd %xmm1, 0x38(%rsp)
movq %r13, %rbp
movq %rbx, %r13
leaq 0x40(%rsp), %rdi
callq 0x1d7dc
movq 0x28(%rsp), %rbx
movsd (%rbx), %xmm1
movsd %xmm0, 0x30(%rsp)
callq 0x38d8e
testl %eax, %eax
je 0x9d9f5
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rbx)
movsd (%rsp), %xmm1
movsd 0x38(%rsp), %xmm0
addsd %xmm1, %xmm0
mulsd 0x5354(%rip), %xmm0     # 0xa2d18
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
movsd (%rbx), %xmm0
movl $0x1, 0xc(%rsp)
ucomisd 0x5327(%rip), %xmm0     # 0xa2d08
movq %r13, %rbx
movq %rbp, %r13
movq 0x10(%rsp), %rbp
jne 0x9da05
jp 0x9da05
jmp 0x9da8a
movq %r13, %rbx
movq %rbp, %r13
movq 0x10(%rsp), %rbp
movsd (%rsp), %xmm1
movsd %xmm1, (%rsp)
leaq (%r15,%r14), %rdi
callq 0x2eaca
cltq
decl 0x40(%rsp,%rax,4)
incl 0x108(%rsp,%rax,4)
addq $0x30, %r14
movsd (%rsp), %xmm1
cmpq %r14, %r12
jne 0x9d932
jmp 0x9da7c
leaq 0x40(%rsp), %r15
movq %r15, %rdx
callq 0x9ccd7
movq %r15, %rdi
callq 0x1d4c4
movsd (%r14), %xmm1
movsd %xmm0, (%rsp)
callq 0x38d8e
testl %eax, %eax
je 0x9da97
movsd (%rsp), %xmm0
movsd %xmm0, (%r14)
movq 0x20(%rsp), %rax
movq $0x0, (%rax)
jmp 0x9da92
movl $0x0, 0xc(%rsp)
movq %r15, %rdi
callq 0x39194
movl 0xc(%rsp), %ebp
jmp 0x9da97
movq %r15, %rdi
callq 0x39194
movl $0x1, %ebp
movl %ebp, %eax
addq $0x4e68, %rsp           # imm = 0x4E68
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq