// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/univariatetree.c
// Function: find_best_ldt_feature_for_realized
int find_best_ldt_feature_for_realized(Instanceptr instances, double* split)
{
/*!Last Changed 23.09.2004*/
 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->multifeaturecount - 1;i++)
   if (initial.count <= 2)
    {
     bestpartitiongain = find_gain_for_partition(instances,initial,i,&bestsplit, HYBRID_CONDITION);
     if (dless(bestpartitiongain,bestgain))
      {
       bestgain = bestpartitiongain;
       bestfeature = i;
       (*split) = bestsplit;
       if (bestpartitiongain == 0)
        {
         free_partition(initial);
         return bestfeature;
        }
      }
     continue;
    }
   else
    {
     current = create_copy(initial);
     bestpartitiongain = find_gain_for_partition(instances,current,i,&bestsplit, HYBRID_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, HYBRID_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);
    }
 free_partition(initial);
 if (bestgain == ISELL)
   return -1;
 else
   return bestfeature;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rsi, 0x70(%rsp)
movq %rdi, %r15
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0x1e10a
leaq 0x33723(%rip), %r14     # 0xd5870
movq (%r14), %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x2, 0x1c0(%rax)
jl 0xa253f
leaq 0xa0(%rsp), %r12
leaq 0xc8(%r12), %r13
xorl %ebx, %ebx
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
movsd 0x3394(%rip), %xmm0     # 0xa5518
movsd %xmm0, 0x48(%rsp)
cmpl $0x2, 0x90(%rsp)
jg 0xa2237
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x80(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %r15, %rdi
movl %ebx, %esi
movl $0x2, %edx
callq 0xa1f40
movq %r15, %rdi
movl %ebx, %esi
movsd %xmm0, 0x40(%rsp)
movq %r12, %rdx
movq %r13, %rcx
movl $0x2, %r8d
callq 0xa11fa
movq %r12, %rdi
callq 0x1df2d
movsd %xmm0, 0x68(%rsp)
movsd 0x48(%rsp), %xmm1
callq 0x39aee
testl %eax, %eax
je 0xa24db
movq 0x70(%rsp), %rax
movsd 0x40(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x68(%rsp), %xmm0
ucomisd 0x3aec(%rip), %xmm0     # 0xa5d08
movl %ebx, 0x1c(%rsp)
movsd %xmm0, 0x48(%rsp)
jne 0xa24db
jp 0xa24db
jmp 0xa253f
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x559be
movq 0xb0(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0xa0(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
movl %ebx, %esi
movl $0x2, %edx
callq 0xa1f40
movq %r15, %rdi
movl %ebx, %esi
movsd %xmm0, 0x78(%rsp)
movq %r12, %rdx
movq %r13, %rcx
movl $0x2, %r8d
callq 0xa11fa
movq %r12, %rdi
callq 0x1df2d
movsd %xmm0, 0x40(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x559be
movq 0xb0(%rsp), %rax
movq %rax, 0x60(%rsp)
movupd 0xa0(%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
cmpl $0x0, 0x30(%rsp)
jle 0xa2462
xorl %r14d, %r14d
movq 0x28(%rsp), %rax
xorl %ebp, %ebp
movl $0x1, %ecx
subl (%rax,%r14,4), %ecx
movl %ecx, (%rax,%r14,4)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movapd 0x20(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %r15, %rdi
movl %ebx, %esi
movl $0x2, %edx
callq 0xa1f40
movq %r15, %rdi
movl %ebx, %esi
movsd %xmm0, 0x68(%rsp)
movq %r12, %rdx
movq %r13, %rcx
movl $0x2, %r8d
callq 0xa11fa
movq %r12, %rdi
callq 0x1df2d
movsd %xmm0, 0x98(%rsp)
movsd 0x40(%rsp), %xmm1
callq 0x39aee
testl %eax, %eax
je 0xa23e4
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x55a69
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x559be
movq 0xb0(%rsp), %rax
movq %rax, 0x60(%rsp)
movups 0xa0(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
movl $0x1, %ebp
movsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x28(%rsp), %rax
movl $0x1, %ecx
subl (%rax,%r14,4), %ecx
movl %ecx, (%rax,%r14,4)
incq %r14
movslq 0x30(%rsp), %rcx
cmpq %rcx, %r14
jl 0xa230a
testl %ebp, %ebp
je 0xa2462
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x55a69
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x559be
movq 0xb0(%rsp), %rax
movq %rax, 0x30(%rsp)
movupd 0xa0(%rsp), %xmm0
movapd %xmm0, 0x20(%rsp)
testl %eax, %eax
jg 0xa2300
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
callq 0x39aee
testl %eax, %eax
je 0xa24a2
movq 0x70(%rsp), %rax
movsd 0x78(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x40(%rsp), %xmm0
ucomisd 0x3874(%rip), %xmm0     # 0xa5d08
movl %ebx, 0x1c(%rsp)
movsd %xmm0, 0x48(%rsp)
jne 0xa24a2
jnp 0xa250f
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x55a69
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movapd 0x20(%rsp), %xmm0
movupd %xmm0, (%rsp)
callq 0x55a69
leaq 0x33395(%rip), %r14     # 0xd5870
incl %ebx
movq (%r14), %rax
movl 0x1c0(%rax), %eax
decl %eax
cmpl %eax, %ebx
jl 0xa218a
movsd 0x48(%rsp), %xmm0
ucomisd 0x37f2(%rip), %xmm0     # 0xa5cf0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl 0x1c(%rsp), %eax
cmovnel %eax, %ebx
cmovpl %eax, %ebx
jmp 0xa253f
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x55a69
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x55a69
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x55a69
movl %ebx, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq