// File: /workspace/github_c_makefile_star2_O1/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 0x1d994
leaq 0x33705(%rip), %rax     # 0xd2870
movq (%rax), %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x2, 0x1c0(%rax)
jl 0x9f563
leaq 0xa0(%rsp), %r12
leaq 0xc8(%r12), %r13
xorl %ebx, %ebx
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
movsd 0x3376(%rip), %xmm0     # 0xa2518
movsd %xmm0, 0x48(%rsp)
cmpl $0x2, 0x90(%rsp)
jg 0x9f255
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 0x9ef42
movq %r15, %rdi
movl %ebx, %esi
movsd %xmm0, 0x40(%rsp)
movq %r12, %rdx
movq %r13, %rcx
movl $0x2, %r8d
callq 0x9e1bf
movq %r12, %rdi
callq 0x1d7dc
movsd %xmm0, 0x68(%rsp)
movsd 0x48(%rsp), %xmm1
callq 0x38d8e
testl %eax, %eax
je 0x9f4f8
movq 0x70(%rsp), %rax
movsd 0x40(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x68(%rsp), %xmm0
ucomisd 0x3ace(%rip), %xmm0     # 0xa2d08
movl %ebx, 0x1c(%rsp)
movsd %xmm0, 0x48(%rsp)
jne 0x9f4f8
jp 0x9f4f8
jmp 0x9f563
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x544be
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 0x9ef42
movq %r15, %rdi
movl %ebx, %esi
movsd %xmm0, 0x78(%rsp)
movq %r12, %rdx
movq %r13, %rcx
movl $0x2, %r8d
callq 0x9e1bf
movq %r12, %rdi
callq 0x1d7dc
movsd %xmm0, 0x40(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x544be
movq 0xb0(%rsp), %rax
movq %rax, 0x60(%rsp)
movupd 0xa0(%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
cmpl $0x0, 0x30(%rsp)
jle 0x9f42c
xorl %r14d, %r14d
xorl %ebp, %ebp
movq 0x28(%rsp), %rax
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 0x9ef42
movq %r15, %rdi
movl %ebx, %esi
movsd %xmm0, 0x68(%rsp)
movq %r12, %rdx
movq %r13, %rcx
movl $0x2, %r8d
callq 0x9e1bf
movq %r12, %rdi
callq 0x1d7dc
movsd %xmm0, 0x98(%rsp)
movsd 0x40(%rsp), %xmm1
callq 0x38d8e
testl %eax, %eax
je 0x9f402
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x54550
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x544be
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), %rax
cmpq %rax, %r14
jl 0x9f323
testl %ebp, %ebp
sete %al
jmp 0x9f42e
movb $0x1, %al
testb %al, %al
jne 0x9f486
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x54550
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x544be
movq 0xb0(%rsp), %rax
movq %rax, 0x30(%rsp)
movupd 0xa0(%rsp), %xmm0
movapd %xmm0, 0x20(%rsp)
jmp 0x9f313
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
callq 0x38d8e
testl %eax, %eax
je 0x9f4c6
movq 0x70(%rsp), %rax
movsd 0x78(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x40(%rsp), %xmm0
ucomisd 0x3850(%rip), %xmm0     # 0xa2d08
movl %ebx, 0x1c(%rsp)
movsd %xmm0, 0x48(%rsp)
jne 0x9f4c6
jnp 0x9f533
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x54550
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movapd 0x20(%rsp), %xmm0
movupd %xmm0, (%rsp)
callq 0x54550
incl %ebx
leaq 0x3336f(%rip), %rax     # 0xd2870
movq (%rax), %rax
movl 0x1c0(%rax), %eax
decl %eax
cmpl %eax, %ebx
jl 0x9f1a8
movsd 0x48(%rsp), %xmm0
ucomisd 0x37ce(%rip), %xmm0     # 0xa2cf0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl 0x1c(%rsp), %eax
cmovnel %eax, %ebx
cmovpl %eax, %ebx
jmp 0x9f563
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x54550
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x54550
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x54550
movl %ebx, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq