// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/srm.c
// Function: vc_estimate_optimized_of_decision_tree
void vc_estimate_optimized_of_decision_tree(int featurecount, int nodecount, int experimentcount, char* featuretypes, int* featurevaluecounts)
{
 /*!Last Changed 24.09.2006 added different feature types*/
 /*!Last Changed 03.05.2006 run for a specific featurecount and nodecount*/
 /*!Last Changed 01.04.2006*/
 int positivecount, positivenotsaturated, total, totalmove;
 void* parameters;
 double vcdimension, vcdimensionremove, msefitting, msefittingremove, averagecount;
 Vcestimateptr estimates, tmpvc, nextvc, tmpvc2, vc1, vc2, vc3, vc4, removed, added;
 parameters = prepare_supervised_algorithm_parameters(NBTREE);
 ((Nodeboundedtree_parameterptr) parameters)->prunetype = NOPRUNING; 
 if (featurevaluecounts[0] > 1)
   ((Nodeboundedtree_parameterptr) parameters)->usediscrete = BOOLEAN_TRUE;
 else
   ((Nodeboundedtree_parameterptr) parameters)->usediscrete = BOOLEAN_FALSE;
 current_dataset = generate_random_dataset("VC-Estimate", featurecount, featuretypes, featurevaluecounts, 2);
 averagecount = average_valuecount(current_dataset);
 estimates = vc_estimates_for_a_design(parameters, nodecount, current_dataset, experimentcount, averagecount);
 total = number_of_experiments(estimates);
 totalmove = 0;
 while (1)
  {
   vcdimension = vc_dimension_for_a_design(estimates, OPTIMIZED_DESIGN, -1);
   msefitting = mse_fitting_for_vc_dimension(estimates, vcdimension, -1);
   positivecount = 0;
   positivenotsaturated = 0;
   /*Calculate contributions*/
   tmpvc = estimates;
   while (tmpvc)
    {
     vcdimensionremove = vc_dimension_for_a_design(estimates, OPTIMIZED_DESIGN, tmpvc->n);
     msefittingremove = mse_fitting_for_vc_dimension(estimates, vcdimensionremove, tmpvc->n);
     tmpvc->contribution = (msefittingremove - msefitting) / tmpvc->count;
     if (tmpvc->contribution > 0)
      {
       if (tmpvc->count / (total + 0.0) < 0.25)
        {
         positivenotsaturated++;
         tmpvc->issaturated = BOOLEAN_FALSE;
        }
       else
         tmpvc->issaturated = BOOLEAN_TRUE;
       positivecount++;
      }
     else
       tmpvc->issaturated = BOOLEAN_FALSE;
     tmpvc = tmpvc->next;
    }
   if (!positivecount || !positivenotsaturated)
     break;
   /*Sort contributions*/
   tmpvc = estimates->next;
   while (tmpvc)
    {
     nextvc = tmpvc->next;
     tmpvc2 = tmpvc;
     while (tmpvc2->before && tmpvc2->contribution > tmpvc2->before->contribution)
      {
       vc1 = tmpvc2->before->before;
       vc2 = tmpvc2->before;
       vc3 = tmpvc2;
       vc4 = tmpvc2->next;
       if (vc1)
         vc1->next = vc3;
       else
         estimates = vc3;
       if (vc4)
         vc4->before = vc2;
       vc2->before = vc3;
       vc2->next = vc4;
       vc3->before = vc1;
       vc3->next = vc2;
      }
     tmpvc = nextvc;
    }
   /*Move one experiment from the worst design point to the best design point, if not succesful to the second best etc.*/
   removed = estimates;
   while (removed->next)
     removed = removed->next;
   added = estimates;
   totalmove++;
   while (added && !(move_vc_estimates(estimates, removed, added, current_dataset, parameters, nodecount, msefitting)))
     added = added->next;
   if (!added)
     break;
  }
 deallocate_vc_estimates(estimates);
 set_default_variable("out1", vcdimension);
 set_default_variable("out2", totalmove);
 free_dataset(current_dataset);
 free_supervised_algorithm_parameters(NBTREE, parameters);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl $0x3fd, %edi            # imm = 0x3FD
callq 0x7410
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl $0x3, 0x14(%rax)
movq -0x20(%rbp), %rax
cmpl $0x1, (%rax)
jle 0xc16bb
movq -0x38(%rbp), %rax
movl $0x1, 0xc(%rax)
jmp 0xc16c6
movq -0x38(%rbp), %rax
movl $0x0, 0xc(%rax)
movl -0x4(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x2c451(%rip), %rdi     # 0xedb29
movl $0x2, %r8d
callq 0x1e750
movq %rax, %rcx
leaq 0x44153(%rip), %rax     # 0x105840
movq %rcx, (%rax)
leaq 0x44149(%rip), %rax     # 0x105840
movq (%rax), %rdi
callq 0x1dbf0
movsd %xmm0, -0x60(%rbp)
movq -0x38(%rbp), %rdi
movl -0x8(%rbp), %esi
leaq 0x4412e(%rip), %rax     # 0x105840
movq (%rax), %rdx
movl -0xc(%rbp), %ecx
movsd -0x60(%rbp), %xmm0
callq 0xc13d0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0xc0c80
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x68(%rbp), %rdi
movl $0x1, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xc0cc0
movsd %xmm0, -0x40(%rbp)
movq -0x68(%rbp), %rdi
movsd -0x40(%rbp), %xmm0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xc10f0
movsd %xmm0, -0x50(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0xc185d
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rax
movl (%rax), %edx
movl $0x1, %esi
callq 0xc0cc0
movsd %xmm0, -0x48(%rbp)
movq -0x68(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movq -0x70(%rbp), %rax
movl (%rax), %esi
callq 0xc10f0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
subsd -0x50(%rbp), %xmm0
movq -0x70(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm1
divsd %xmm1, %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x70(%rbp), %rax
movsd 0x10(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc1841
movq -0x70(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm1
cvtsi2sdl -0x2c(%rbp), %xmm0
xorps %xmm2, %xmm2
addsd %xmm2, %xmm0
divsd %xmm0, %xmm1
movsd 0x211a1(%rip), %xmm0    # 0xe29b0
ucomisd %xmm1, %xmm0
jbe 0xc182b
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movq -0x70(%rbp), %rax
movl $0x0, 0x8(%rax)
jmp 0xc1836
movq -0x70(%rbp), %rax
movl $0x1, 0x8(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc184c
movq -0x70(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x70(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0xc177f
cmpl $0x0, -0x24(%rbp)
je 0xc1869
cmpl $0x0, -0x28(%rbp)
jne 0xc186e
jmp 0xc1a75
movq -0x68(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0xc19b5
movq -0x70(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x28(%rcx)
movb %al, -0xb1(%rbp)
je 0xc18cb
movq -0x80(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq -0x80(%rbp), %rax
movq 0x28(%rax), %rax
ucomisd 0x10(%rax), %xmm0
seta %al
movb %al, -0xb1(%rbp)
movb -0xb1(%rbp), %al
testb $0x1, %al
jne 0xc18da
jmp 0xc19a8
movq -0x80(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x80(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0xc1934
movq -0x98(%rbp), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0xc193f
movq -0x98(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0xc195b
movq -0x90(%rbp), %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x98(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0xa0(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x88(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x90(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0xc1899
movq -0x78(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0xc187a
movq -0x68(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xc19e2
movq -0xa8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xa8(%rbp)
jmp 0xc19c0
movq -0x68(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, -0xb0(%rbp)
movb %al, -0xb2(%rbp)
je 0xc1a44
movq -0x68(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq 0x43e1f(%rip), %rax     # 0x105840
movq (%rax), %rcx
movq -0x38(%rbp), %r8
movl -0x8(%rbp), %r9d
movsd -0x50(%rbp), %xmm0
callq 0xc1ad0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0xb2(%rbp)
movb -0xb2(%rbp), %al
testb $0x1, %al
jne 0xc1a50
jmp 0xc1a64
movq -0xb0(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc19f6
cmpq $0x0, -0xb0(%rbp)
jne 0xc1a70
jmp 0xc1a75
jmp 0xc1739
movq -0x68(%rbp), %rdi
callq 0xc0b50
movsd -0x40(%rbp), %xmm0
leaq 0x240fe(%rip), %rdi     # 0xe5b88
callq 0x4b070
cvtsi2sdl -0x30(%rbp), %xmm0
leaq 0x240f3(%rip), %rdi     # 0xe5b8e
callq 0x4b070
leaq 0x43d99(%rip), %rax     # 0x105840
movq (%rax), %rdi
callq 0x1b710
movq -0x38(%rbp), %rsi
movl $0x3fd, %edi            # imm = 0x3FD
callq 0x5a00
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)