// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/univariaterule.c
// Function: find_best_condition
Decisionconditionptr find_best_condition(Instanceptr growset, int positive, Ripper_parameterptr param)
{
 /*!Last Changed 17.12.1005 added result->freeparam = 1*/
 /*!Last Changed 02.02.2004 added safecalloc*/
 /*!Last Changed 21.01.2004 added empty_condition*/
 /*!Last Changed 10.05.2003*/
 int i, j, size, tpositive, t, tdotpositive, tdot, equal, equalpositive, *featurecounts, *positivecounts;
 Instanceptr instancelist, tmp;
 double bestgain = 0, valuebefore, value, it, split;
 Partition p;
 Decisionconditionptr result;
 p = get_start_partition(growset, positive);
 result = empty_condition();
 result->conditiontype = UNIVARIATE_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->featurecount; i++)
   switch (current_dataset->features[i].type)
    { 
     case INTEGER:
     case    REAL:if ((!param->usefisher) || (t < param->smallsetsize && param->smallset))
                   {
                    instancelist = sort_instances(growset, i, &size);
                    if (current_dataset->features[i].type == INTEGER)
                      valuebefore = instancelist[0].values[i].intvalue;
                    else
                      valuebefore = instancelist[0].values[i].floatvalue;
                    tdot = 1;
                    if (give_classno(&(instancelist[0])) == positive)
                      tdotpositive = 1;
                    else
                      tdotpositive = 0;
                    equalpositive = tdotpositive;
                    equal = 1;
                    for (j = 1; j < size; j++)
                     {
                      if (current_dataset->features[i].type == INTEGER)
                        value = instancelist[j].values[i].intvalue;
                      else
                        value = instancelist[j].values[i].floatvalue;
                      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);
                   }
                  else
                   {
                    if (param->withoutoutliers)
                      split = find_split_for_partition_without_outliers(growset, p, i, param->conditiontype, param->variancerange);
                    else
                      split = find_split_for_partition(growset, p, i, param->conditiontype);
                    tdotpositive = 0;
                    tdot = 0;
                    tmp = growset;
                    while (tmp)
                     {
                      if (current_dataset->features[i].type == INTEGER)
                        value = tmp->values[i].intvalue;
                      else
                        value = tmp->values[i].floatvalue;
                      if (value < split)
                       {
                        tdot++;
                        if (give_classno(tmp) == positive)
                          tdotpositive++;
                       }
                      tmp = tmp->next;
                     }
                    check_for_bestgain(tdotpositive, tdot, it, &bestgain, result, '<', split, i);
                    check_for_bestgain(tpositive - tdotpositive, t - tdot, it, &bestgain, result, '>', split, i);
                   }
                  break;
     case  STRING:featurecounts = safecalloc(current_dataset->features[i].valuecount,sizeof(int), "find_best_condition", 94);
                  positivecounts = safecalloc(current_dataset->features[i].valuecount,sizeof(int), "find_best_condition", 95); 
                  tmp = growset;
                  while (tmp)
                   {
                    featurecounts[tmp->values[i].stringindex]++;
                    if (give_classno(tmp) == positive)
                      positivecounts[tmp->values[i].stringindex]++;
                    tmp = tmp->next;
                   }
                  for (j = 0; j < current_dataset->features[i].valuecount; j++)
                    check_for_bestgain(positivecounts[j], featurecounts[j], it, &bestgain, result, '=', j, i);
                  safe_free(featurecounts);
                  safe_free(positivecounts);
                  break;
    }
 free_partition(p);
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0xc8(%rbp), %rdi
callq 0x2af60
movq -0xc8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x98(%rbp)
movb $0x0, %al
callq 0xadea0
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0xb0(%rbp), %rax
movl $0x1, 0x3c(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0xda6f0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x68(%rbp), %rdi
callq 0x43530
cmpl -0x14(%rbp), %eax
jne 0xda6e2
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0xda6bb
cmpl $0x0, -0x30(%rbp)
jne 0xda70f
movq -0xb0(%rbp), %rdi
callq 0x52e80
movq $0x0, -0x8(%rbp)
jmp 0xdad47
movl -0x30(%rbp), %edi
movl -0x34(%rbp), %esi
callq 0xae3a0
movsd %xmm0, -0x88(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
leaq 0x2b10d(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0xdad17
leaq 0x2b0f7(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0xcc(%rbp)
testl %eax, %eax
je 0xda78c
jmp 0xda76a
movl -0xcc(%rbp), %eax
subl $0x1, %eax
je 0xdaba4
jmp 0xda77b
movl -0xcc(%rbp), %eax
subl $0x2, %eax
jne 0xdad07
jmp 0xda78c
movq -0x20(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0xda7b4
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0xda9f8
movq -0x20(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0xda9f8
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq -0x2c(%rbp), %rdx
callq 0xdc050
movq %rax, -0x60(%rbp)
leaq 0x2b071(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0xda802
movq -0x60(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x78(%rbp)
jmp 0xda817
movq -0x60(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x78(%rbp)
movl $0x1, -0x3c(%rbp)
movq -0x60(%rbp), %rdi
callq 0x43530
cmpl -0x14(%rbp), %eax
jne 0xda835
movl $0x1, -0x38(%rbp)
jmp 0xda83c
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x44(%rbp)
movl $0x1, -0x40(%rbp)
movl $0x1, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xda9b1
leaq 0x2afdd(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0xda8a1
movq -0x60(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x80(%rbp)
jmp 0xda8c1
movq -0x60(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
ucomisd -0x78(%rbp), %xmm0
jne 0xda8d4
jp 0xda8d4
jmp 0xda966
movl -0x38(%rbp), %edi
movl -0x3c(%rbp), %esi
movsd -0x88(%rbp), %xmm0
movq -0xb0(%rbp), %rcx
movsd 0x14147(%rip), %xmm1    # 0xeea38
addsd -0x78(%rbp), %xmm1
movl -0x24(%rbp), %r9d
leaq -0x70(%rbp), %rdx
movl $0x3c, %r8d
callq 0xda2d0
movl -0x30(%rbp), %edi
subl -0x38(%rbp), %edi
addl -0x44(%rbp), %edi
movl -0x34(%rbp), %esi
subl -0x3c(%rbp), %esi
addl -0x40(%rbp), %esi
movsd -0x88(%rbp), %xmm0
movq -0xb0(%rbp), %rcx
movsd -0x78(%rbp), %xmm1
movsd 0x14101(%rip), %xmm2    # 0xeea38
subsd %xmm2, %xmm1
movl -0x24(%rbp), %r9d
leaq -0x70(%rbp), %rdx
movl $0x3e, %r8d
callq 0xda2d0
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movq -0x60(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x43530
cmpl -0x14(%rbp), %eax
jne 0xda99a
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xda850
movl -0x44(%rbp), %edi
movl -0x40(%rbp), %esi
movsd -0x88(%rbp), %xmm0
movq -0xb0(%rbp), %rcx
movsd -0x80(%rbp), %xmm1
movsd 0x14065(%rip), %xmm2    # 0xeea38
subsd %xmm2, %xmm1
movl -0x24(%rbp), %r9d
leaq -0x70(%rbp), %rdx
movl $0x3e, %r8d
callq 0xda2d0
movq -0x60(%rbp), %rdi
callq 0x52e80
jmp 0xdab9f
movq -0x20(%rbp), %rax
cmpl $0x0, 0x20(%rax)
je 0xdaa48
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x20(%rbp), %rax
movl 0x28(%rax), %edx
movq -0x20(%rbp), %rax
movsd 0x48(%rax), %xmm0
leaq -0xa8(%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 0xde5e0
movsd %xmm0, -0x90(%rbp)
jmp 0xdaa83
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x20(%rbp), %rax
movl 0x28(%rax), %edx
leaq -0xa8(%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 0xdea30
movsd %xmm0, -0x90(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0xdab39
leaq 0x2ad95(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0xdaade
movq -0x68(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x80(%rbp)
jmp 0xdaaf3
movq -0x68(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm1
movsd -0x90(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xdab28
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x68(%rbp), %rdi
callq 0x43530
cmpl -0x14(%rbp), %eax
jne 0xdab26
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xdab28
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0xdaa99
movl -0x38(%rbp), %edi
movl -0x3c(%rbp), %esi
movsd -0x88(%rbp), %xmm0
movq -0xb0(%rbp), %rcx
movsd -0x90(%rbp), %xmm1
movl -0x24(%rbp), %r9d
leaq -0x70(%rbp), %rdx
movl $0x3c, %r8d
callq 0xda2d0
movl -0x30(%rbp), %edi
subl -0x38(%rbp), %edi
movl -0x34(%rbp), %esi
subl -0x3c(%rbp), %esi
movsd -0x88(%rbp), %xmm0
movq -0xb0(%rbp), %rcx
movsd -0x90(%rbp), %xmm1
movl -0x24(%rbp), %r9d
leaq -0x70(%rbp), %rdx
movl $0x3e, %r8d
callq 0xda2d0
jmp 0xdad07
leaq 0x2ac95(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq 0x18(%rax), %rdi
movl $0x4, %esi
leaq 0x80f9(%rip), %rdx      # 0xe2ccb
movl $0x5e, %ecx
callq 0x52f40
movq %rax, -0x50(%rbp)
leaq 0x2ac59(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq 0x18(%rax), %rdi
movl $0x4, %esi
leaq 0x80bd(%rip), %rdx      # 0xe2ccb
movl $0x5f, %ecx
callq 0x52f40
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0xdac7f
movq -0x50(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x24(%rbp), %rdx
movslq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x68(%rbp), %rdi
callq 0x43530
cmpl -0x14(%rbp), %eax
jne 0xdac71
movq -0x58(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x24(%rbp), %rdx
movslq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0xdac24
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
leaq 0x2abb0(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
addq $0x30f08, %rcx          # imm = 0x30F08
movslq -0x24(%rbp), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
jge 0xdacf5
movq -0x58(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x50(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %esi
movsd -0x88(%rbp), %xmm0
movq -0xb0(%rbp), %rcx
cvtsi2sdl -0x28(%rbp), %xmm1
movl -0x24(%rbp), %r9d
leaq -0x70(%rbp), %rdx
movl $0x3d, %r8d
callq 0xda2d0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xdac86
movq -0x50(%rbp), %rdi
callq 0x52e80
movq -0x58(%rbp), %rdi
callq 0x52e80
jmp 0xdad09
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xda729
leaq -0xa8(%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
movq -0xb0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)