// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/metaclassification.c
// Function: ensemble
Classificationresultptr ensemble(matrixptr* posteriors, int learner_count, int fold_count)
{
 int i, j, k, t, class_count, predicted_class, actual_class;
 matrix ensemble_posteriors;
 int* predictions;
 Classificationresultptr results;
 results = safemalloc(fold_count * sizeof(Classificationresult), "ensemble", 5);
 class_count = posteriors[0][0].col - 1;
 predictions = safemalloc(learner_count * sizeof(int), "ensemble", 7);
 ensemble_posteriors = matrix_alloc(learner_count, class_count);
 for (i = 0; i < fold_count; i++)
  {
   results[i].performance = 0;
   results[i].datasize = posteriors[0][i].row;
   results[i].classno = class_count;
   results[i].class_performance = safecalloc(class_count, sizeof(int), "ensemble", 14);
   results[i].class_counts = safecalloc(class_count, sizeof(int), "ensemble", 15);
   results[i].confusion_matrix = (int**) safecalloc_2d(sizeof(int*), sizeof(int), class_count, class_count, "ensemble", 16);
   for (j = 0; j < results[i].datasize; j++)
    {
     for (k = 0; k < learner_count; k++)
      {
       for (t = 0; t < class_count; t++)
         ensemble_posteriors.values[k][t] = posteriors[k][i].values[j][t];
       predictions[k] = find_max_in_list_double(ensemble_posteriors.values[k], class_count);
      }
     predicted_class = combination_algorithms[get_parameter_l("combinationtype")](predictions, ensemble_posteriors);
     actual_class = posteriors[0][i].values[j][class_count];
     (results[i].class_counts[actual_class])++;
     (results[i].confusion_matrix[actual_class][predicted_class])++;
     if (predicted_class == actual_class)
      {
       (results[i].performance)++;
       (results[i].class_performance[actual_class])++;
      }
    }
  }
 matrix_free(ensemble_posteriors);
 safe_free(predictions);
 return results;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movslq -0x10(%rbp), %rax
imulq $0x58, %rax, %rdi
leaq 0x86690(%rip), %rsi     # 0xe6e41
movl $0x5, %edx
callq 0x52d70
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movslq -0xc(%rbp), %rdi
shlq $0x2, %rdi
leaq 0x86663(%rip), %rsi     # 0xe6e41
movl $0x7, %edx
callq 0x52d70
movq %rax, -0x48(%rbp)
movl -0xc(%rbp), %edi
movl -0x24(%rbp), %esi
callq 0x57fc0
movq %rax, -0x60(%rbp)
movq %rdx, -0x58(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x60ac4
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0x58, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x30(%rax)
movl -0x24(%rbp), %ecx
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0x58, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x20(%rax)
movslq -0x24(%rbp), %rdi
movl $0x4, %esi
leaq 0x865bf(%rip), %rdx     # 0xe6e41
movl $0xe, %ecx
callq 0x52f40
movq %rax, %rcx
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0x58, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movslq -0x24(%rbp), %rdi
movl $0x4, %esi
leaq 0x8658f(%rip), %rdx     # 0xe6e41
movl $0xf, %ecx
callq 0x52f40
movq %rax, %rcx
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0x58, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movl -0x24(%rbp), %edx
movl -0x24(%rbp), %ecx
movl $0x8, %edi
movl $0x4, %esi
leaq 0x86558(%rip), %r8      # 0xe6e41
movl $0x10, %r9d
callq 0x52fa0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0x58, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x50(%rbp), %rcx
movslq -0x14(%rbp), %rdx
imulq $0x58, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x30(%rcx), %eax
jge 0x60ab4
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x609c9
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x6099a
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x38(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x60946
movq -0x38(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl -0x24(%rbp), %esi
callq 0x500d0
movl %eax, %edx
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x60933
leaq 0x86461(%rip), %rdi     # 0xe6e31
callq 0x792b0
movslq %eax, %rcx
leaq 0xa4571(%rip), %rax     # 0x104f50
movq (%rax,%rcx,8), %rax
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq *%rax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
cvttsd2si (%rax,%rcx,8), %eax
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x60aa4
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x60aa6
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x60911
jmp 0x60ab6
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x60816
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x59ea0
movq -0x48(%rbp), %rdi
callq 0x52e80
movq -0x50(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop