// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/svmtree.c
// Function: find_best_svmtree_feature
int find_best_svmtree_feature(Instanceptr instances, double* split, int positive, double C)
{
 /*!Last Changed 03.07.2009*/
 Instanceptr tmp;
 int counts[2][MAXCLASSES];
 int i, j, t, count = data_size(instances), bestfeature = -1, negativecount, positivecount, splitcount;
 double* splits = safemalloc(count * sizeof(double), "find_best_svmtree_feature", 2);
 Splitpointptr splitpoints = safemalloc(count * sizeof(Splitpoint), "find_best_svmtree_feature", 3);
 double fvalue, bestvalue, bestfsplit, besterror = +INT_MAX, error;
 for (i = 0; i < current_dataset->featurecount; i++)
   if (current_dataset->features[i].type != CLASSDEF)
    {
     for (j = 0, tmp = instances; j < count; j++, tmp = tmp->next)
      {
       if (give_classno(tmp) == positive)
         t = -1;
       else
         t = +1;
       splits[j] = (C - t * tmp->values[i].floatvalue) / t;
      }
     qsort(splits, count, sizeof(double), sort_function_double_ascending);
     if (splits[0] == splits[count - 1])
       continue;
     splitcount = 1;
     splitpoints[0].x = splits[0];
     splitpoints[0].count = 1;
     for (j = 1; j < count; j++)
       if (splitpoints[splitcount - 1].x != splits[j])
        {
         splitpoints[splitcount].x = splits[j];
         splitpoints[splitcount].count = 1;
         splitcount++;
        }
       else
         splitpoints[splitcount - 1].count++;
     bestvalue = +INT_MAX;
     fvalue = 0.0;
     negativecount = 0;
     positivecount = 0;
     for (j = splitcount - 1; j > 0; j--)
       if (splitpoints[j].x > 0)
        {
         positivecount += splitpoints[j].count;
         fvalue += (splitpoints[j].x - splitpoints[0].x) * splitpoints[j].count;
        }
       else
         break;
     for (j = 0; j < splitcount - 1; j++)
      {
       if (fvalue < bestvalue)
        {
         bestvalue = fvalue;
         bestfsplit = -(splitpoints[j].x + splitpoints[j + 1].x) / 2;
        }
       if (splitpoints[j].x < 0)
         negativecount += splitpoints[j].count;
       else
         positivecount -= splitpoints[j].count;
       fvalue += (negativecount - positivecount) * (splitpoints[j + 1].x - splitpoints[j].x);
      }
     find_counts_for_split(instances, i, bestfsplit, counts[0], counts[1], UNIVARIATE_CONDITION);
     error = error_of_split(counts, count);
     if (error < besterror)
      {
       bestfeature = i;
       *split = bestfsplit;
       besterror = error;
      }
    }
 safe_free(splits);
 safe_free(splitpoints);
 return bestfeature;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x449f0
movl %eax, -0x1d0(%rbp)
movl $0xffffffff, -0x1d4(%rbp) # imm = 0xFFFFFFFF
movslq -0x1d0(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x1d7c2(%rip), %rsi     # 0xee2b8
movl $0x2, %edx
callq 0x52d70
movq %rax, -0x1e8(%rbp)
movslq -0x1d0(%rbp), %rdi
shlq $0x4, %rdi
leaq 0x1d79f(%rip), %rsi     # 0xee2b8
movl $0x3, %edx
callq 0x52d70
movq %rax, -0x1f0(%rbp)
movsd 0x114de(%rip), %xmm0    # 0xe2010
movsd %xmm0, -0x210(%rbp)
movl $0x0, -0x1c4(%rbp)
movl -0x1c4(%rbp), %eax
leaq 0x34cef(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0xd10d8
leaq 0x34cd9(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x1c4(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x3, (%rax)
je 0xd10c2
movl $0x0, -0x1c8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x1c8(%rbp), %eax
cmpl -0x1d0(%rbp), %eax
jge 0xd0c50
movq -0x28(%rbp), %rdi
callq 0x43530
cmpl -0x14(%rbp), %eax
jne 0xd0bc8
movl $0xffffffff, -0x1cc(%rbp) # imm = 0xFFFFFFFF
jmp 0xd0bd2
movl $0x1, -0x1cc(%rbp)
movsd -0x20(%rbp), %xmm1
cvtsi2sdl -0x1cc(%rbp), %xmm0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsi2sdl -0x1cc(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x1e8(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c8(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xd0b9c
movq -0x1e8(%rbp), %rdi
movslq -0x1d0(%rbp), %rsi
movl $0x8, %edx
leaq -0x7d7aa(%rip), %rcx    # 0x534c0
callq 0x41f0
movq -0x1e8(%rbp), %rax
movsd (%rax), %xmm0
movq -0x1e8(%rbp), %rax
movl -0x1d0(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
ucomisd (%rax,%rcx,8), %xmm0
jne 0xd0c9b
jp 0xd0c9b
jmp 0xd10c4
movl $0x1, -0x1e0(%rbp)
movq -0x1e8(%rbp), %rax
movsd (%rax), %xmm0
movq -0x1f0(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x1f0(%rbp), %rax
movl $0x1, 0x8(%rax)
movl $0x1, -0x1c8(%rbp)
movl -0x1c8(%rbp), %eax
cmpl -0x1d0(%rbp), %eax
jge 0xd0dae
movq -0x1f0(%rbp), %rax
movl -0x1e0(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x1e8(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jne 0xd0d1c
jp 0xd0d1c
jmp 0xd0d75
movq -0x1e8(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x1f0(%rbp), %rax
movslq -0x1e0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq -0x1f0(%rbp), %rax
movslq -0x1e0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl $0x1, 0x8(%rax)
movl -0x1e0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e0(%rbp)
jmp 0xd0d98
movq -0x1f0(%rbp), %rax
movl -0x1e0(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0xd0d9a
movl -0x1c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c8(%rbp)
jmp 0xd0cd3
movsd 0x1125a(%rip), %xmm0    # 0xe2010
movsd %xmm0, -0x200(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x1f8(%rbp)
movl $0x0, -0x1d8(%rbp)
movl $0x0, -0x1dc(%rbp)
movl -0x1e0(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x1c8(%rbp)
cmpl $0x0, -0x1c8(%rbp)
jle 0xd0eaf
movq -0x1f0(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd0e97
movq -0x1f0(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl -0x1dc(%rbp), %eax
movl %eax, -0x1dc(%rbp)
movq -0x1f0(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x1f0(%rbp), %rax
subsd (%rax), %xmm0
movq -0x1f0(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cvtsi2sdl 0x8(%rax), %xmm2
movsd -0x1f8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x1f8(%rbp)
jmp 0xd0e99
jmp 0xd0eaf
jmp 0xd0e9b
movl -0x1c8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c8(%rbp)
jmp 0xd0dec
movl $0x0, -0x1c8(%rbp)
movl -0x1c8(%rbp), %eax
movl -0x1e0(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0xd1035
movsd -0x1f8(%rbp), %xmm1
movsd -0x200(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd0f58
movsd -0x1f8(%rbp), %xmm0
movsd %xmm0, -0x200(%rbp)
movq -0x1f0(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x1f0(%rbp), %rax
movl -0x1c8(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x11d54(%rip), %xmm1    # 0xe2ca0
divsd %xmm1, %xmm0
movsd %xmm0, -0x208(%rbp)
movq -0x1f0(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0xd0f9c
movq -0x1f0(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl -0x1d8(%rbp), %eax
movl %eax, -0x1d8(%rbp)
jmp 0xd0fc2
movq -0x1f0(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movl -0x1dc(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1dc(%rbp)
movl -0x1d8(%rbp), %eax
subl -0x1dc(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x1f0(%rbp), %rax
movl -0x1c8(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm2
movq -0x1f0(%rbp), %rax
movslq -0x1c8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
subsd (%rax), %xmm2
movsd -0x1f8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x1f8(%rbp)
movl -0x1c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c8(%rbp)
jmp 0xd0eb9
movq -0x8(%rbp), %rdi
movl -0x1c4(%rbp), %esi
movsd -0x208(%rbp), %xmm0
leaq -0x1c0(%rbp), %rdx
leaq -0x1c0(%rbp), %rcx
addq $0xc8, %rcx
xorl %r8d, %r8d
callq 0xdd8e0
leaq -0x1c0(%rbp), %rdi
movl -0x1d0(%rbp), %esi
callq 0x2adc0
movsd %xmm0, -0x218(%rbp)
movsd -0x218(%rbp), %xmm1
movsd -0x210(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd10c0
movl -0x1c4(%rbp), %eax
movl %eax, -0x1d4(%rbp)
movsd -0x208(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x218(%rbp), %xmm0
movsd %xmm0, -0x210(%rbp)
jmp 0xd10c2
jmp 0xd10c4
movl -0x1c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c4(%rbp)
jmp 0xd0b44
movq -0x1e8(%rbp), %rdi
callq 0x52e80
movq -0x1f0(%rbp), %rdi
callq 0x52e80
movl -0x1d4(%rbp), %eax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nop