// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/srm.c
// Function: vc_dimension_of_ruleset
int vc_dimension_of_ruleset(int featurecount, char* values, int randomgenerate, int randomcount)
{
 /*Last Changed 24.02.2008*/
 int i, vcdimension = 1, bound = (int) pow(2, featurecount), conditioncount = 0, notfinished, classcounts[2];
 BOOLEAN successful, classifiedsinglecombination, classifiedallcombinations;
 int *datacombination, *classiterator, *ruleset, *indexlist, *list, *featurelist, valuecount, count = 0;
 valuecount = strlen(values);
 ruleset = safemalloc(valuecount * sizeof(int), "vc_dimension_of_ruleset", 3);
 for (i = 0; i < valuecount; i++)
  {
   ruleset[i] = values[i] - '0';
   conditioncount += ruleset[i];
  }
 list = safemalloc(2 * featurecount * sizeof(int), "vc_dimension_of_ruleset", 9);
 for (i = 0; i < featurecount; i++)
  {
   list[2 * i] = 10 * i;
   list[2 * i + 1] = 10 * i + 1;
  } 
 while (vcdimension <= bound)
  {
   datacombination = first_combination(vcdimension);
   count = 0;
   successful = BOOLEAN_FALSE;
   while (BOOLEAN_TRUE)
    {
     classifiedallcombinations = BOOLEAN_TRUE;
     classiterator = first_iterator(vcdimension);
     do{
        classcounts[0] = classcounts[1] = 0;
        for (i = 0; i < vcdimension; i++)
          classcounts[classiterator[i]]++;
        if (classcounts[0] * classcounts[1] == 0)
          continue;
        featurelist = first_iterator_from_list(conditioncount, list, &indexlist);
        classifiedsinglecombination = BOOLEAN_FALSE;
        notfinished = BOOLEAN_TRUE;
        while (!classifiedsinglecombination && notfinished)
         {
          if (can_ruleset_classify(featurelist, ruleset, valuecount, datacombination, classiterator, vcdimension, 0) ||
              can_ruleset_classify(featurelist, ruleset, valuecount, datacombination, classiterator, vcdimension, 1))
           {
            classifiedsinglecombination = BOOLEAN_TRUE;
            break;
           }
          notfinished = next_iterator_from_list(featurelist, list, indexlist, conditioncount, 2 * featurecount - 1);
         }
        safe_free(indexlist);
        safe_free(featurelist);
        if (!classifiedsinglecombination)
         {
          classifiedallcombinations = BOOLEAN_FALSE;
          break;
         }
     }while(next_iterator(classiterator, vcdimension, 1));
     safe_free(classiterator);
     if (classifiedallcombinations)
      {
       successful = BOOLEAN_TRUE;
       break;
      }
     count++;
     if (randomgenerate)
       if (count < randomcount)
         random_combination(datacombination, vcdimension, bound - 1);
       else
         break;
     else
       if (!next_combination(datacombination, vcdimension, bound - 1))
         break;
   }
   safe_free(datacombination);
   if (successful)
     vcdimension++;
   else
     break;
  }
 safe_free(list);
 safe_free(ruleset);
 return vcdimension - 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl $0x1, -0x20(%rbp)
cvtsi2sdl -0x4(%rbp), %xmm1
movsd 0x20c44(%rip), %xmm0    # 0xe2ca0
callq 0x4290
cvttsd2si %xmm0, %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4150
movl %eax, -0x74(%rbp)
movslq -0x74(%rbp), %rdi
shlq $0x2, %rdi
leaq 0x2baa4(%rip), %rsi     # 0xedb35
movl $0x3, %edx
callq 0x52d70
movq %rax, -0x58(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0xc20e4
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %edx
subl $0x30, %edx
movq -0x58(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x58(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc20a6
movl -0x4(%rbp), %eax
shll %eax
movslq %eax, %rdi
shlq $0x2, %rdi
leaq 0x2ba3e(%rip), %rsi     # 0xedb35
movl $0x9, %edx
callq 0x52d70
movq %rax, -0x68(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0xc214b
imull $0xa, -0x1c(%rbp), %edx
movq -0x68(%rbp), %rax
movl -0x1c(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
imull $0xa, -0x1c(%rbp), %edx
addl $0x1, %edx
movq -0x68(%rbp), %rax
movl -0x1c(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc210c
jmp 0xc214d
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0xc2360
movl -0x20(%rbp), %edi
callq 0x51a10
movq %rax, -0x48(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x1, -0x40(%rbp)
movl -0x20(%rbp), %edi
callq 0x51b20
movq %rax, -0x50(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0xc21c5
movq -0x50(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movl -0x34(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x34(%rbp,%rax,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc219b
movl -0x34(%rbp), %eax
imull -0x30(%rbp), %eax
cmpl $0x0, %eax
jne 0xc21d6
jmp 0xc22be
movl -0x28(%rbp), %edi
movq -0x68(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x51be0
movq %rax, -0x70(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x1, -0x2c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x3c(%rbp)
movb %al, -0x79(%rbp)
jne 0xc220d
cmpl $0x0, -0x2c(%rbp)
setne %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0xc2219
jmp 0xc229b
movq -0x70(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl -0x74(%rbp), %edx
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movl -0x20(%rbp), %r9d
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0xc1da0
cmpl $0x0, %eax
jne 0xc226b
movq -0x70(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl -0x74(%rbp), %edx
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movl -0x20(%rbp), %r9d
movl $0x1, (%rsp)
callq 0xc1da0
cmpl $0x0, %eax
je 0xc2274
movl $0x1, -0x3c(%rbp)
jmp 0xc229b
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movl -0x28(%rbp), %ecx
movl -0x4(%rbp), %r8d
shll %r8d
subl $0x1, %r8d
callq 0x52420
movl %eax, -0x2c(%rbp)
jmp 0xc21f8
movq -0x60(%rbp), %rdi
callq 0x52e80
movq -0x70(%rbp), %rdi
callq 0x52e80
cmpl $0x0, -0x3c(%rbp)
jne 0xc22bc
movl $0x0, -0x40(%rbp)
jmp 0xc22d8
jmp 0xc22be
movq -0x50(%rbp), %rdi
movl -0x20(%rbp), %esi
movl $0x1, %edx
callq 0x52330
cmpl $0x0, %eax
jne 0xc2186
movq -0x50(%rbp), %rdi
callq 0x52e80
cmpl $0x0, -0x40(%rbp)
je 0xc22f0
movl $0x1, -0x38(%rbp)
jmp 0xc233f
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xc231f
movl -0x78(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xc231b
movq -0x48(%rbp), %rdi
movl -0x20(%rbp), %esi
movl -0x24(%rbp), %edx
subl $0x1, %edx
callq 0x54740
jmp 0xc231d
jmp 0xc233f
jmp 0xc233a
movq -0x48(%rbp), %rdi
movl -0x20(%rbp), %esi
movl -0x24(%rbp), %edx
subl $0x1, %edx
callq 0x52190
cmpl $0x0, %eax
jne 0xc2338
jmp 0xc233f
jmp 0xc233a
jmp 0xc2173
movq -0x48(%rbp), %rdi
callq 0x52e80
cmpl $0x0, -0x38(%rbp)
je 0xc2359
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xc235b
jmp 0xc2360
jmp 0xc214d
movq -0x68(%rbp), %rdi
callq 0x52e80
movq -0x58(%rbp), %rdi
callq 0x52e80
movl -0x20(%rbp), %eax
subl $0x1, %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)