// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/process.c
// Function: run_supervised_algorithm
void run_supervised_algorithm(int meta_algorithm, int algorithm)
{
 /*!Last Changed 12.12.2005*/
 /*!Last Changed 31.10.2005*/
 /*!Last Changed 11.04.2005*/
 /*!Last Changed 10.04.2004 allow also regression algorithms to run*/
 /*!Last Changed 29.01.2004* if dataset is not active you can not run any algorithm on it*/
 int i, runstart, k, **partition, *classes, *classcounts;
 RUN_TYPE runtype;
 void* parameters;
 char* testfname;
 FILE* posfile = NULL;
 FILE* modelfile = NULL;
 FILE* testcodefile = NULL;
 FILE* confusionfile = NULL;
 if (!checkparams(paramcount, 3, m1006, m1048, m1049))
   return;
 totalrun = 0;
 current_dataset = search_dataset(Datasets, params[0]);
 if (!current_dataset)
  {
   printf(m1320);
   return;
  }
 mustrealize = must_realize(algorithm);
 if (current_dataset->storetype != STORE_KERNEL)
   mustnormalize = must_normalize(algorithm);
 else
  {
   read_kernel_of_dataset(current_dataset);
   mustnormalize = NO;
  }
 if (!check_supervised_algorithm_type(algorithm, current_dataset))  
   return;
 if (current_dataset->active == NO)
   return;
 if (strIcmp(params[1], "cv") == 0)
   if (get_parameter_f("testpercentage") > 0)
     runtype = CROSSVALIDATION_WITH_SEPARATE_TEST_SET;
   else
     runtype = CROSSVALIDATION;
 else
   if (strIcmp(params[1], "bootstrap") == 0)
     if (get_parameter_f("testpercentage") > 0)
       runtype = BOOTSTRAP;
     else
      {
       printf(m1414);
       return;
      }
   else
     if (paramcount == 4)
       runtype = TRAIN_TEST_SETS_GIVEN;
     else
       if (paramcount == 5)
         runtype = TRAIN_TEST_CV_SETS_GIVEN;
       else
        {
         printf(m1186);
         return;
        }
 parameters = prepare_supervised_algorithm_parameters(algorithm);
 if (get_parameter_o("printposterior"))
  {
   posfile = fopen(get_parameter_s("posteriorfilename"), "w");
   if (!posfile)
     return;
  }
 if (get_parameter_o("printconfusion"))
  {
   confusionfile = fopen(get_parameter_s("confusionfilename"), "w");
   if (!confusionfile)
     return;
  }
 if (get_parameter_o("savetestcode"))
  {
   testfname = test_code_file_name_with_extension(get_parameter_s("testcodefilename"), get_parameter_l("language"));
   testcodefile = fopen(testfname, "w");
   if (!testcodefile)
     return;
   safe_free(testfname);
  }
 if (get_parameter_o("savemodel"))
  {
   modelfile = fopen(get_parameter_s("modelfilename"), "w");
   if (!modelfile)
     return;
   switch (runtype){
     case                        CROSSVALIDATION:
     case CROSSVALIDATION_WITH_SEPARATE_TEST_SET:fprintf(modelfile, "%s %s %d\n", current_dataset->name, get_algorithm_name(algorithm), get_parameter_i("runcount") * get_parameter_i("runtofold"));
                                                 break;
     case                              BOOTSTRAP:fprintf(modelfile, "%s %s %d\n", current_dataset->name, get_algorithm_name(algorithm), get_parameter_i("runcount"));
                                                 break;
     case                  TRAIN_TEST_SETS_GIVEN:
     case               TRAIN_TEST_CV_SETS_GIVEN:fprintf(modelfile, "%s %s 1\n", current_dataset->name, get_algorithm_name(algorithm));
                                                 break;
   }
  }
 if (runtype == CROSSVALIDATION || runtype == CROSSVALIDATION_WITH_SEPARATE_TEST_SET)
  {
   runstart = atoi(params[2]);
   get_prior_information();
   mysrand(runstart);
   partition = safemalloc(get_parameter_i("runcount") * sizeof(int *), "run_supervised_algorithm", 34);
   classes = read_train_and_test_lines(&classcounts);
   for (i = 0; i < get_parameter_i("runcount"); i++)
     partition[i] = stratified_partition(classes, trainlinecount, current_dataset->classno, classcounts);
   for (i = 0; i < get_parameter_i("runcount"); i++)
     for (k = get_parameter_i("runfromfold"); k < get_parameter_i("runtofold"); k++)
      {
       #ifdef MPI
       if (get_parameter_o("parallel") && get_parameter_i("paralleltype") == 2 && get_parameter_i("proccount") > 1 && rank > 0)   
         get_fold_mpiclient(k, partition[i]);
       else
         get_fold(k, partition[i]);
       #else
       if (get_parameter_i("foldcount") != 1)
         get_fold(k, partition[i]);
       else
        {
         read_from_train_file(current_dataset, &traindata);
         read_from_train_file(current_dataset, &testdata);
        }
       #endif
       if (runtype == CROSSVALIDATION_WITH_SEPARATE_TEST_SET)
        {
         read_data_from_lines(testlines, testlinecount, &separateddata);
         handle_missing_values(traindata, separateddata);
        }
       single_run_supervised_algorithm(parameters, meta_algorithm, algorithm, runtype, posfile, modelfile, testcodefile, confusionfile);
       separateddata = NULL;
      }
   free_2d((void**)partition, get_parameter_i("runcount"));
   free_train_and_test_lines();
   if (current_dataset->classno > 0)
    {
     safe_free(classes);
     safe_free(classcounts);
    }
  }
 else
   if (runtype == BOOTSTRAP)
    {
     runstart = atoi(params[2]);
     get_prior_information();
     mysrand(runstart);
     classes = read_train_and_test_lines(&classcounts);
     for (i = 0; i < get_parameter_i("runcount"); i++)
      {
       bootstrap_sample_with_stratification(classes, classcounts);
       read_data_from_lines(testlines, testlinecount, &testdata);
       handle_missing_values(traindata, testdata);
       single_run_supervised_algorithm(parameters, meta_algorithm, algorithm, runtype, posfile, modelfile, testcodefile, confusionfile);
      }
     free_train_and_test_lines();
     if (current_dataset->classno > 0)
      {
       safe_free(classes);
       safe_free(classcounts);
      }
    }
   else
     if (runtype == TRAIN_TEST_SETS_GIVEN)
      {
       if (prepare_from_files(current_dataset, params[1], params[2], NULL))
        {
         mysrand(atoi(params[3]));
         single_run_supervised_algorithm(parameters, meta_algorithm, algorithm, runtype, posfile, modelfile, testcodefile, confusionfile);
        }
      }
     else
      {
       if (prepare_from_files(current_dataset, params[1], params[2], params[3]))
        {
         mysrand(atoi(params[4]));
         single_run_supervised_algorithm(parameters, meta_algorithm, algorithm, runtype, posfile, modelfile, testcodefile, confusionfile);
        }
      }
 free_supervised_algorithm_parameters(algorithm, parameters);
 if (get_parameter_o("printposterior"))
   fclose(posfile);
 if (get_parameter_o("savemodel"))
   fclose(modelfile);
 if (get_parameter_o("savetestcode"))
   fclose(testcodefile);
 if (get_parameter_o("printconfusion"))
   fclose(confusionfile);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, %r15d
movl %edi, 0x14(%rsp)
movl 0x3500e2(%rip), %edi    # 0x3a9fa0
leaq 0x41c33(%rip), %rdx     # 0x9baf8
leaq 0x41c9c(%rip), %rcx     # 0x9bb68
leaq 0x41cbf(%rip), %r8      # 0x9bb92
pushq $0x3
popq %rbp
movl %ebp, %esi
xorl %eax, %eax
callq 0x358ba
testl %eax, %eax
je 0x5a66d
andl $0x0, 0x350132(%rip)    # 0x3aa020
movq 0x73983(%rip), %rdi     # 0xcd878
movq 0x73634(%rip), %rsi     # 0xcd530
callq 0x13da6
movq %rax, 0x73968(%rip)     # 0xcd870
testq %rax, %rax
je 0x59f34
movl %r15d, %edi
callq 0x448a
movl %eax, 0x350089(%rip)    # 0x3a9fa4
movq 0x7394e(%rip), %rdi     # 0xcd870
cmpl $0x3, 0x140713c(%rdi)
jne 0x59f4e
callq 0x157bb
xorl %eax, %eax
jmp 0x59f56
leaq 0x4477b(%rip), %rdi     # 0x9e6b6
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4090
movl %r15d, %edi
callq 0x44cb
movl %eax, 0x2d5f14(%rip)    # 0x32fe70
movq 0x7390d(%rip), %rsi     # 0xcd870
movl %r15d, %edi
callq 0x458f
testl %eax, %eax
je 0x5a66d
movq 0x738f6(%rip), %rax     # 0xcd870
cmpl $0x0, (%rax)
je 0x5a66d
movq 0x735ae(%rip), %rdi     # 0xcd538
leaq 0x47dbd(%rip), %rsi     # 0xa1d4e
callq 0x35f65
testl %eax, %eax
je 0x59fd8
movq 0x73597(%rip), %rdi     # 0xcd538
leaq 0x41c0e(%rip), %rsi     # 0x9bbb6
callq 0x35f65
testl %eax, %eax
je 0x5a003
movl 0x34ffe9(%rip), %eax    # 0x3a9fa0
cmpl $0x4, %eax
je 0x5a033
cmpl $0x5, %eax
jne 0x5a1ba
pushq $0x4
popq %rbp
xorl %r12d, %r12d
movl $0x0, 0x4(%rsp)
xorl %r13d, %r13d
jmp 0x5a02e
leaq 0x41a94(%rip), %rdi     # 0x9ba73
callq 0x4cdcf
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm0
setbe %r12b
seta %al
xorl %r13d, %r13d
xorl %r14d, %r14d
movl %eax, 0x4(%rsp)
movl %eax, %ebp
jmp 0x5a044
leaq 0x41a69(%rip), %rdi     # 0x9ba73
callq 0x4cdcf
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x5a1d4
pushq $0x2
popq %rbp
movb $0x1, %r13b
xorl %r12d, %r12d
movl $0x0, 0x4(%rsp)
xorl %r14d, %r14d
jmp 0x5a044
movb $0x1, %r14b
xorl %r12d, %r12d
movl $0x0, 0x4(%rsp)
xorl %r13d, %r13d
movl %r15d, %edi
callq 0x5a9c
movq %rax, 0x38(%rsp)
leaq 0x41934(%rip), %rdi     # 0x9b98c
callq 0x4cff1
testl %eax, %eax
je 0x5a08b
leaq 0x41a34(%rip), %rdi     # 0x9ba9c
callq 0x4ce84
leaq 0x4181d(%rip), %rsi     # 0x9b891
movq %rax, %rdi
callq 0x40f0
movq %rax, 0x30(%rsp)
testq %rax, %rax
jne 0x5a094
jmp 0x5a66d
movq $0x0, 0x30(%rsp)
leaq 0x4191e(%rip), %rdi     # 0x9b9b9
callq 0x4cff1
testl %eax, %eax
je 0x5a0ce
leaq 0x41b29(%rip), %rdi     # 0x9bbd4
callq 0x4ce84
leaq 0x417da(%rip), %rsi     # 0x9b891
movq %rax, %rdi
callq 0x40f0
movq %rax, 0x28(%rsp)
testq %rax, %rax
jne 0x5a0d7
jmp 0x5a66d
movq $0x0, 0x28(%rsp)
leaq 0x4191d(%rip), %rdi     # 0x9b9fb
callq 0x4cff1
testl %eax, %eax
je 0x5a136
leaq 0x41af8(%rip), %rdi     # 0x9bbe6
callq 0x4ce84
movq %rax, %rbx
leaq 0x4190b(%rip), %rdi     # 0x9ba08
callq 0x4cf11
movq %rbx, %rdi
movl %eax, %esi
callq 0x72626
movq %rax, %rbx
leaq 0x4177b(%rip), %rsi     # 0x9b891
movq %rax, %rdi
callq 0x40f0
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x5a66d
movq %rbx, %rdi
callq 0x34ff7
jmp 0x5a13f
movq $0x0, 0x20(%rsp)
leaq 0x418ab(%rip), %rdi     # 0x9b9f1
callq 0x4cff1
testl %eax, %eax
je 0x5a1c6
leaq 0x41aa1(%rip), %rdi     # 0x9bbf7
callq 0x4ce84
leaq 0x4172f(%rip), %rsi     # 0x9b891
movq %rax, %rdi
callq 0x40f0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x5a66d
cmpl $0x2, %ebp
jb 0x5a1e0
leal -0x3(%rbp), %eax
cmpl $0x2, %eax
jae 0x5a243
movq 0x736e0(%rip), %rax     # 0xcd870
movq 0x8(%rax), %rbx
movl %r15d, %edi
callq 0x454d
leaq 0x41a6c(%rip), %rsi     # 0x9bc0f
movq 0x8(%rsp), %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x42e0
jmp 0x5a294
leaq 0x4451d(%rip), %rdi     # 0x9e6de
jmp 0x59f3b
movq $0x0, 0x8(%rsp)
jmp 0x5a294
leaq 0x44516(%rip), %rdi     # 0x9e6f1
jmp 0x59f3b
movq 0x73689(%rip), %rax     # 0xcd870
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movl %r15d, %edi
callq 0x454d
movq %rax, 0x40(%rsp)
leaq 0x40a29(%rip), %rdi     # 0x9ac2d
callq 0x4cd35
movq %rbp, %rbx
movl %r15d, %ebp
movl %eax, %r15d
leaq 0x418a0(%rip), %rdi     # 0x9bab9
callq 0x4cd35
imull %eax, %r15d
leaq 0x419dc(%rip), %rsi     # 0x9bc05
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq 0x40(%rsp), %rcx
movl %r15d, %r8d
movl %ebp, %r15d
movq %rbx, %rbp
jmp 0x5a28d
movq 0x73626(%rip), %rax     # 0xcd870
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movl %r15d, %edi
callq 0x454d
movq %rbp, %rbx
movl %r15d, %ebp
movq %rax, %r15
leaq 0x409c2(%rip), %rdi     # 0x9ac2d
callq 0x4cd35
leaq 0x4198e(%rip), %rsi     # 0x9bc05
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
movl %ebp, %r15d
movq %rbx, %rbp
movl %eax, %r8d
xorl %eax, %eax
callq 0x42e0
orb 0x4(%rsp), %r12b
cmpb $0x1, %r12b
jne 0x5a341
movq 0x73296(%rip), %rdi     # 0xcd540
callq 0x4200
movl %eax, %ebx
callq 0x55d99
movl %ebx, %edi
callq 0x35ca7
leaq 0x40969(%rip), %rbx     # 0x9ac2d
movq %rbx, %rdi
callq 0x4cd35
movslq %eax, %rdi
shlq $0x3, %rdi
leaq 0x4193e(%rip), %rsi     # 0x9bc18
pushq $0x22
popq %rdx
callq 0x34f59
movq %rax, 0x18(%rsp)
leaq 0x50(%rsp), %r13
movq %r13, %rdi
callq 0x567cb
movq %rax, %r14
xorl %r12d, %r12d
movq (%r13), %rax
movq %rax, 0x40(%rsp)
movq %rbx, %rdi
callq 0x4cd35
cltq
cmpq %rax, %r12
jge 0x5a3f8
movl 0x731f4(%rip), %esi     # 0xcd510
movq 0x7354d(%rip), %rax     # 0xcd870
movl 0x10(%rax), %edx
movq %r14, %rdi
movq 0x40(%rsp), %rcx
callq 0x2ba93
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
jmp 0x5a303
testb %r13b, %r13b
je 0x5a53b
movq 0x731ef(%rip), %rdi     # 0xcd540
callq 0x4200
movl %eax, %ebx
callq 0x55d99
movl %ebx, %edi
callq 0x35ca7
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x567cb
movq %rax, %r14
xorl %r13d, %r13d
movq (%rbx), %rbx
leaq 0x408ac(%rip), %r12     # 0x9ac2d
pushq $0x2
popq %rbp
movq %r12, %rdi
callq 0x4cd35
cmpl %eax, %r13d
jge 0x5a57b
movq %r14, %rdi
movq %rbx, %rsi
callq 0x55f01
movq 0x734b1(%rip), %rdi     # 0xcd858
movl 0x7315f(%rip), %esi     # 0xcd50c
leaq 0x2d5a84(%rip), %rdx    # 0x32fe38
callq 0x56a16
movq 0x2d5a70(%rip), %rdi    # 0x32fe30
movq 0x2d5a71(%rip), %rsi    # 0x32fe38
callq 0x54edc
movq 0x38(%rsp), %rdi
movl 0x14(%rsp), %esi
movl %r15d, %edx
movl %ebp, %ecx
movq 0x30(%rsp), %r8
movq 0x8(%rsp), %r9
pushq 0x28(%rsp)
pushq 0x28(%rsp)
callq 0x58a7e
popq %rax
popq %rcx
incl %r13d
jmp 0x5a384
movq %r14, 0x48(%rsp)
xorl %ebx, %ebx
leaq 0x416b3(%rip), %r14     # 0x9bab9
leaq 0x446ff(%rip), %r12     # 0x9eb0c
leaq 0x40819(%rip), %rdi     # 0x9ac2d
callq 0x4cd35
cltq
cmpq %rax, %rbx
jge 0x5a4fc
leaq 0x41806(%rip), %rdi     # 0x9bc31
callq 0x4cd35
movl %eax, %r13d
movq %r14, %rdi
callq 0x4cd35
cmpl %eax, %r13d
jge 0x5a4f4
movq %r12, %rdi
callq 0x4cd35
cmpl $0x1, %eax
jne 0x5a479
movq 0x73418(%rip), %rdi     # 0xcd870
leaq 0x2d59d1(%rip), %rsi    # 0x32fe30
callq 0x5577a
movq 0x73405(%rip), %rdi     # 0xcd870
leaq 0x2d59c6(%rip), %rsi    # 0x32fe38
callq 0x5577a
jmp 0x5a48a
movq 0x18(%rsp), %rax
movq (%rax,%rbx,8), %rsi
movl %r13d, %edi
callq 0x56001
cmpb $0x0, 0x4(%rsp)
je 0x5a4bd
movq 0x733c0(%rip), %rdi     # 0xcd858
movl 0x7306e(%rip), %esi     # 0xcd50c
leaq 0x2d59a3(%rip), %rdx    # 0x32fe48
callq 0x56a16
movq 0x2d597f(%rip), %rdi    # 0x32fe30
movq 0x2d5990(%rip), %rsi    # 0x32fe48
callq 0x54edc
movq 0x38(%rsp), %rdi
movl 0x14(%rsp), %esi
movl %r15d, %edx
movl %ebp, %ecx
movq 0x30(%rsp), %r8
movq 0x8(%rsp), %r9
pushq 0x28(%rsp)
pushq 0x28(%rsp)
callq 0x58a7e
popq %rax
popq %rcx
andq $0x0, 0x2d595c(%rip)    # 0x32fe48
incl %r13d
jmp 0x5a433
incq %rbx
jmp 0x5a40d
leaq 0x4072a(%rip), %rdi     # 0x9ac2d
callq 0x4cd35
movq 0x18(%rsp), %rdi
movl %eax, %esi
callq 0x34fc3
callq 0x59120
movq 0x73350(%rip), %rax     # 0xcd870
cmpl $0x0, 0x10(%rax)
jle 0x5a5ea
movq 0x48(%rsp), %rdi
callq 0x34ff7
movq 0x40(%rsp), %rdi
jmp 0x5a598
movq 0x7332e(%rip), %rdi     # 0xcd870
movq 0x72fef(%rip), %rsi     # 0xcd538
movq 0x72ff0(%rip), %rdx     # 0xcd540
testb %r14b, %r14b
je 0x5a59f
xorl %ecx, %ecx
callq 0x55c2a
testl %eax, %eax
je 0x5a5ea
movq 0x72fdd(%rip), %rdi     # 0xcd548
callq 0x4200
movl %eax, %edi
callq 0x35ca7
pushq $0x3
jmp 0x5a5c4
callq 0x59120
movq 0x732e9(%rip), %rax     # 0xcd870
cmpl $0x0, 0x10(%rax)
jle 0x5a5ea
movq %r14, %rdi
callq 0x34ff7
movq %rbx, %rdi
callq 0x34ff7
jmp 0x5a5ea
movq 0x72fa2(%rip), %rcx     # 0xcd548
callq 0x55c2a
testl %eax, %eax
je 0x5a5ea
movq 0x72f9a(%rip), %rdi     # 0xcd550
callq 0x4200
movl %eax, %edi
callq 0x35ca7
pushq $0x4
popq %rcx
movq 0x38(%rsp), %rdi
movl 0x14(%rsp), %esi
movl %r15d, %edx
movq 0x30(%rsp), %r8
movq 0x8(%rsp), %r9
pushq 0x28(%rsp)
pushq 0x28(%rsp)
callq 0x58a7e
popq %rax
popq %rcx
movl %r15d, %edi
movq 0x38(%rsp), %rsi
callq 0x4cf6
leaq 0x4138e(%rip), %rdi     # 0x9b98c
callq 0x4cff1
testl %eax, %eax
je 0x5a611
movq 0x30(%rsp), %rdi
callq 0x42a0
leaq 0x413d9(%rip), %rdi     # 0x9b9f1
callq 0x4cff1
testl %eax, %eax
je 0x5a62b
movq 0x8(%rsp), %rdi
callq 0x42a0
leaq 0x413c9(%rip), %rdi     # 0x9b9fb
callq 0x4cff1
testl %eax, %eax
je 0x5a645
movq 0x20(%rsp), %rdi
callq 0x42a0
leaq 0x4136d(%rip), %rdi     # 0x9b9b9
callq 0x4cff1
testl %eax, %eax
je 0x5a66d
movq 0x28(%rsp), %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x42a0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq