// File: /workspace/github_c_makefile_star2_O2/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 0x35157a(%rip)          # 0x3aa020
callq 0x4250
movq %rax, 0x8(%rsp)
callq 0x56f57
movl %ebx, %edi
callq 0x591a
testl %eax, %eax
je 0x58adf
pushq $0x2
popq %rcx
pushq $0x3
popq %rsi
movl %ebp, %edi
xorl %edx, %edx
movl %esi, %r8d
xorl %eax, %eax
callq 0x35812
testl %eax, %eax
je 0x58b27
callq 0x56e2d
jmp 0x58ae7
andq $0x0, 0x2d7359(%rip)    # 0x32fe40
movb $0x1, %r14b
cmpl $0x1, %ebp
jne 0x58b40
leaq 0x42e85(%rip), %rdi     # 0x9b97b
callq 0x4cff1
movb $0x1, %cl
movl %ecx, 0x4(%rsp)
cmpl $0x1, %eax
jne 0x58b48
testb %r14b, %r14b
je 0x58b17
movq 0x2d7326(%rip), %rdi    # 0x32fe38
callq 0x2c010
movq 0x2d732a(%rip), %rax    # 0x32fe48
movq %rax, 0x2d7313(%rip)    # 0x32fe38
jmp 0x58b48
leaq 0x42e4d(%rip), %rdi     # 0x9b97b
callq 0x4cff1
testl %eax, %eax
je 0x58ad8
cmpl $0x4, %ebp
jne 0x58c1a
movl $0x0, 0x4(%rsp)
movq 0x2d72e9(%rip), %rdi    # 0x32fe38
callq 0x2c3cc
movl %eax, %r13d
cmpl $-0x1, %r12d
je 0x58b7f
movl %ebx, %edi
callq 0x445c
testl %eax, %eax
je 0x58bb4
leal -0xc8(%r12), %eax
cltq
imulq $0x18, %rax, %rax
addq 0x73423(%rip), %rax     # 0xcbfa0
jmp 0x58bc6
leaq 0x3cc2f(%rip), %rdi     # 0x957b5
callq 0x4cff1
testl %eax, %eax
je 0x58bfa
leaq 0x2d729a(%rip), %rsi    # 0x32fe30
leaq 0x2d72a3(%rip), %rcx    # 0x32fe40
movl %ebx, %edi
movq %rcx, %rdx
movq 0x10(%rsp), %r14
movq %r14, %r8
callq 0x5231
jmp 0x58c5c
leal -0x64(%r12), %eax
cltq
imulq $0x18, %rax, %rax
addq 0x7341a(%rip), %rax     # 0xcbfe0
leaq 0x2d7263(%rip), %rdi    # 0x32fe30
leaq 0x2d726c(%rip), %rsi    # 0x32fe40
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 0x5849f
xorl %ebp, %ebp
jmp 0x58c6f
movl %ebx, %edi
callq 0x445c
testl %eax, %eax
je 0x58c30
leal -0x7d0(%rbx), %eax
cltq
imulq $0x28, %rax, %rax
leaq 0x73c18(%rip), %rcx     # 0xcc830
jmp 0x58c43
movq 0x2d7217(%rip), %rax    # 0x32fe38
movq %rax, 0x2d7218(%rip)    # 0x32fe40
xorl %r14d, %r14d
jmp 0x58aea
leal -0x3e8(%rbx), %eax
cltq
imulq $0x28, %rax, %rax
leaq 0x7357d(%rip), %rcx     # 0xcc1c0
leaq 0x2d71e6(%rip), %rdi    # 0x32fe30
leaq 0x2d71ef(%rip), %rsi    # 0x32fe40
movq 0x10(%rsp), %r14
movq %r14, %rdx
callq *(%rcx,%rax)
movq %rax, %rbp
movl %ebx, %edi
movq %rax, %rsi
movq %r14, %rdx
movl %r13d, %ecx
callq 0x5872b
leaq 0x42d16(%rip), %rdi     # 0x9b98c
callq 0x4cff1
testl %eax, %eax
je 0x58cb3
movl 0x35139b(%rip), %edx    # 0x3aa020
leaq 0x42d0f(%rip), %rsi     # 0x9b99b
movq %r15, %rdi
xorl %eax, %eax
callq 0x42e0
movq 0x35138b(%rip), %rax    # 0x3aa028
movq 0x28(%rax), %rsi
movq 0x2d7190(%rip), %rcx    # 0x32fe38
movq %r15, %rdi
movl %r13d, %edx
callq 0x840e
leaq 0x42cff(%rip), %rdi     # 0x9b9b9
callq 0x4cff1
testl %eax, %eax
je 0x58ce7
movq 0x68(%rsp), %rdi
movq 0x351359(%rip), %rax    # 0x3aa028
movl 0x20(%rax), %edx
movq 0x18(%rax), %rsi
cmpl $0x2, %edx
jne 0x58ce2
callq 0x83ed
jmp 0x58ce7
callq 0x8369
movl %ebx, %edi
movq %rbp, %rsi
callq 0x65c5
cmpl $-0x1, %r12d
jne 0x58d0f
movq 0x2d713a(%rip), %rcx    # 0x32fe38
leaq 0x2d712b(%rip), %rdx    # 0x32fe30
movl %ebx, %edi
movq %rbp, %rsi
callq 0x57209
cvtsi2sdq 0x8(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0x4250
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x42c95(%rip), %rdi     # 0x9b9c8
callq 0x4cff1
testl %eax, %eax
je 0x58d64
movl 0x3512de(%rip), %esi    # 0x3aa020
movsd 0x8(%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
divsd 0x3cfd2(%rip), %xmm0    # 0x95d28
leaq 0x42c7a(%rip), %rdi     # 0x9b9d7
movb $0x1, %al
callq 0x4030
movq 0x74b05(%rip), %rcx     # 0xcd870
cmpl $-0x1, %r12d
je 0x58d83
movl %r12d, %edi
movl %ebx, %esi
movq %r14, %rdx
callq 0x3ce1d
jmp 0x58ee3
cmpl $0x2, 0x10(%rcx)
jne 0x58dd6
pushq $0x2
popq %rsi
movl %ebx, %edi
movl $0x3f9, %edx            # imm = 0x3F9
movl $0x3fa, %ecx            # imm = 0x3FA
xorl %eax, %eax
callq 0x35812
testl %eax, %eax
je 0x58dd6
movl 0x351277(%rip), %esi    # 0x3aa020
movq 0x351278(%rip), %rax    # 0x3aa028
movsd 0x38(%rax), %xmm0
cvtsi2sdl 0x30(%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x3c9eb(%rip), %rdi     # 0x957b0
leaq 0x3f82d(%rip), %rcx     # 0x985f9
pushq $0x3
popq %rdx
movb $0x1, %al
callq 0x2f310
pushq $0x2
popq %rsi
movl %ebx, %edi
movl $0x7d8, %edx            # imm = 0x7D8
movl $0x7d9, %ecx            # imm = 0x7D9
xorl %eax, %eax
callq 0x35812
testl %eax, %eax
movq 0x10(%rsp), %r15
je 0x58e28
movl 0x351225(%rip), %esi    # 0x3aa020
movq 0x351226(%rip), %rax    # 0x3aa028
movsd 0x18(%rax), %xmm0
cvtsi2sdl 0x10(%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x3c999(%rip), %rdi     # 0x957b0
leaq 0x3f7db(%rip), %rcx     # 0x985f9
pushq $0x3
popq %rdx
movb $0x1, %al
callq 0x2f310
cmpl $0x3e9, %ebx            # imm = 0x3E9
jne 0x58e75
movl 0x3511ea(%rip), %esi    # 0x3aa020
movq 0x3511eb(%rip), %rax    # 0x3aa028
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 0x3c94c(%rip), %rdi     # 0x957b0
leaq 0x48e4a(%rip), %rcx     # 0xa1cb5
pushq $0x3
popq %rdx
movb $0x3, %al
callq 0x2f310
leaq 0x42b75(%rip), %rdi     # 0x9b9f1
callq 0x4cff1
testl %eax, %eax
je 0x58e97
movq 0x20(%rsp), %rdi
movl %ebx, %esi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x57fff
leaq 0x42b5d(%rip), %rdi     # 0x9b9fb
callq 0x4cff1
testl %eax, %eax
je 0x58ed2
movq 0x60(%rsp), %r14
leaq 0x42b55(%rip), %rdi     # 0x9ba08
callq 0x4cf11
movq 0x749b1(%rip), %r9      # 0xcd870
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rdx
movq %r15, %rcx
movl %eax, %r8d
callq 0x4abd
movq 0x74997(%rip), %rdx     # 0xcd870
movl %ebx, %edi
movq %rbp, %rsi
callq 0x4d2f
pushq $0x1
popq %rdi
callq 0x5549c
movl %ebx, %edi
callq 0x445c
movl %eax, %r12d
movq 0x2d6f3c(%rip), %r14    # 0x32fe38
movq 0x351125(%rip), %rbx    # 0x3aa028
leaq 0x42b07(%rip), %rdi     # 0x9ba11
callq 0x4cff1
movl %eax, %ebp
leaq 0x42b05(%rip), %rdi     # 0x9ba1d
callq 0x4cff1
movl %eax, %r15d
movsd 0x8(%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
divsd 0x3cdf4(%rip), %xmm0    # 0x95d28
testl %r12d, %r12d
je 0x58f5a
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movl %r15d, %ecx
callq 0x68838
movq 0x3510d8(%rip), %rdi    # 0x3aa028
callq 0x689da
jmp 0x58fef
leaq 0x42acb(%rip), %rdi     # 0x9ba2c
movsd %xmm0, 0x8(%rsp)
callq 0x4cff1
movl %eax, %r12d
leaq 0x42abf(%rip), %rdi     # 0x9ba35
callq 0x4cff1
movq %r14, %rdi
movq %rbx, %rsi
movsd 0x8(%rsp), %xmm0
movl %ebp, %edx
movl %r15d, %ecx
movl %r12d, %r8d
movl %eax, %r9d
callq 0x84db
movq 0x35108a(%rip), %rax    # 0x3aa028
movq 0x28(%rax), %rdi
movq 0x2d6e8f(%rip), %rsi    # 0x32fe38
callq 0x820a7
movq %rax, %rbx
movq %rdx, %r14
leaq 0x29058(%rip), %rdx     # 0x82013
movq %rax, %rdi
movq %r14, %rsi
callq 0x823f0
leaq 0x29088(%rip), %rdx     # 0x82055
movq %rbx, %rdi
movq %r14, %rsi
callq 0x823f0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3929f
movq 0x35103e(%rip), %rdi    # 0x3aa028
callq 0x882e
movq 0x2d6e3a(%rip), %rdi    # 0x32fe30
testq %rdi, %rdi
je 0x59008
callq 0x2c010
andq $0x0, 0x2d6e28(%rip)    # 0x32fe30
movq 0x2d6e29(%rip), %rdi    # 0x32fe38
testq %rdi, %rdi
je 0x59021
callq 0x2c010
andq $0x0, 0x2d6e17(%rip)    # 0x32fe38
movq 0x2d6e18(%rip), %rdi    # 0x32fe40
testq %rdi, %rdi
sete %al
movl 0x4(%rsp), %ecx
xorb $0x1, %cl
orb %al, %cl
jne 0x59046
callq 0x2c010
andq $0x0, 0x2d6dfa(%rip)    # 0x32fe40
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq