// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/univariaterule.c
// Function: find_best_condition_for_realized_features
Decisionconditionptr find_best_condition_for_realized_features(Instanceptr growset, int positive)
{
 /*!Last Changed 22.01.2004*/
 int i, j, size, tpositive, t, tdotpositive, tdot, equal, equalpositive;
 Instanceptr instancelist, tmp;
 double bestgain = 0, valuebefore, value, it;
 Decisionconditionptr result;
 result = empty_condition();
 result->conditiontype = HYBRID_CONDITION;
 result->freeparam = 1;
 tmp = growset;
 tpositive = 0;
 t = 0;
 while (tmp)
  {
   t++;
   if (give_classno(tmp) == positive)
     tpositive++;
   tmp = tmp->next;
  }
 if (tpositive == 0)
  {
   safe_free(result);
   return NULL;
  }
 it = information(tpositive, t);
 for (i = 0; i < current_dataset->multifeaturecount - 1; i++)
  { 
   instancelist = sort_instances(growset, i, &size);
   valuebefore = real_feature(&(instancelist[0]), i);
   tdot = 1;
   if (give_classno(&(instancelist[0])) == positive)
     tdotpositive = 1;
   else
     tdotpositive = 0;
   equalpositive = tdotpositive;
   equal = 1;
   for (j = 1; j < size; j++)
    {
     value = real_feature(&(instancelist[j]), i);
     if (value != valuebefore)
      {
       check_for_bestgain(tdotpositive, tdot, it, &bestgain, result, '<', valuebefore + DBL_EPSILON, i);
       check_for_bestgain(tpositive - tdotpositive + equalpositive, t - tdot + equal, it, &bestgain, result, '>', valuebefore - DBL_EPSILON, i);
       valuebefore = value;
       equal = 0;
       equalpositive = 0;
      }
     equal++;
     if (give_classno(&(instancelist[j])) == positive)
      {
       tdotpositive++;
       equalpositive++;
      }
     tdot++;
    }
   check_for_bestgain(equalpositive, equal, it, &bestgain, result, '>', value - DBL_EPSILON, i);
   safe_free(instancelist);
  }
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, 0x8(%rsp)
movq %rdi, %rbx
andq $0x0, 0x28(%rsp)
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x71cd1
movq %rax, %r14
movabsq $0x200000001, %rax      # imm = 0x200000001
movq %rax, 0x3c(%r14)
pushq $-0x1
popq %r12
movq %rbx, 0x50(%rsp)
testq %rbx, %rbx
je 0x8f822
movq %rbx, %rdi
callq 0x2b47e
xorl %ecx, %ecx
cmpl 0x8(%rsp), %eax
sete %cl
addl %ecx, %ebp
movq 0x10(%rbx), %rbx
incl %r12d
jmp 0x8f801
testl %ebp, %ebp
je 0x8fa09
leal 0x1(%r12), %esi
movl %ebp, %edi
callq 0x71fae
movsd %xmm0, 0x18(%rsp)
xorl %ebx, %ebx
movq %r14, 0x38(%rsp)
movl %ebp, 0x30(%rsp)
movq %r12, 0x48(%rsp)
leaq 0x3e01d(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x1c0(%rax), %eax
decl %eax
cmpl %eax, %ebx
jge 0x8fa14
movq 0x50(%rsp), %rdi
movl %ebx, %esi
leaq 0x34(%rsp), %rdx
callq 0x90c1a
movq %rax, %r15
movq %rax, %rdi
movl %ebx, 0xc(%rsp)
movl %ebx, %esi
callq 0x2aea2
movsd %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0x2b47e
xorl %ecx, %ecx
cmpl 0x8(%rsp), %eax
sete %cl
movq %r15, 0x58(%rsp)
addq $0x30, %r15
movq %r15, 0x20(%rsp)
movl %r12d, %eax
movl %ecx, %r12d
pushq $0x1
popq %r14
movl %eax, %r13d
pushq $0x1
popq %rbp
movl %ecx, %ebx
movslq 0x34(%rsp), %rax
cmpq %rax, %r14
movsd 0x40(%rsp), %xmm1
jge 0x8f9c4
movl %ebx, %r15d
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %ebx
movl %ebx, %esi
callq 0x2aea2
movsd 0x10(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
jne 0x8f8fe
jnp 0x8f990
movsd %xmm1, 0x10(%rsp)
addsd 0x12a94(%rip), %xmm1    # 0xa23a0
movl %r12d, %edi
movl %r14d, %esi
movsd 0x18(%rsp), %xmm0
leaq 0x28(%rsp), %rdx
movq %r14, 0x60(%rsp)
movl %r13d, %r14d
movl %r12d, %r13d
movq 0x38(%rsp), %r12
movq %r12, %rcx
pushq $0x3c
popq %r8
movl %ebx, %r9d
callq 0x8f732
movl 0x30(%rsp), %edi
subl %r13d, %edi
addl %r15d, %edi
addl %r14d, %ebp
movsd 0x10(%rsp), %xmm1
addsd 0x12a41(%rip), %xmm1    # 0xa2398
movl %ebp, %esi
movsd 0x18(%rsp), %xmm0
leaq 0x28(%rsp), %rdx
movq %r12, %rcx
movl %r13d, %r12d
movl %r14d, %r13d
movq 0x60(%rsp), %r14
pushq $0x3e
popq %r8
movl %ebx, %r9d
callq 0x8f732
xorl %ebp, %ebp
xorl %ebx, %ebx
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x8f993
movl %r15d, %ebx
incl %ebp
movq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x2b47e
xorl %ecx, %ecx
cmpl 0x8(%rsp), %eax
sete %cl
addl %ecx, %r12d
addl %ecx, %ebx
incq %r14
decl %r13d
addq $0x30, %r15
movq %r15, 0x20(%rsp)
jmp 0x8f8bf
addsd 0x129cc(%rip), %xmm1    # 0xa2398
movl %ebx, %edi
movl %ebp, %esi
movsd 0x18(%rsp), %xmm0
leaq 0x28(%rsp), %rdx
movq 0x38(%rsp), %r14
movq %r14, %rcx
pushq $0x3e
popq %r8
movl 0xc(%rsp), %ebx
movl %ebx, %r9d
callq 0x8f732
movq 0x58(%rsp), %rdi
callq 0x34ff7
incl %ebx
movq 0x48(%rsp), %r12
jmp 0x8f84c
movq %r14, %rdi
callq 0x34ff7
xorl %r14d, %r14d
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq