// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/srm.c
// Function: vc_dimension_for_a_design
double vc_dimension_for_a_design(Vcestimateptr estimates, DESIGN_TYPE experimenttype, int n)
{
 /*!Last Changed 01.04.2006*/
 Vcestimateptr tmpvc = estimates, nextvc;
 Epsilonestimateptr tmpepsilon;
 int count = 0, i;
 double sumvcdimension = 0, sumepsilon, vcdimension, difference, before, after;
 switch (experimenttype)
  {
   case UNIFORM_DESIGN  :while (tmpvc)
                          {
                           tmpepsilon = tmpvc->epsilonestimates;
                           sumepsilon = 0.0;
                           while (tmpepsilon)
                            {
                             sumepsilon += tmpepsilon->epsilon;
                             tmpepsilon = tmpepsilon->next;
                            }
                           vcdimension = tmpvc->n / solve_vc_bound_equation(sumepsilon / tmpvc->count);
                           nextvc = tmpvc->next;
                           tmpvc->next = NULL;
                           for (i = 0; i < 6; i++)
                            {
                             difference = pow(10, -i);
                             before = mse_fitting_for_vc_dimension(tmpvc, vcdimension - difference, -1);
                             after = mse_fitting_for_vc_dimension(tmpvc, vcdimension + difference, -1);
                             if (before < after)
                               while (mse_fitting_for_vc_dimension(tmpvc, vcdimension - difference, -1) < mse_fitting_for_vc_dimension(tmpvc, vcdimension, -1))
                                 vcdimension -= difference;
                             else
                               while (mse_fitting_for_vc_dimension(tmpvc, vcdimension + difference, -1) < mse_fitting_for_vc_dimension(tmpvc, vcdimension, -1))
                                 vcdimension += difference;
                            }
                           tmpvc->next = nextvc;
                           sumvcdimension += vcdimension;
                           count++;
                           tmpvc = tmpvc->next;
                          }                         
                         vcdimension = sumvcdimension / count;
                         break;
   case OPTIMIZED_DESIGN:while (tmpvc)
                          {
                           if (tmpvc->n != n)
                            {
                             tmpepsilon = tmpvc->epsilonestimates;
                             while (tmpepsilon)
                              {
                               sumvcdimension += tmpvc->n / solve_vc_bound_equation(tmpepsilon->epsilon);
                               count++;
                               tmpepsilon = tmpepsilon->next;
                              }
                            }
                           tmpvc = tmpvc->next;
                          }
                         vcdimension = sumvcdimension / count;
                         for (i = 0; i < 6; i++)
                          {
                           difference = pow(10, -i);
                           before = mse_fitting_for_vc_dimension(estimates, vcdimension - difference, n);
                           after = mse_fitting_for_vc_dimension(estimates, vcdimension + difference, n);
                           if (before < after)
                             while (mse_fitting_for_vc_dimension(estimates, vcdimension - difference, n) < mse_fitting_for_vc_dimension(tmpvc, vcdimension, n))
                               vcdimension -= difference;
                           else
                             while (mse_fitting_for_vc_dimension(estimates, vcdimension + difference, n) < mse_fitting_for_vc_dimension(tmpvc, vcdimension, n))
                               vcdimension += difference;
                          }
                         break;
  }
 return vcdimension;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x64(%rbp)
testl %eax, %eax
je 0xc0d09
jmp 0xc0cf8
movl -0x64(%rbp), %eax
subl $0x1, %eax
je 0xc0f15
jmp 0xc10db
jmp 0xc0d0b
cmpq $0x0, -0x18(%rbp)
je 0xc0efd
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xc0d51
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xc0d2a
movq -0x18(%rbp), %rax
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x40(%rbp), %xmm0
movq -0x18(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0xc0930
movaps %xmm0, %xmm1
movsd -0x70(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
movl $0x0, -0x30(%rbp)
cmpl $0x6, -0x30(%rbp)
jge 0xc0ec8
xorl %eax, %eax
subl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x23b88(%rip), %xmm0    # 0xe4948
callq 0x4290
movsd %xmm0, -0x50(%rbp)
movq -0x18(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
subsd -0x50(%rbp), %xmm0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xc10f0
movsd %xmm0, -0x58(%rbp)
movq -0x18(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xc10f0
movsd %xmm0, -0x60(%rbp)
movsd -0x58(%rbp), %xmm1
movsd -0x60(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xc0e68
jmp 0xc0e16
movq -0x18(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
subsd -0x50(%rbp), %xmm0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xc10f0
movsd %xmm0, -0x78(%rbp)
movq -0x18(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xc10f0
movsd -0x78(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc0e66
movsd -0x50(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0xc0e16
jmp 0xc0eb8
jmp 0xc0e6a
movq -0x18(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xc10f0
movsd %xmm0, -0x80(%rbp)
movq -0x18(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xc10f0
movsd -0x80(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc0eb6
movsd -0x50(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0xc0e6a
jmp 0xc0eb8
jmp 0xc0eba
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xc0da5
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movsd -0x48(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xc0d0b
movsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x2c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0xc10db
jmp 0xc0f17
cmpq $0x0, -0x18(%rbp)
je 0xc0f9c
movq -0x18(%rbp), %rax
movl (%rax), %eax
cmpl -0x10(%rbp), %eax
je 0xc0f8b
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xc0f89
movq -0x18(%rbp), %rax
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
callq 0xc0930
movaps %xmm0, %xmm1
movsd -0x88(%rbp), %xmm0
divsd %xmm1, %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xc0f35
jmp 0xc0f8b
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xc0f17
movsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x2c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x6, -0x30(%rbp)
jge 0xc10d9
xorl %eax, %eax
subl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x23977(%rip), %xmm0    # 0xe4948
callq 0x4290
movsd %xmm0, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
subsd -0x50(%rbp), %xmm0
movl -0x10(%rbp), %esi
callq 0xc10f0
movsd %xmm0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movl -0x10(%rbp), %esi
callq 0xc10f0
movsd %xmm0, -0x60(%rbp)
movsd -0x58(%rbp), %xmm1
movsd -0x60(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xc1077
jmp 0xc1023
movq -0x8(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
subsd -0x50(%rbp), %xmm0
movl -0x10(%rbp), %esi
callq 0xc10f0
movsd %xmm0, -0x90(%rbp)
movq -0x18(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movl -0x10(%rbp), %esi
callq 0xc10f0
movsd -0x90(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc1075
movsd -0x50(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0xc1023
jmp 0xc10c9
jmp 0xc1079
movq -0x8(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movl -0x10(%rbp), %esi
callq 0xc10f0
movsd %xmm0, -0x98(%rbp)
movq -0x18(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movl -0x10(%rbp), %esi
callq 0xc10f0
movsd -0x98(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc10c7
movsd -0x50(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0xc1079
jmp 0xc10c9
jmp 0xc10cb
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xc0fb6
jmp 0xc10db
movsd -0x48(%rbp), %xmm0
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)