// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/process.c
// Function: single_run_supervised_algorithm
void single_run_supervised_algorithm(void* parameters, int meta_algorithm, int algorithm, RUN_TYPE runtype, FILE* posfile, FILE* modelfile, FILE* testcodefile, FILE* confusionfile)
{
 /*!Last Changed 16.12.2005 added write_aout_variables*/
 /*!Last Changed 28.10.2005*/
 double tstart, tend, rocarea, prarea;
 void* model = NULL;
 void** meta_model;
 int testsize;
 matrix posteriors;
 BOOLEAN testtocv = BOOLEAN_FALSE;
 totalrun++;
 tstart = clock();
 pre_process();
 if (is_cvdata_needed(algorithm))
  {
   if (in_list(runtype, 3, CROSSVALIDATION, BOOTSTRAP, TRAIN_TEST_SETS_GIVEN))
     create_cvdata();
   else
     if (get_parameter_o("separatedataused") == OFF)
       create_cvdata();
     else
       if (runtype != TRAIN_TEST_CV_SETS_GIVEN)
        {
         cvdata = testdata;
         testtocv = BOOLEAN_TRUE;
        }
  }
 else
   cvdata = NULL;
 if (runtype == CROSSVALIDATION_WITH_SEPARATE_TEST_SET && get_parameter_o("separatedataused") == ON)
  {
   if (!testtocv)
     deallocate(testdata);
   testdata = separateddata;  
  }
 testsize = data_size(testdata);
 if (meta_algorithm == NO_META_ALGORITHM)
  {
   if (get_parameter_o("hyperparametertune"))
     model = tune_hyperparameters_of_the_supervised_algorithm(algorithm, &traindata, &cvdata, &cvdata, parameters);
   else
    {
     if (get_algorithm_type(algorithm) == CLASSIFICATION)
       model = classification_algorithms[algorithm - SELECTMAX].train_algorithm(&traindata, &cvdata, parameters);
     else
       model = regression_algorithms[algorithm - ONEFEATURE].train_algorithm(&traindata, &cvdata, parameters);
    }
   test_algorithm(algorithm, model, parameters, testsize);
  }
 else
  {
   if (get_algorithm_type(algorithm) == CLASSIFICATION)
     meta_model = meta_classification_algorithms[meta_algorithm - ONE_VERSUS_ONE].train_algorithm(&traindata, &cvdata, algorithm, parameters);
   else
     meta_model = meta_regression_algorithms[meta_algorithm - BAGGING_REGRESSION].train_algorithm(&traindata, &cvdata, algorithm, parameters);
   test_meta_algorithm(meta_algorithm, algorithm, meta_model, parameters, testsize);
  }
 if (get_parameter_o("printposterior"))
  {
   fprintf(posfile, "####### CURRENT RUN COUNT %d\n", totalrun);
   print_posterior(posfile, ((Classificationresultptr) result)->posteriors, testsize, testdata);
  }
 if (get_parameter_o("printconfusion"))
  {
   if (((Classificationresultptr) result)->classno == 2)
     print_confusion_2d(confusionfile, ((Classificationresultptr) result)->confusion_matrix);
   else
     print_confusion(confusionfile, ((Classificationresultptr) result)->confusion_matrix, ((Classificationresultptr) result)->classno);
  }
 display_output(algorithm, model);
 if (meta_algorithm == NO_META_ALGORITHM)
   write_to_output_variables(algorithm, model, &traindata, testdata);
 tend = clock();
 if (get_parameter_o("showrundetails"))
   printf("Run %d took %.3f seconds\n", totalrun, (tend - tstart) / CLOCKS_PER_SEC);
 /*if (meta_algorithm == NO_META_ALGORITHM)*/
   /*write_array_variables("aout", totalrun, 1, "fd", (tend - tstart) / CLOCKS_PER_SEC, complexity_of_supervised_algorithm(algorithm, model, parameters, current_dataset));*/
 if (meta_algorithm == NO_META_ALGORITHM && current_dataset->classno == 2 && in_list(algorithm, 2, SVM, SIMPLEXSVM))
   write_array_variables("aout", totalrun, 3, "f", ((Classificationresultptr) result)->hingeloss / ((Classificationresultptr) result)->datasize);
 if (meta_algorithm == NO_META_ALGORITHM && in_list(algorithm, 2, SVMREG, SIMPLEXSVMREG))
   write_array_variables("aout", totalrun, 3, "f", ((Regressionresultptr) result)->epsilonloss / ((Regressionresultptr) result)->datasize);
 if (meta_algorithm == NO_META_ALGORITHM && algorithm == KNN)
   write_array_variables("aout", totalrun, 3, "fff", ((Classificationresultptr) result)->knnloss[0] / ((Classificationresultptr) result)->datasize, ((Classificationresultptr) result)->knnloss[1] / ((Classificationresultptr) result)->datasize, ((Classificationresultptr) result)->knnloss[2] / ((Classificationresultptr) result)->datasize);
 if (meta_algorithm == NO_META_ALGORITHM &&get_parameter_o("savemodel"))
   save_model(modelfile, algorithm, model, parameters);
 if (meta_algorithm == NO_META_ALGORITHM &&get_parameter_o("savetestcode"))
   generate_test_code(testcodefile, algorithm, model, parameters, get_parameter_l("language"), current_dataset);
 if (meta_algorithm == NO_META_ALGORITHM)
   free_model_of_supervised_algorithm(algorithm, model, current_dataset);
 else
   free_model_of_meta_classification_algorithm(meta_algorithm, algorithm, meta_model, current_dataset);
 post_process(YES);
 #ifdef MPI
 if (rank == 0)
  {
   if (get_algorithm_type(algorithm) == CLASSIFICATION)
    {
     print_classification_results(testdata, (Classificationresultptr) result, (tend - tstart) / CLOCKS_PER_SEC, get_parameter_o("printbinary"), get_parameter_o("displayruntime"), get_parameter_o("accuracy"), get_parameter_o("displayclassresulton"));
     free_performance((Classificationresultptr) result);
    }
   else
    {
     print_regression_results(testdata, (Regressionresultptr) result, (tend - tstart) / CLOCKS_PER_SEC, get_parameter_o("printbinary"), get_parameter_o("displayruntime"));
     free_performance_regression((Regressionresultptr) result);
    }
  }
 #else
 if (get_algorithm_type(algorithm) == CLASSIFICATION)
  {
   print_classification_results(testdata, (Classificationresultptr) result, (tend - tstart) / CLOCKS_PER_SEC, get_parameter_o("printbinary"), get_parameter_o("displayruntime"), get_parameter_o("accuracy"), get_parameter_o("displayclassresulton"));
   posteriors = construct_posterior_matrix(((Classificationresultptr) result)->posteriors, testdata);
   rocarea = find_area_under_the_curve_kclass(posteriors, tpr_fpr_performance);
   prarea = find_area_under_the_curve_kclass(posteriors, precision_recall_performance);
   matrix_free(posteriors);
   /*write_array_variables("pout", totalrun, 1, "ff", rocarea, prarea);*/
   free_performance((Classificationresultptr) result);
  }
 else
  {
   print_regression_results(testdata, (Regressionresultptr) result, (tend - tstart) / CLOCKS_PER_SEC, get_parameter_o("printbinary"), get_parameter_o("displayruntime"));
   free_performance_regression((Regressionresultptr) result);
  }
 #endif 
 if (traindata)
  {
   deallocate(traindata);
   traindata = NULL;
  }
 if (testdata)
  {
   deallocate(testdata);
   testdata = NULL;
  }
 if (cvdata && runtype == CROSSVALIDATION_WITH_SEPARATE_TEST_SET)
  {
   deallocate(cvdata);
   cvdata = NULL;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x20(%rsp)
movq %r8, %r15
movl %ecx, %ebp
movl %edx, %ebx
movl %esi, %r12d
movq %rdi, 0x10(%rsp)
incl 0x350cd2(%rip)          # 0x3b2020
callq 0x4250
movq %rax, 0x8(%rsp)
callq 0x5f670
movl %ebx, %edi
callq 0x595b
testl %eax, %eax
je 0x6138e
movl %ebp, %edi
movl $0x3, %esi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x3, %r8d
xorl %eax, %eax
callq 0x3aa8c
testl %eax, %eax
je 0x613d9
callq 0x5f530
jmp 0x61399
movq $0x0, 0x2d6aa7(%rip) # 0x337e40
movb $0x1, %r14b
cmpl $0x1, %ebp
jne 0x613f2
leaq 0x4a6af(%rip), %rdi     # 0xaba57
callq 0x54bec
movb $0x1, %cl
movl %ecx, 0x4(%rsp)
cmpl $0x1, %eax
jne 0x613fa
testb %r14b, %r14b
je 0x613c9
movq 0x2d6a74(%rip), %rdi    # 0x337e38
callq 0x2ff55
movq 0x2d6a78(%rip), %rax    # 0x337e48
movq %rax, 0x2d6a61(%rip)    # 0x337e38
jmp 0x613fa
leaq 0x4a677(%rip), %rdi     # 0xaba57
callq 0x54bec
testl %eax, %eax
je 0x61387
cmpl $0x4, %ebp
jne 0x614d4
movl $0x0, 0x4(%rsp)
movq 0x2d6a37(%rip), %rdi    # 0x337e38
callq 0x30309
movl %eax, %r13d
cmpl $-0x1, %r12d
je 0x61435
movl %ebx, %edi
callq 0x445c
testl %eax, %eax
je 0x6146a
leal -0xc8(%r12), %eax
cltq
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x72b6d(%rip), %rax     # 0xd3fa0
jmp 0x61480
leaq 0x44379(%rip), %rdi     # 0xa57b5
callq 0x54bec
testl %eax, %eax
je 0x614b4
leaq 0x2d69e4(%rip), %rsi    # 0x337e30
leaq 0x2d69ed(%rip), %rcx    # 0x337e40
movl %ebx, %edi
movq %rcx, %rdx
movq 0x10(%rsp), %r14
movq %r14, %r8
callq 0x529d
jmp 0x61516
leal -0x64(%r12), %eax
cltq
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x72b60(%rip), %rax     # 0xd3fe0
leaq 0x2d69a9(%rip), %rdi    # 0x337e30
leaq 0x2d69b2(%rip), %rsi    # 0x337e40
movl %ebx, %edx
movq 0x10(%rsp), %rbp
movq %rbp, %rcx
callq *(%rax)
movq %rax, %r14
movl %r12d, %edi
movl %ebx, %esi
movq %rax, %rdx
movq %rbp, %rcx
movl %r13d, %r8d
callq 0x60d4b
xorl %ebp, %ebp
jmp 0x61529
movl %ebx, %edi
callq 0x445c
testl %eax, %eax
je 0x614ea
leal -0x7d0(%rbx), %eax
cltq
leaq (%rax,%rax,4), %rax
leaq 0x7335e(%rip), %rcx     # 0xd4830
jmp 0x614fd
movq 0x2d695d(%rip), %rax    # 0x337e38
movq %rax, 0x2d695e(%rip)    # 0x337e40
xorl %r14d, %r14d
jmp 0x6139c
leal -0x3e8(%rbx), %eax
cltq
leaq (%rax,%rax,4), %rax
leaq 0x72cc3(%rip), %rcx     # 0xd41c0
leaq 0x2d692c(%rip), %rdi    # 0x337e30
leaq 0x2d6935(%rip), %rsi    # 0x337e40
movq 0x10(%rsp), %r14
movq %r14, %rdx
callq *(%rcx,%rax,8)
movq %rax, %rbp
movl %ebx, %edi
movq %rax, %rsi
movq %r14, %rdx
movl %r13d, %ecx
callq 0x60fd6
leaq 0x4a538(%rip), %rdi     # 0xaba68
callq 0x54bec
testl %eax, %eax
je 0x6156d
movl 0x350ae1(%rip), %edx    # 0x3b2020
leaq 0x4a531(%rip), %rsi     # 0xaba77
movq %r15, %rdi
xorl %eax, %eax
callq 0x42e0
movq 0x350ad1(%rip), %rax    # 0x3b2028
movq 0x28(%rax), %rsi
movq 0x2d68d6(%rip), %rcx    # 0x337e38
movq %r15, %rdi
movl %r13d, %edx
callq 0x8728
leaq 0x4a521(%rip), %rdi     # 0xaba95
callq 0x54bec
testl %eax, %eax
je 0x615a1
movq 0x68(%rsp), %rdi
movq 0x350a9f(%rip), %rax    # 0x3b2028
movl 0x20(%rax), %edx
movq 0x18(%rax), %rsi
cmpl $0x2, %edx
jne 0x6159c
callq 0x8707
jmp 0x615a1
callq 0x8691
movl %ebx, %edi
movq %rbp, %rsi
callq 0x6718
cmpl $-0x1, %r12d
jne 0x615c9
movq 0x2d6880(%rip), %rcx    # 0x337e38
leaq 0x2d6871(%rip), %rdx    # 0x337e30
movl %ebx, %edi
movq %rbp, %rsi
callq 0x5fa27
cvtsi2sdq 0x8(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0x4250
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x4a4b4(%rip), %rdi     # 0xabaa4
callq 0x54bec
testl %eax, %eax
je 0x61621
movl 0x350a21(%rip), %esi    # 0x3b2020
movsd 0x8(%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
divsd 0x4470d(%rip), %xmm0    # 0xa5d20
leaq 0x4a499(%rip), %rdi     # 0xabab3
movb $0x1, %al
callq 0x4030
movq 0x74248(%rip), %rcx     # 0xd5870
cmpl $-0x1, %r12d
je 0x61640
movl %r12d, %edi
movl %ebx, %esi
movq %r14, %rdx
callq 0x43207
jmp 0x617ad
cmpl $0x2, 0x10(%rcx)
jne 0x61697
movl %ebx, %edi
movl $0x2, %esi
movl $0x3f9, %edx            # imm = 0x3F9
movl $0x3fa, %ecx            # imm = 0x3FA
xorl %eax, %eax
callq 0x3aa8c
testl %eax, %eax
je 0x61697
movl 0x3509b8(%rip), %esi    # 0x3b2020
movq 0x3509b9(%rip), %rax    # 0x3b2028
movsd 0x38(%rax), %xmm0
cvtsi2sdl 0x30(%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x4412c(%rip), %rdi     # 0xa57b0
leaq 0x46fee(%rip), %rcx     # 0xa8679
movl $0x3, %edx
movb $0x1, %al
callq 0x33644
movl %ebx, %edi
movl $0x2, %esi
movl $0x7d8, %edx            # imm = 0x7D8
movl $0x7d9, %ecx            # imm = 0x7D9
xorl %eax, %eax
callq 0x3aa8c
testl %eax, %eax
movq 0x10(%rsp), %r15
je 0x616f0
movl 0x350962(%rip), %esi    # 0x3b2020
movq 0x350963(%rip), %rax    # 0x3b2028
movsd 0x18(%rax), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x10(%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x440d3(%rip), %rdi     # 0xa57b0
leaq 0x46f95(%rip), %rcx     # 0xa8679
movl $0x3, %edx
movb $0x1, %al
callq 0x33644
cmpl $0x3e9, %ebx            # imm = 0x3E9
jne 0x6173f
movl 0x350922(%rip), %esi    # 0x3b2020
movq 0x350923(%rip), %rax    # 0x3b2028
cvtsi2sdl 0x30(%rax), %xmm3
movsd 0x40(%rax), %xmm0
movsd 0x48(%rax), %xmm1
divsd %xmm3, %xmm0
divsd %xmm3, %xmm1
movsd 0x50(%rax), %xmm2
divsd %xmm3, %xmm2
leaq 0x44084(%rip), %rdi     # 0xa57b0
leaq 0x5062a(%rip), %rcx     # 0xb1d5d
movl $0x3, %edx
movb $0x3, %al
callq 0x33644
leaq 0x4a387(%rip), %rdi     # 0xabacd
callq 0x54bec
testl %eax, %eax
je 0x61761
movq 0x20(%rsp), %rdi
movl %ebx, %esi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x608aa
leaq 0x4a36f(%rip), %rdi     # 0xabad7
callq 0x54bec
testl %eax, %eax
je 0x6179c
movq 0x60(%rsp), %r14
leaq 0x4a367(%rip), %rdi     # 0xabae4
callq 0x54afc
movq 0x740e7(%rip), %r9      # 0xd5870
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rdx
movq %r15, %rcx
movl %eax, %r8d
callq 0x4ac3
movq 0x740cd(%rip), %rdx     # 0xd5870
movl %ebx, %edi
movq %rbp, %rsi
callq 0x4d38
movl $0x1, %edi
callq 0x5d9af
movl %ebx, %edi
callq 0x445c
movl %eax, %r12d
movq 0x2d6670(%rip), %r14    # 0x337e38
movq 0x350859(%rip), %rbx    # 0x3b2028
leaq 0x4a317(%rip), %rdi     # 0xabaed
callq 0x54bec
movl %eax, %ebp
leaq 0x4a315(%rip), %rdi     # 0xabaf9
callq 0x54bec
movl %eax, %r15d
movsd 0x8(%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
divsd 0x44520(%rip), %xmm0    # 0xa5d20
testl %r12d, %r12d
je 0x61826
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movl %r15d, %ecx
callq 0x721cc
movq 0x35080c(%rip), %rdi    # 0x3b2028
callq 0x7238c
jmp 0x618bb
leaq 0x4a2db(%rip), %rdi     # 0xabb08
movsd %xmm0, 0x8(%rsp)
callq 0x54bec
movl %eax, %r12d
leaq 0x4a2cf(%rip), %rdi     # 0xabb11
callq 0x54bec
movq %r14, %rdi
movq %rbx, %rsi
movsd 0x8(%rsp), %xmm0
movl %ebp, %edx
movl %r15d, %ecx
movl %r12d, %r8d
movl %eax, %r9d
callq 0x8823
movq 0x3507be(%rip), %rax    # 0x3b2028
movq 0x28(%rax), %rdi
movq 0x2d65c3(%rip), %rsi    # 0x337e38
callq 0x8fc71
movq %rax, %rbx
movq %rdx, %r14
leaq 0x2e353(%rip), %rdx     # 0x8fbda
movq %rax, %rdi
movq %r14, %rsi
callq 0x90030
leaq 0x2e383(%rip), %rdx     # 0x8fc1c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x90030
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3ed51
movq 0x350772(%rip), %rdi    # 0x3b2028
callq 0x8bab
movq 0x2d656e(%rip), %rdi    # 0x337e30
testq %rdi, %rdi
je 0x618d7
callq 0x2ff55
movq $0x0, 0x2d6559(%rip) # 0x337e30
movq 0x2d655a(%rip), %rdi    # 0x337e38
testq %rdi, %rdi
je 0x618f3
callq 0x2ff55
movq $0x0, 0x2d6545(%rip) # 0x337e38
movq 0x2d6546(%rip), %rdi    # 0x337e40
testq %rdi, %rdi
sete %al
movl 0x4(%rsp), %ecx
xorb $0x1, %cl
orb %al, %cl
jne 0x6191b
callq 0x2ff55
movq $0x0, 0x2d6525(%rip) # 0x337e40
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq