// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/libmisc.c
// Function: find_mse_and_sse
void find_mse_and_sse(char* inname, char* outname1, char* outname2)
{
 /*!Last Changed 18.12.2004*/
 FILE* infile;
 FILE* outfile1, *outfile2;
 char buffer[450000];
 char number[10];
 double numbers[5000], meansum, msesum, ssesum;
 int read, i, j, k, count, totalread, first = 1;
 infile = fopen(inname, "r");
 if (!infile)
   return;
 outfile1 = fopen(outname1, "w");
 if (!outfile1)
   return;
 outfile2 = fopen(outname2, "w");
 if (!outfile2)
   return;
 read = fread(buffer, 1, 450000, infile);
 i = 0;
 j = 0;
 totalread = -1;
 while (i < read)
  {
   if (buffer[i] != 10)
    {
     number[j] = buffer[i];
     j++;
    }
   else
    {
     number[j] = 0;
     j = 0;
     if (totalread == -1)
      {
       count = atoi(number);
       totalread = 0;
       meansum = 0;
       msesum = 0;
      }
     else
      {
       numbers[totalread] = (double) atof(number);
       meansum += numbers[totalread];
       msesum += numbers[totalread] * numbers[totalread];
       totalread++;
       if (totalread == count)
        {
         if (first)
           fprintf(outfile2, "%d\n", count);
         fprintf(outfile1, "%5.4f\n", msesum / count);
         ssesum = 0;
         meansum /= count;
         for (k = 0; k < count; k++)
           ssesum += (numbers[k] - meansum) * (numbers[k] - meansum);
         fprintf(outfile2, "%5.4f\n", ssesum / (count - 1));
         totalread = -1;
         first = 0;
        }
      }   
    }
   i++;
  }
 fclose(infile);
 fclose(outfile1);
 fclose(outfile2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x77a90, %rsp          # imm = 0x77A90
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x1, -0x77a84(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x93fea(%rip), %rsi     # 0xe81a6
callq 0x40c0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x541d1
jmp 0x544e4
movq -0x10(%rbp), %rdi
leaq 0x93fe2(%rip), %rsi     # 0xe81be
callq 0x40c0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x541f1
jmp 0x544e4
movq -0x18(%rbp), %rdi
leaq 0x93fc2(%rip), %rsi     # 0xe81be
callq 0x40c0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x54211
jmp 0x544e4
leaq -0x6de00(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl $0x1, %esi
movl $0x6ddd0, %edx          # imm = 0x6DDD0
callq 0x41e0
movl %eax, -0x77a6c(%rbp)
movl $0x0, -0x77a70(%rbp)
movl $0x0, -0x77a74(%rbp)
movl $0xffffffff, -0x77a80(%rbp) # imm = 0xFFFFFFFF
movl -0x77a70(%rbp), %eax
cmpl -0x77a6c(%rbp), %eax
jge 0x544c9
movslq -0x77a70(%rbp), %rax
movsbl -0x6de00(%rbp,%rax), %eax
cmpl $0xa, %eax
je 0x542a5
movslq -0x77a70(%rbp), %rax
movb -0x6de00(%rbp,%rax), %cl
movslq -0x77a74(%rbp), %rax
movb %cl, -0x6de0a(%rbp,%rax)
movl -0x77a74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x77a74(%rbp)
jmp 0x544b5
movslq -0x77a74(%rbp), %rax
movb $0x0, -0x6de0a(%rbp,%rax)
movl $0x0, -0x77a74(%rbp)
cmpl $-0x1, -0x77a80(%rbp)
jne 0x542fe
leaq -0x6de0a(%rbp), %rdi
callq 0x41c0
movl %eax, -0x77a7c(%rbp)
movl $0x0, -0x77a80(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x77a58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x77a60(%rbp)
jmp 0x544b3
leaq -0x6de0a(%rbp), %rdi
callq 0x4100
movslq -0x77a80(%rbp), %rax
movsd %xmm0, -0x77a50(%rbp,%rax,8)
movslq -0x77a80(%rbp), %rax
movsd -0x77a50(%rbp,%rax,8), %xmm0
addsd -0x77a58(%rbp), %xmm0
movsd %xmm0, -0x77a58(%rbp)
movslq -0x77a80(%rbp), %rax
movsd -0x77a50(%rbp,%rax,8), %xmm0
movslq -0x77a80(%rbp), %rax
movsd -0x77a50(%rbp,%rax,8), %xmm2
movsd -0x77a60(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x77a60(%rbp)
movl -0x77a80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x77a80(%rbp)
movl -0x77a80(%rbp), %eax
cmpl -0x77a7c(%rbp), %eax
jne 0x544b1
cmpl $0x0, -0x77a84(%rbp)
je 0x543b4
movq -0x30(%rbp), %rdi
movl -0x77a7c(%rbp), %edx
leaq 0x988a4(%rip), %rsi     # 0xecc51
movb $0x0, %al
callq 0x4280
movq -0x28(%rbp), %rdi
movsd -0x77a60(%rbp), %xmm0
cvtsi2sdl -0x77a7c(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq 0x92354(%rip), %rsi     # 0xe6727
movb $0x1, %al
callq 0x4280
xorps %xmm0, %xmm0
movsd %xmm0, -0x77a68(%rbp)
cvtsi2sdl -0x77a7c(%rbp), %xmm1
movsd -0x77a58(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x77a58(%rbp)
movl $0x0, -0x77a78(%rbp)
movl -0x77a78(%rbp), %eax
cmpl -0x77a7c(%rbp), %eax
jge 0x54472
movslq -0x77a78(%rbp), %rax
movsd -0x77a50(%rbp,%rax,8), %xmm0
subsd -0x77a58(%rbp), %xmm0
movslq -0x77a78(%rbp), %rax
movsd -0x77a50(%rbp,%rax,8), %xmm2
subsd -0x77a58(%rbp), %xmm2
movsd -0x77a68(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x77a68(%rbp)
movl -0x77a78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x77a78(%rbp)
jmp 0x5440b
movq -0x30(%rbp), %rdi
movsd -0x77a68(%rbp), %xmm0
movl -0x77a7c(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
leaq 0x92291(%rip), %rsi     # 0xe6727
movb $0x1, %al
callq 0x4280
movl $0xffffffff, -0x77a80(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x77a84(%rbp)
jmp 0x544b3
jmp 0x544b5
movl -0x77a70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x77a70(%rbp)
jmp 0x5424f
movq -0x20(%rbp), %rdi
callq 0x4250
movq -0x28(%rbp), %rdi
callq 0x4250
movq -0x30(%rbp), %rdi
callq 0x4250
addq $0x77a90, %rsp          # imm = 0x77A90
popq %rbp
retq
nopl (%rax)