// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/statistics.c
// Function: find_performance_points
Performance_pointptr find_performance_points(matrix posteriors, int* number_of_points, int posclass, int negclass, Performance_point (*calculate_performance)(int tp, int fp, int tn, int fn))
{
 int i, fp = 0, tp = 0, classno, p = 0, n = 0;
 double fprev = -INT_MAX;
 Performance_pointptr points = NULL;
 for (i = 0; i < posteriors.row; i++)
  {
   if (posteriors.values[i][posteriors.col - 1] == posclass)
     p++;
   if (posteriors.values[i][posteriors.col - 1] == negclass)
     n++;
  }
 (*number_of_points) = 0;
 matrix_sort_by_column(posteriors, posclass, DESCENDING);
 for (i = 0; i < posteriors.row; i++)
  {
   classno = posteriors.values[i][posteriors.col - 1];
   if (posteriors.values[i][posclass] != fprev)
    {
     points = alloc(points, (*number_of_points + 1) * sizeof(Performance_point), *number_of_points + 1);
     points[*number_of_points] = calculate_performance(tp, fp, n - fp, p - tp);
     if (fprev > 0.5 && posteriors.values[i][posclass] <= 0.5)
       points[*number_of_points].equal_loss = YES;
     else 
       points[*number_of_points].equal_loss = NO;
     fprev = posteriors.values[i][posclass];
     (*number_of_points)++;
    }
   if (classno == posclass)
     tp++;
   if (classno == negclass)
     fp++;
  }
 points = alloc(points, (*number_of_points + 1) * sizeof(Performance_point), *number_of_points + 1);
 points[*number_of_points] = calculate_performance(tp, fp, n - fp, p - tp);
 (*number_of_points)++;
 return points;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movsd 0x1cd52(%rip), %xmm0    # 0xe2008
movsd %xmm0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0xc533f
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jne 0xc5302
jp 0xc5302
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
cvtsi2sdl -0x20(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jne 0xc5332
jp 0xc5332
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xc5334
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xc52ca
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl -0x1c(%rbp), %edx
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl $0x1, %ecx
callq 0x5b340
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0xc54e8
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cvttsd2si (%rax,%rcx,8), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd -0x48(%rbp), %xmm0
jne 0xc53b1
jp 0xc53b1
jmp 0xc54b6
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
cltq
imulq $0x18, %rax, %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
addl $0x1, %edx
callq 0x52d10
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %esi
movl -0x30(%rbp), %edx
movl -0x40(%rbp), %ecx
subl -0x30(%rbp), %ecx
movl -0x3c(%rbp), %r8d
subl -0x34(%rbp), %r8d
leaq -0x68(%rbp), %rdi
callq *%rax
movq -0x88(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, (%rax)
movq -0x60(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rcx
movq %rcx, 0x10(%rax)
movsd -0x48(%rbp), %xmm0
movsd 0x1d580(%rip), %xmm1    # 0xe29b8
ucomisd %xmm1, %xmm0
jbe 0xc5478
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
movsd 0x1d562(%rip), %xmm0    # 0xe29b8
ucomisd (%rax,%rcx,8), %xmm0
jb 0xc5478
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x10(%rax)
jmp 0xc5491
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x10(%rax)
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x38(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0xc54c7
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0xc54d8
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xc54da
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xc5365
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
cltq
imulq $0x18, %rax, %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
addl $0x1, %edx
callq 0x52d10
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %esi
movl -0x30(%rbp), %edx
movl -0x40(%rbp), %ecx
subl -0x30(%rbp), %ecx
movl -0x3c(%rbp), %r8d
subl -0x34(%rbp), %r8d
leaq -0x80(%rbp), %rdi
callq *%rax
movq -0x90(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)