// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/univariatetree.c
// Function: find_best_ldt_feature
int find_best_ldt_feature(Instanceptr instances,double* split)
{
/*!Last Changed 26.01.2003*/
 int i,j,bestfeature=-1,improved;
 double bestgain=+INT_MAX,gain,bestpartitiongain,currentsplit,bestsplit;
 Partition initial,current,best;
 initial = get_initial_partition(instances);
 for (i=0;i<current_dataset->featurecount;i++)
   switch (current_dataset->features[i].type)
    {
     case REAL   :
     case INTEGER:if (initial.count <= 2)
                   {
                    bestpartitiongain = find_gain_for_partition(instances,initial,i,&bestsplit, UNIVARIATE_CONDITION);
                    if (dless(bestpartitiongain,bestgain))
                     {
                      bestgain = bestpartitiongain;
                      bestfeature = i;
                      (*split) = bestsplit;
                      if (bestpartitiongain == 0)
                       {
                        free_partition(initial);
                        return bestfeature;
                       }
                     }
                    continue;
                   }
                  current = create_copy(initial);
                  bestpartitiongain = find_gain_for_partition(instances,current,i,&bestsplit, UNIVARIATE_CONDITION);
                  best = create_copy(current);
                  improved = 1;
                  while (improved)
                   {
                    improved = 0;
                    for (j = 0; j < current.count; j++)
                     {
                      current.assignments[j] = 1-current.assignments[j];
                      gain = find_gain_for_partition(instances,current,i,&currentsplit, UNIVARIATE_CONDITION);
                      if (dless(gain,bestpartitiongain))
                       {
                        bestsplit = currentsplit;
                        bestpartitiongain = gain;
                        free_partition(best);
                        best = create_copy(current);
                        improved = 1;
                       }
                      current.assignments[j]=1-current.assignments[j];
                     }
                    if (improved)
                     {
                      free_partition(current);
                      current = create_copy(best);
                     }
                   }
                  if (dless(bestpartitiongain,bestgain))
                   {
                    bestgain = bestpartitiongain;
                    bestfeature = i;
                    (*split) = bestsplit;
                    if (bestgain == 0)
                     {
                      free_partition(best);
                      free_partition(current);
                      free_partition(initial);
                      return bestfeature;
                     }
                   }
                  free_partition(best);
                  free_partition(current);
                  break;
     case STRING :gain=information_gain_for_discrete_feature(instances,i);
                  if (dless(gain,bestgain))
                   {
                    bestgain=gain;
                    bestfeature=i;
                    (*split)=0;
                    if (gain==0)
                      return bestfeature;
                   }
                  break;
    }
 free_partition(initial);
 if (bestgain==ISELL)
   return -1;
 else
   return bestfeature;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movsd 0x2e3e(%rip), %xmm0     # 0xe2010
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x2aea0
movq -0xb0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0x26627(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0xdf72e
leaq 0x26611(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x114(%rbp)
testl %eax, %eax
je 0xdf272
jmp 0xdf250
movl -0x114(%rbp), %eax
subl $0x1, %eax
je 0xdf6c2
jmp 0xdf261
movl -0x114(%rbp), %eax
subl $0x2, %eax
jne 0xdf71e
jmp 0xdf272
cmpl $0x2, -0x58(%rbp)
jg 0xdf325
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq -0x68(%rbp), %rax
leaq -0x50(%rbp), %rdx
xorl %ecx, %ecx
movq (%rax), %r8
movq %r8, (%rsp)
movq 0x8(%rax), %r8
movq %r8, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xdec00
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x52750
cmpl $0x0, %eax
je 0xdf320
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movsd -0x50(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xdf31e
jp 0xdf31e
leaq -0x68(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xdf774
jmp 0xdf320
jmp 0xdf720
leaq -0xc8(%rbp), %rdi
leaq -0x68(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7a990
movq -0xc8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq -0x80(%rbp), %rax
leaq -0x50(%rbp), %rdx
xorl %ecx, %ecx
movq (%rax), %r8
movq %r8, (%rsp)
movq 0x8(%rax), %r8
movq %r8, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xdec00
movsd %xmm0, -0x40(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0x80(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7a990
movq -0xe0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x88(%rbp)
movl $0x1, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xdf5be
movl $0x0, -0x28(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x70(%rbp), %eax
jge 0xdf544
movq -0x78(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl $0x1, %edx
subl (%rax,%rcx,4), %edx
movq -0x78(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq -0x80(%rbp), %rax
leaq -0x48(%rbp), %rdx
xorl %ecx, %ecx
movq (%rax), %r8
movq %r8, (%rsp)
movq 0x8(%rax), %r8
movq %r8, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xdec00
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x52750
cmpl $0x0, %eax
je 0xdf51b
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq -0x98(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
leaq -0xf8(%rbp), %rdi
leaq -0x80(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7a990
movq -0xf8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x88(%rbp)
movl $0x1, -0x28(%rbp)
movq -0x78(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl $0x1, %edx
subl (%rax,%rcx,4), %edx
movq -0x78(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xdf415
cmpl $0x0, -0x28(%rbp)
je 0xdf5b9
leaq -0x80(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
leaq -0x110(%rbp), %rdi
leaq -0x98(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7a990
movq -0x110(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0xdf3fd
movsd -0x40(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x52750
cmpl $0x0, %eax
je 0xdf679
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movsd -0x50(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x30(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xdf677
jp 0xdf677
leaq -0x98(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
leaq -0x80(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
leaq -0x68(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xdf774
jmp 0xdf679
leaq -0x98(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
leaq -0x80(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
jmp 0xdf71e
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0xdbc30
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x52750
cmpl $0x0, %eax
je 0xdf71c
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xdf71a
jp 0xdf71a
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xdf774
jmp 0xdf71c
jmp 0xdf71e
jmp 0xdf720
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xdf20f
leaq -0x68(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x7aa80
movsd -0x30(%rbp), %xmm0
movsd 0x323b(%rip), %xmm1     # 0xe2998
ucomisd %xmm1, %xmm0
jne 0xdf76e
jp 0xdf76e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdf774
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq