// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movl %ecx, %r15d
movl %edx, %r14d
movl %esi, %r13d
movq %rdi, %r12
incl 0x34f3cc(%rip)          # 0x3af020
callq 0x4250
movq %rax, (%rsp)
callq 0x5e071
movl %r14d, %edi
callq 0x595b
testl %eax, %eax
je 0x5fc99
movl %r15d, %edi
movl $0x3, %esi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x3, %r8d
xorl %eax, %eax
callq 0x39a80
testl %eax, %eax
je 0x5fd5e
callq 0x5df2c
jmp 0x5fca4
movq $0x0, 0x2d519c(%rip) # 0x334e40
movb $0x1, %bpl
cmpl $0x1, %r15d
jne 0x5fcdd
leaq 0x48cd7(%rip), %rdi     # 0xa898b
callq 0x536e7
cmpl $0x1, %eax
jne 0x5fcdd
testb %bpl, %bpl
je 0x5fccf
movq 0x2d516e(%rip), %rdi    # 0x334e38
callq 0x2f616
movq 0x2d5172(%rip), %rax    # 0x334e48
movq %rax, 0x2d515b(%rip)    # 0x334e38
movl %r15d, 0xc(%rsp)
movq 0x2d514f(%rip), %rdi    # 0x334e38
callq 0x2fa14
movl %eax, %r15d
cmpl $-0x1, %r13d
movq %r12, 0x10(%rsp)
je 0x5fd29
movl %r14d, %edi
callq 0x445c
testl %eax, %eax
je 0x5fd94
leal -0xc8(%r13), %eax
cltq
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x7127c(%rip), %rax     # 0xd0fa0
jmp 0x5fda9
leaq 0x42a85(%rip), %rdi     # 0xa27b5
callq 0x536e7
testl %eax, %eax
je 0x5fddb
leaq 0x2d50ec(%rip), %rsi    # 0x334e30
leaq 0x2d50f5(%rip), %rcx    # 0x334e40
movl %r14d, %edi
movq %rcx, %rdx
movq %r12, %r8
callq 0x52af
jmp 0x5fe25
leaq 0x48c26(%rip), %rdi     # 0xa898b
callq 0x536e7
testl %eax, %eax
je 0x5fc92
movb $0x1, %bpl
cmpl $0x4, %r15d
je 0x5fca7
movq 0x2d50b2(%rip), %rax    # 0x334e38
movq %rax, 0x2d50b3(%rip)    # 0x334e40
xorl %ebp, %ebp
jmp 0x5fca7
leal -0x64(%r13), %eax
cltq
leaq (%rax,%rax,2), %rax
shlq $0x3, %rax
addq 0x71237(%rip), %rax     # 0xd0fe0
leaq 0x2d5080(%rip), %rdi    # 0x334e30
leaq 0x2d5089(%rip), %rsi    # 0x334e40
movl %r14d, %edx
movq %r12, %rcx
callq *(%rax)
movq %rax, %rbp
movl %r13d, %edi
movl %r14d, %esi
movq %rax, %rdx
movq %r12, %rcx
movl %r15d, %r8d
callq 0x5f651
xorl %r12d, %r12d
jmp 0x5fe39
movl %r14d, %edi
callq 0x445c
testl %eax, %eax
je 0x5fdfd
leal -0x7d0(%r14), %eax
cltq
leaq (%rax,%rax,4), %rax
leaq 0x71a35(%rip), %rcx     # 0xd1830
jmp 0x5fe11
leal -0x3e8(%r14), %eax
cltq
leaq (%rax,%rax,4), %rax
leaq 0x713af(%rip), %rcx     # 0xd11c0
leaq 0x2d5018(%rip), %rdi    # 0x334e30
leaq 0x2d5021(%rip), %rsi    # 0x334e40
movq %r12, %rdx
callq *(%rcx,%rax,8)
movq %r12, %rdx
movq %rax, %r12
movl %r14d, %edi
movq %rax, %rsi
movl %r15d, %ecx
callq 0x5f8dc
leaq 0x48b5c(%rip), %rdi     # 0xa899c
callq 0x536e7
testl %eax, %eax
je 0x5fe7d
movl 0x34f1d1(%rip), %edx    # 0x3af020
leaq 0x48b55(%rip), %rsi     # 0xa89ab
movq %rbx, %rdi
xorl %eax, %eax
callq 0x42e0
movq 0x34f1c1(%rip), %rax    # 0x3af028
movq 0x28(%rax), %rsi
movq 0x2d4fc6(%rip), %rcx    # 0x334e38
movq %rbx, %rdi
movl %r15d, %edx
callq 0x86f8
leaq 0x48b45(%rip), %rdi     # 0xa89c9
callq 0x536e7
testl %eax, %eax
je 0x5feb1
movq 0x68(%rsp), %rdi
movq 0x34f18f(%rip), %rax    # 0x3af028
movl 0x20(%rax), %edx
movq 0x18(%rax), %rsi
cmpl $0x2, %edx
jne 0x5feac
callq 0x86d7
jmp 0x5feb1
callq 0x8661
movl %r14d, %edi
movq %r12, %rsi
callq 0x6718
cmpl $-0x1, %r13d
jne 0x5fedb
movq 0x2d4f6f(%rip), %rcx    # 0x334e38
leaq 0x2d4f60(%rip), %rdx    # 0x334e30
movl %r14d, %edi
movq %r12, %rsi
callq 0x5e32d
cvtsi2sdq (%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0x4250
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, (%rsp)
leaq 0x48ad8(%rip), %rdi     # 0xa89d8
callq 0x536e7
testl %eax, %eax
je 0x5ff30
movl 0x34f111(%rip), %esi    # 0x3af020
movsd (%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
divsd 0x42dfe(%rip), %xmm0    # 0xa2d20
leaq 0x48abe(%rip), %rdi     # 0xa89e7
movb $0x1, %al
callq 0x4030
cmpl $-0x1, %r13d
jne 0x5ffee
movq 0x7292f(%rip), %rax     # 0xd2870
cmpl $0x2, 0x10(%rax)
jne 0x5ff99
movl %r14d, %edi
movl $0x2, %esi
movl $0x3f9, %edx            # imm = 0x3F9
movl $0x3fa, %ecx            # imm = 0x3FA
xorl %eax, %eax
callq 0x39a80
testl %eax, %eax
je 0x5ff99
movl 0x34f0b6(%rip), %esi    # 0x3af020
movq 0x34f0b7(%rip), %rax    # 0x3af028
movsd 0x38(%rax), %xmm0
cvtsi2sdl 0x30(%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x4282a(%rip), %rdi     # 0xa27b0
leaq 0x45694(%rip), %rcx     # 0xa5621
movl $0x3, %edx
movb $0x1, %al
callq 0x32c64
movl %r14d, %edi
movl $0x2, %esi
movl $0x7d8, %edx            # imm = 0x7D8
movl $0x7d9, %ecx            # imm = 0x7D9
xorl %eax, %eax
callq 0x39a80
testl %eax, %eax
je 0x5ffee
movl 0x34f064(%rip), %esi    # 0x3af020
movq 0x34f065(%rip), %rax    # 0x3af028
movsd 0x18(%rax), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x10(%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0x427d5(%rip), %rdi     # 0xa27b0
leaq 0x4563f(%rip), %rcx     # 0xa5621
movl $0x3, %edx
movb $0x1, %al
callq 0x32c64
movl %r13d, %eax
notl %eax
movl %r14d, %ecx
xorl $0x3e9, %ecx            # imm = 0x3E9
orl %eax, %ecx
jne 0x60047
movl 0x34f01a(%rip), %esi    # 0x3af020
movq 0x34f01b(%rip), %rax    # 0x3af028
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 0x4277c(%rip), %rdi     # 0xa27b0
leaq 0x4eca2(%rip), %rcx     # 0xaecdd
movl $0x3, %edx
movb $0x3, %al
callq 0x32c64
cmpl $-0x1, %r13d
je 0x60064
movq 0x7281c(%rip), %rcx     # 0xd2870
movl %r13d, %edi
movl %r14d, %esi
movq %rbp, %rdx
callq 0x41e9c
jmp 0x600d9
leaq 0x48996(%rip), %rdi     # 0xa8a01
callq 0x536e7
testl %eax, %eax
je 0x60089
movq 0x20(%rsp), %rdi
movl %r14d, %esi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
callq 0x5f1b0
leaq 0x4897b(%rip), %rdi     # 0xa8a0b
callq 0x536e7
testl %eax, %eax
je 0x600c7
movq 0x60(%rsp), %rbx
leaq 0x48973(%rip), %rdi     # 0xa8a18
callq 0x535f7
movq 0x727bf(%rip), %r9      # 0xd2870
movq %rbx, %rdi
movl %r14d, %esi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
movl %eax, %r8d
callq 0x4add
movq 0x727a2(%rip), %rdx     # 0xd2870
movl %r14d, %edi
movq %r12, %rsi
callq 0x4d52
movl $0x1, %edi
callq 0x5c49b
movl %r14d, %edi
callq 0x445c
movl %eax, %r12d
movq 0x2d4d43(%rip), %r14    # 0x334e38
movq 0x34ef2c(%rip), %rbx    # 0x3af028
leaq 0x4891e(%rip), %rdi     # 0xa8a21
callq 0x536e7
movl %eax, %ebp
leaq 0x4891c(%rip), %rdi     # 0xa8a2d
callq 0x536e7
movl %eax, %r15d
movsd (%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
divsd 0x42bf4(%rip), %xmm0    # 0xa2d20
testl %r12d, %r12d
je 0x60152
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movl %r15d, %ecx
callq 0x70a00
movq 0x34eee0(%rip), %rdi    # 0x3af028
callq 0x70bc0
jmp 0x601e5
leaq 0x488e3(%rip), %rdi     # 0xa8a3c
movsd %xmm0, (%rsp)
callq 0x536e7
movl %eax, %r12d
leaq 0x488d8(%rip), %rdi     # 0xa8a45
callq 0x536e7
movq %r14, %rdi
movq %rbx, %rsi
movsd (%rsp), %xmm0
movl %ebp, %edx
movl %r15d, %ecx
movl %r12d, %r8d
movl %eax, %r9d
callq 0x87f3
movq 0x34ee94(%rip), %rax    # 0x3af028
movq 0x28(%rax), %rdi
movq 0x2d4c99(%rip), %rsi    # 0x334e38
callq 0x8d4b7
movq %rax, %rbx
movq %rdx, %r14
leaq 0x2d286(%rip), %rdx     # 0x8d437
movq %rax, %rdi
movq %r14, %rsi
callq 0x8d84f
leaq 0x2d2b4(%rip), %rdx     # 0x8d477
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8d84f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3dbad
movq 0x34ee48(%rip), %rdi    # 0x3af028
callq 0x8b7b
movq 0x2d4c44(%rip), %rdi    # 0x334e30
testq %rdi, %rdi
movl 0xc(%rsp), %ebx
je 0x60205
callq 0x2f616
movq $0x0, 0x2d4c2b(%rip) # 0x334e30
movq 0x2d4c2c(%rip), %rdi    # 0x334e38
testq %rdi, %rdi
je 0x60221
callq 0x2f616
movq $0x0, 0x2d4c17(%rip) # 0x334e38
cmpl $0x1, %ebx
setne %al
movq 0x2d4c12(%rip), %rdi    # 0x334e40
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x60248
callq 0x2f616
movq $0x0, 0x2d4bf8(%rip) # 0x334e40
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq