// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/omnivariaterule.c
// Function: find_best_hybrid_condition_crossvalidation
Decisionconditionptr find_best_hybrid_condition_crossvalidation(Instanceptr* growset, int positive, Ripper_parameterptr param)
{
 /*!Last Changed 30.01.2004 added denom == 0 condition*/
 /*!Last Changed 22.01.2004*/
 int hybridspace = get_parameter_i("hybridspace");
 Decisionconditionptr result, condition;
 char **files, st[READLINELENGTH] = "-", pst[READLINELENGTH], buffer[READLINELENGTH];
 Instanceptr train = NULL, test = NULL, traindata, testdata;
 int bestmodel = 0, error, trainsize, testsize, *models, dummy, dummy2, i, j, k, datasize, testtype;
 FILE* errorfiles[3];
 files = safemalloc(hybridspace * sizeof(char *), "find_best_hybrid_ldt_split_crossvalidation", 6); 
 strcpy(buffer, get_parameter_s("tempdirectory"));
 strcat(buffer, "/univariate.txt");
 files[0] = strcopy(files[0], buffer);
 strcpy(buffer, get_parameter_s("tempdirectory"));
 strcat(buffer, "/linear.txt");
 files[1] = strcopy(files[1], buffer);
 if (hybridspace == 3)
  {
   strcpy(buffer, get_parameter_s("tempdirectory"));
   strcat(buffer, "/quadratic.txt");
   files[2] = strcopy(files[2], buffer);
  }
 for (i = 0; i < hybridspace; i++)
  {
   errorfiles[i] = fopen(files[i], "w");
   if (!errorfiles[i])
     return NULL;
  }
 for (i = 0; i < 5; i++)
  {
   divide_instancelist(growset, &train, &test, 2);
   trainsize = data_size(train);
   testsize = data_size(test);
   if (trainsize <= 1 || testsize <= 1)
    {
     *growset = restore_instancelist(*growset, train);
     merge_instancelist(growset, test); 
     bestmodel = 1;
     break;
    }
   for (j = 0; j < 2; j++)
    {
     if (j == 0)
      {
       traindata = train;
       testdata = test;
       datasize = testsize;
      }
     else
      {
       traindata = test;
       testdata = train;
       datasize = trainsize;
      }
     for (k = 0; k < hybridspace; k++)
      {
       switch (k)
        {
         case MODEL_UNI:condition = find_best_condition_for_realized_features(traindata, positive);
                        break;
         case MODEL_LIN:condition = find_best_multivariate_condition(&traindata, positive, MULTIVARIATE_LINEAR, param);
                        break;
         case MODEL_QUA:condition = find_best_multivariate_condition(&traindata, positive, MULTIVARIATE_QUADRATIC, param);
                        break;
        }
       error = return_error_and_free_condition(condition, testdata, positive);
       set_precision(pst, NULL, "\n");
       fprintf(errorfiles[k], pst, error / (datasize + 0.0));
      }
    }
   *growset = restore_instancelist(*growset, testdata);
   merge_instancelist(growset, traindata); 
   train = NULL;
   test = NULL;
  }
 for (i = 0; i < hybridspace; i++)
   fclose(errorfiles[i]);
 if (bestmodel)
  {
   free_2d((void**)files, hybridspace);
   result = find_best_condition_for_realized_features(*growset, positive);
   if (result)
     result->datasize = trainsize + testsize;
   return result;
  }
 testtype = get_parameter_l("testtype");
 if (in_list(testtype, 9, FTEST, PAIREDT5X2, COMBINEDT5X2, PERMUTATIONTEST, PAIREDPERMUTATIONTEST, SIGNTEST, RANKSUMTEST, SIGNEDRANKTEST, NOTEST))
   models = multiple_comparison(files, hybridspace, testtype, st, &dummy, &dummy2, param->correctiontype);
 else
   models = multiple_comparison(files, hybridspace, FTEST, st, &dummy, &dummy2, param->correctiontype);
 switch (models[0])
  {
   case 1:result = find_best_condition_for_realized_features(*growset, positive);
          break;
   case 2:result = find_best_multivariate_condition(growset, positive, MULTIVARIATE_LINEAR, param);
          break;
   case 3:result = find_best_multivariate_condition(growset, positive, MULTIVARIATE_QUADRATIC, param);
          break;
  }
 safe_free(models);
 free_2d((void**)files, hybridspace);
 if (result)
  {
   result->conditiontype = HYBRID_CONDITION;
   result->datasize = trainsize + testsize;
  }
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x16e3f8, %rsp         # imm = 0x16E3F8
movq %rdx, 0x20(%rsp)
movl %esi, %ebp
movq %rdi, %r15
leaq 0x56ac3(%rip), %rdi     # 0xa8c98
callq 0x54920
movl %eax, %r12d
leaq 0x7a1b0(%rsp), %rbx
xorl %r14d, %r14d
movl $0x7a120, %edx          # imm = 0x7A120
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4050
movb $0x2d, (%rbx)
movq %r14, 0x18(%rsp)
movq %r14, 0x10(%rsp)
movslq %r12d, %rdi
shlq $0x3, %rdi
leaq 0x58728(%rip), %rsi     # 0xaa93a
movl $0x6, %edx
callq 0x3a0e1
movq %rax, %r13
leaq 0x58236(%rip), %r14     # 0xaa45c
movq %r14, %rdi
callq 0x54a6f
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4270
movq %rbx, %rdi
callq 0x4190
movupd 0x58714(%rip), %xmm0    # 0xaa965
movupd %xmm0, 0x90(%rsp,%rax)
movq (%r13), %rdi
movq %rbx, %rsi
callq 0x3b494
movq %rax, (%r13)
movq %r14, %rdi
callq 0x54a6f
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4270
movq %rbx, %rdi
callq 0x4190
movabsq $0x2e7261656e696c2f, %rcx # imm = 0x2E7261656E696C2F
movq %rcx, 0x90(%rsp,%rax)
movl $0x747874, 0x98(%rsp,%rax) # imm = 0x747874
movq 0x8(%r13), %rdi
movq %rbx, %rsi
callq 0x3b494
movq %rax, 0x8(%r13)
movl %r12d, %eax
cmpl $0x3, %r12d
movl %r12d, 0x4(%rsp)
movq %rax, 0x28(%rsp)
jne 0x52322
leaq 0x58190(%rip), %rdi     # 0xaa45c
callq 0x54a6f
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4270
movq %rbx, %rdi
callq 0x4190
movabsq $0x746172646175712f, %rcx # imm = 0x746172646175712F
movq %rcx, 0x90(%rsp,%rax)
movabsq $0x7478742e636974, %rcx # imm = 0x7478742E636974
movq %rcx, 0x97(%rsp,%rax)
movq 0x10(%r13), %rdi
movq %rbx, %rsi
callq 0x3b494
movq %rax, 0x10(%r13)
jmp 0x52327
testl %r12d, %r12d
jle 0x5236b
movq %r15, %r12
xorl %ebx, %ebx
leaq 0x5963a(%rip), %r14     # 0xab96d
xorl %r15d, %r15d
movq (%r13,%r15,8), %rdi
movq %r14, %rsi
callq 0x40f0
movq %rax, 0x70(%rsp,%r15,8)
testq %rax, %rax
je 0x526e5
incq %r15
cmpq %r15, 0x28(%rsp)
jne 0x52336
movb $0x1, %al
movl %eax, 0xc(%rsp)
movq %r12, %r15
movl 0x4(%rsp), %r12d
jmp 0x52373
movl $0x0, 0xc(%rsp)
leaq 0x18(%rsp), %rbx
leaq 0x10(%rsp), %r14
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x2, %ecx
callq 0x31019
movq (%rbx), %rdi
callq 0x30309
movl %eax, %ebx
movq (%r14), %rdi
callq 0x30309
movl %ebx, 0x8(%rsp)
cmpl $0x2, %ebx
setl %dl
movl %eax, (%rsp)
cmpl $0x2, %eax
setl %cl
movq $0x0, 0x30(%rsp)
orb %dl, %cl
jne 0x52576
movq %r13, 0x48(%rsp)
leaq 0xf42d0(%rsp), %r13
xorl %r14d, %r14d
movl (%rsp), %eax
movq %r15, 0x58(%rsp)
movl %eax, (%rsp)
movl %r14d, %eax
movq %rax, 0x50(%rsp)
movb $0x1, %cl
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %r14
testb $0x1, %cl
movq %r14, %rax
cmovneq %rdx, %rax
movq %rax, 0x38(%rsp)
movq %rdx, 0x60(%rsp)
cmoveq %rdx, %r14
cmpb $0x0, 0xc(%rsp)
movl %ecx, 0x44(%rsp)
je 0x524c9
testb $0x1, %cl
movl 0x8(%rsp), %eax
cmovnel (%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %r15d, %r15d
cmpl $0x2, %r15d
je 0x52464
cmpl $0x1, %r15d
je 0x52456
testl %r15d, %r15d
jne 0x5247d
movq 0x38(%rsp), %rdi
movl %ebp, %esi
callq 0x9ea42
jmp 0x5247a
leaq 0x38(%rsp), %rdi
movl %ebp, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
jmp 0x52470
leaq 0x38(%rsp), %rdi
movl %ebp, %esi
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
movq 0x20(%rsp), %rcx
callq 0x4ca77
movq %rax, %rbx
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x7c709
movl %eax, %r12d
movq %r13, %rdi
xorl %esi, %esi
leaq 0x56d02(%rip), %rdx     # 0xa919b
callq 0x3a535
movq 0x70(%rsp,%r15,8), %rdi
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
divsd 0x30(%rsp), %xmm0
movq %r13, %rsi
movb $0x1, %al
callq 0x42e0
incq %r15
cmpq %r15, 0x28(%rsp)
jne 0x52437
testb $0x1, 0x44(%rsp)
movl $0x0, %ecx
jne 0x523eb
movq 0x58(%rsp), %r15
movq (%r15), %rdi
movq 0x60(%rsp), %rsi
callq 0x31345
movq %rax, (%r15)
movq 0x38(%rsp), %rsi
movq %r15, %rdi
callq 0x30648
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq 0x50(%rsp), %rax
leal 0x1(%rax), %r14d
cmpl $0x5, %r14d
je 0x5259a
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movl $0x2, %ecx
callq 0x31019
movq 0x18(%rsp), %rdi
callq 0x30309
movl %eax, %r12d
movq 0x10(%rsp), %rdi
callq 0x30309
movl %r12d, 0x8(%rsp)
cmpl $0x2, %r12d
jl 0x5255c
cmpl $0x2, %eax
jge 0x523de
movl %eax, (%rsp)
cmpl $0x4, 0x50(%rsp)
setae %al
movq %rax, 0x30(%rsp)
movl 0x4(%rsp), %r12d
movq 0x48(%rsp), %r13
movq 0x28(%rsp), %r14
movq (%r15), %rdi
movq 0x18(%rsp), %rsi
callq 0x31345
movq %rax, (%r15)
movq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x30648
jmp 0x525b0
movb $0x1, %al
movq %rax, 0x30(%rsp)
movl 0x4(%rsp), %r12d
movq 0x48(%rsp), %r13
movq 0x28(%rsp), %r14
cmpb $0x0, 0xc(%rsp)
je 0x525cb
xorl %ebx, %ebx
movq 0x70(%rsp,%rbx,8), %rdi
callq 0x42a0
incq %rbx
cmpq %rbx, %r14
jne 0x525b9
cmpb $0x0, 0x30(%rsp)
je 0x52676
leaq 0x57ec4(%rip), %rdi     # 0xaa4a1
callq 0x54afc
movl %eax, %ebx
subq $0x8, %rsp
movl $0x3, %r14d
movl %eax, %edi
movl $0x9, %esi
movl $0x3, %edx
movl $0xa, %ecx
movl $0xc, %r8d
movl $0xf, %r9d
xorl %eax, %eax
pushq $0x13
pushq $0x7
pushq $0x6
pushq $0xe
pushq $0x10
callq 0x3aa8c
addq $0x30, %rsp
testl %eax, %eax
movq 0x20(%rsp), %rax
movl 0x3c(%rax), %eax
cmovel %r14d, %ebx
subq $0x8, %rsp
leaq 0x7a1b8(%rsp), %rcx
leaq 0x74(%rsp), %r8
leaq 0x70(%rsp), %r9
movq %r13, %rdi
movl %r12d, %esi
movl %ebx, %edx
pushq %rax
callq 0x8ec4a
addq $0x10, %rsp
movq %rax, %r14
movl (%rax), %eax
cmpl $0x3, %eax
je 0x526a1
cmpl $0x2, %eax
je 0x52695
cmpl $0x1, %eax
jne 0x526b8
movq (%r15), %rdi
movl %ebp, %esi
callq 0x9ea42
jmp 0x526b5
movq %r13, %rdi
movl %r12d, %esi
callq 0x3a14b
movq (%r15), %rdi
movl %ebp, %esi
callq 0x9ea42
movq %rax, %rbx
testq %rax, %rax
jne 0x526d7
jmp 0x526e3
movq %r15, %rdi
movl %ebp, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
jmp 0x526ab
movq %r15, %rdi
movl %ebp, %esi
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
movq 0x20(%rsp), %rcx
callq 0x4ca77
movq %rax, %rbx
movq %r14, %rdi
callq 0x3a180
movq %r13, %rdi
movl %r12d, %esi
callq 0x3a14b
testq %rbx, %rbx
je 0x526e3
movl $0x2, 0x40(%rbx)
movl (%rsp), %eax
addl 0x8(%rsp), %eax
movl %eax, 0x38(%rbx)
jmp 0x526e5
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x16e3f8, %rsp         # imm = 0x16E3F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq