// File: /workspace/github_c_makefile_star2_O2/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 $0xc8, %rsp
movq %rsi, 0xb0(%rsp)
movq %rdi, %r15
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0x1bbad
movsd 0x29cd(%rip), %xmm0     # 0x95518
movsd %xmm0, 0x48(%rsp)
pushq $-0x1
popq %rax
movl %eax, 0x2c(%rsp)
xorl %ebx, %ebx
leaq 0x3ad0f(%rip), %r14     # 0xcd870
pushq $0x1
popq %rbp
leaq 0xc0(%rsp), %r12
movq (%r14), %rax
movl 0x1c0(%rax), %eax
decl %eax
cmpl %eax, %ebx
jge 0x92eb1
cmpl $0x2, 0x90(%rsp)
jg 0x92c0e
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x80(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %r15, %rdi
movl %ebx, %esi
leaq 0x58(%rsp), %rdx
pushq $0x2
popq %rcx
callq 0x92ace
movsd %xmm0, 0x20(%rsp)
movsd 0x48(%rsp), %xmm1
callq 0x34c76
testl %eax, %eax
je 0x92eaa
movsd 0x58(%rsp), %xmm0
movq 0xb0(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x20(%rsp), %xmm0
ucomisd 0x3125(%rip), %xmm0     # 0x95d18
movl %ebx, 0x2c(%rsp)
movsd %xmm0, 0x48(%rsp)
jne 0x92eaa
jp 0x92eaa
jmp 0x92f1e
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x98(%rsp), %r14
movq %r14, %rdi
callq 0x4dcb2
movq 0xa8(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x98(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
movl %ebx, %esi
leaq 0x58(%rsp), %rdx
pushq $0x2
popq %rcx
callq 0x92ace
movsd %xmm0, 0x50(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x4dcb2
movq 0xa8(%rsp), %rax
movq %rax, 0x70(%rsp)
movups 0x98(%rsp), %xmm0
movaps %xmm0, 0x60(%rsp)
xorl %r14d, %r14d
movsd 0x58(%rsp), %xmm0
testb $0x1, %r14b
jne 0x92e22
xorl %r13d, %r13d
xorl %r14d, %r14d
movslq 0x40(%rsp), %rax
cmpq %rax, %r13
movsd %xmm0, 0x20(%rsp)
jge 0x92db8
movq 0x38(%rsp), %rax
movl %ebp, %ecx
subl (%rax,%r13,4), %ecx
movl %ecx, (%rax,%r13,4)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
movl %ebx, %esi
movq %r12, %rdx
pushq $0x2
popq %rcx
callq 0x92ace
movsd %xmm0, 0xb8(%rsp)
movsd 0x50(%rsp), %xmm1
callq 0x34c76
testl %eax, %eax
je 0x92d9b
movsd 0xc0(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x4dd42
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x98(%rsp), %rdi
callq 0x4dcb2
movq 0xa8(%rsp), %rax
movq %rax, 0x70(%rsp)
movups 0x98(%rsp), %xmm0
movaps %xmm0, 0x60(%rsp)
movl %ebp, %r14d
movsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x38(%rsp), %rax
movl %ebp, %ecx
subl (%rax,%r13,4), %ecx
movl %ecx, (%rax,%r13,4)
incq %r13
movsd 0x20(%rsp), %xmm0
jmp 0x92cca
testl %r14d, %r14d
sete %r14b
je 0x92cba
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x4dd42
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x98(%rsp), %rdi
callq 0x4dcb2
movq 0xa8(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x98(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movsd 0x20(%rsp), %xmm0
jmp 0x92cba
movsd %xmm0, 0x58(%rsp)
movsd %xmm0, 0x20(%rsp)
movsd 0x50(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
callq 0x34c76
testl %eax, %eax
je 0x92e71
movq 0xb0(%rsp), %rax
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x50(%rsp), %xmm0
ucomisd 0x2eb5(%rip), %xmm0     # 0x95d18
movl %ebx, 0x2c(%rsp)
movsd %xmm0, 0x48(%rsp)
jne 0x92e71
jnp 0x92eec
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x4dd42
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movapd 0x30(%rsp), %xmm0
movupd %xmm0, (%rsp)
callq 0x4dd42
leaq 0x3a9c6(%rip), %r14     # 0xcd870
incl %ebx
jmp 0x92b6c
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x4dd42
movsd 0x48(%rsp), %xmm0
ucomisd 0x2e1b(%rip), %xmm0     # 0x95cf8
pushq $-0x1
popq %rbx
movl 0x2c(%rsp), %eax
cmovnel %eax, %ebx
cmovpl %eax, %ebx
jmp 0x92f3e
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x4dd42
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movapd 0x30(%rsp), %xmm0
movupd %xmm0, (%rsp)
callq 0x4dd42
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x80(%rsp), %xmm0
movupd %xmm0, (%rsp)
callq 0x4dd42
movl %ebx, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq