// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/plot.c
// Function: error_histogram_plot
void error_histogram_plot(char** names, int filecount)
{
 /*!Last Changed 27.12.2007*/
 int i, j, index, counts[10], count;
 Point p1, p2, p3;
 char* plotname, st2[11];
 char* pos;
 double obs, min = +INT_MAX, max = -INT_MAX;
 FILE* myfile;
 if (!get_parameter_o("hold"))
   clear_image();
 for (i = 0; i < filecount; i++)
  {
   myfile = fopen(names[i], "r");
   if (!myfile)
    {
     printf(m1274, names[i]);
     return;
    }
   while (fscanf(myfile, "%lf\n", &obs) != EOF)
    {
     if (obs > max)
       max = obs;
     if (obs < min)
       min = obs;
    }
   fclose(myfile);
  } 
 for (i = 0; i < filecount; i++)
  {
   p1.x = min;
   p1.y = max;
   p2.x = img.yaxis.namesavailable;
   p2.y = i;
   myfile = fopen(names[i], "r");
   for (j = 0; j < 10; j++)
     counts[j] = 0;
   if (!myfile)
    {
     printf(m1274, names[i]);
     return;
    }
   count = 0;
   while (fscanf(myfile, "%lf\n", &obs) != EOF)
    {
     if (max != min)
      {
       index = (int) (10 * (obs - min) / (max - min));
       if (index == 10)
         index--;
      }
     else
       index = 5;
     counts[index]++;
     count++;
    }
   fclose(myfile);
   for (j = 0; j < 10; j++)
     st2[j] = '0' + (30 * counts[j]) / count;
   st2[10] = '\0';
   add_object(OBJECT_ERRORHISTOGRAM, p1, p2, p3, st2);
   if (img.yaxis.namesavailable == 0)
    {
     plotname = file_only_name(names[i]);     
     pos = strchr(plotname, '-');
     img.xaxis.names = alloc(img.xaxis.names, (i + 1) * sizeof(char *), (i + 1)); 
     if (pos)
       img.xaxis.names[i] = strcopy(img.xaxis.names[i], (pos + 1));
     else
       img.xaxis.names[i] = strcopy(img.xaxis.names[i], "Try Again");
     safe_free(plotname);
    }   
  }
 img.yaxis.names = alloc(img.yaxis.names, (img.yaxis.namesavailable + 1) * sizeof(char *), (img.yaxis.namesavailable + 1));
 plotname = file_only_name(names[0]);
 img.yaxis.names[img.yaxis.namesavailable] = strcopy(img.yaxis.names[img.yaxis.namesavailable], plotname);
 safe_free(plotname);
 img.xaxis.namesavailable = filecount;
 img.yaxis.namesavailable++;
 img.xaxis.limitsset = 1;
 img.xaxis.lim.division = img.xaxis.namesavailable;
 img.xaxis.lim.min = 0;
 img.xaxis.lim.max = img.xaxis.namesavailable;
 img.xaxis.lim.precision = 0;
 img.yaxis.limitsset = 1;
 img.yaxis.lim.division = img.yaxis.namesavailable;
 img.yaxis.lim.min = 0;
 img.yaxis.lim.max = 10 * img.yaxis.namesavailable;
 export_image();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %esi, %ebx
movq %rdi, %r14
leaq 0x4fe56(%rip), %rdi     # 0xa7715
callq 0x536e7
testl %eax, %eax
jne 0x578cf
xorl %eax, %eax
callq 0x2da74
movl %ebx, %eax
movq %rax, 0x28(%rsp)
movl %ebx, 0x1c(%rsp)
testl %ebx, %ebx
jle 0x579af
movsd 0x4ac2e(%rip), %xmm0    # 0xa2518
movsd %xmm0, 0x10(%rsp)
movsd 0x4ac18(%rip), %xmm0    # 0xa2510
movsd %xmm0, 0x8(%rsp)
leaq 0x50f8a(%rip), %rbx     # 0xa888f
leaq 0x50380(%rip), %r15     # 0xa7c8c
leaq 0x20(%rsp), %r12
xorl %ebp, %ebp
movq (%r14,%rbp,8), %rdi
movq %rbx, %rsi
callq 0x40f0
testq %rax, %rax
je 0x57c94
movq %rax, %r13
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x4070
cmpl $-0x1, %eax
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
je 0x5798b
movsd 0x20(%rsp), %xmm2
movapd %xmm2, %xmm3
maxsd %xmm1, %xmm3
movsd %xmm3, 0x10(%rsp)
minsd %xmm0, %xmm2
movsd %xmm2, 0x8(%rsp)
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x4070
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
cmpl $-0x1, %eax
jne 0x5794c
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, 0x10(%rsp)
movq %r13, %rdi
callq 0x42a0
incq %rbp
cmpq 0x28(%rsp), %rbp
jne 0x57913
jmp 0x579cb
movsd 0x4ab59(%rip), %xmm0    # 0xa2510
movsd %xmm0, 0x8(%rsp)
movsd 0x4ab53(%rip), %xmm0    # 0xa2518
movsd %xmm0, 0x10(%rsp)
cmpl $0x0, 0x1c(%rsp)
jle 0x57bb2
movsd 0x8(%rsp), %xmm0
subsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
leaq 0x5029d(%rip), %r12     # 0xa7c8c
leaq 0x20(%rsp), %r13
xorl %r15d, %r15d
movq %r14, 0x40(%rsp)
leaq 0x3576b5(%rip), %rax    # 0x3af0b8
xorps %xmm0, %xmm0
cvtsi2sdl 0xa8(%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movq (%r14,%r15,8), %rdi
leaq 0x50e70(%rip), %rsi     # 0xa888f
callq 0x40f0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movapd %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
testq %rax, %rax
je 0x57c9a
movq %rax, %rbx
xorl %ebp, %ebp
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x4070
cmpl $-0x1, %eax
je 0x57ac6
xorl %ebp, %ebp
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jne 0x57a79
jnp 0x57aa6
movsd 0x20(%rsp), %xmm0
subsd %xmm1, %xmm0
mulsd 0x4d2a5(%rip), %xmm0    # 0xa4d30
divsd 0x58(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl $0x9, %ecx
cmpl $0xa, %eax
je 0x57aa1
movl %eax, %ecx
movslq %ecx, %rax
jmp 0x57aab
movl $0x5, %eax
incl 0x60(%rsp,%rax,4)
incl %ebp
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x4070
cmpl $-0x1, %eax
jne 0x57a65
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd %xmm0, 0x48(%rsp)
movq %rbx, %rdi
callq 0x42a0
xorl %ecx, %ecx
movl 0x60(%rsp,%rcx,4), %eax
leal (%rax,%rax), %edx
shll $0x5, %eax
subl %edx, %eax
cltd
idivl %ebp
addb $0x30, %al
movb %al, 0x35(%rsp,%rcx)
incq %rcx
cmpq $0xa, %rcx
jne 0x57ade
movb $0x0, 0x3f(%rsp)
movl $0x5, %edi
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
movsd 0x48(%rsp), %xmm3
leaq 0x35(%rsp), %rsi
callq 0x2c3cc
leaq 0x357589(%rip), %rax    # 0x3af0b8
cmpl $0x0, 0xa8(%rax)
jne 0x57ba4
movq (%r14,%r15,8), %rdi
callq 0x37f08
movq %rax, %rbx
movq %rax, %rdi
movl $0x2d, %esi
callq 0x4220
movq %rax, %rbp
leaq 0x35755d(%rip), %r14    # 0x3af0b8
movq 0x30(%r14), %rdi
leaq 0x1(%r15), %rdx
leaq 0x8(,%r15,8), %rsi
callq 0x390c8
movq %rax, 0x30(%r14)
leaq 0x1(%rbp), %rsi
testq %rbp, %rbp
movq (%rax,%r15,8), %rdi
leaq 0x500bd(%rip), %rax     # 0xa7c43
cmoveq %rax, %rsi
callq 0x3a404
movq 0x30(%r14), %rcx
movq 0x40(%rsp), %r14
movq %rax, (%rcx,%r15,8)
movq %rbx, %rdi
callq 0x39194
incq %r15
cmpq 0x28(%rsp), %r15
jne 0x579fc
leaq 0x3574ff(%rip), %r15    # 0x3af0b8
movq 0xa0(%r15), %rdi
movslq 0xa8(%r15), %rdx
leaq 0x8(,%rdx,8), %rsi
incq %rdx
callq 0x390c8
movq %rax, 0xa0(%r15)
movq (%r14), %rdi
callq 0x37f08
movq %rax, %rbx
movq 0xa0(%r15), %rax
movslq 0xa8(%r15), %rcx
movq (%rax,%rcx,8), %rdi
movq %rbx, %rsi
callq 0x3a404
movq 0xa0(%r15), %rcx
movslq 0xa8(%r15), %rdx
movq %rax, (%rcx,%rdx,8)
movq %rbx, %rdi
callq 0x39194
movl 0x1c(%rsp), %esi
movl %esi, 0x38(%r15)
movl 0xa8(%r15), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0xa8(%r15)
movl %esi, 0x20(%r15)
xorl %edx, %edx
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movq %rdx, 0x10(%r15)
movsd %xmm0, 0x18(%r15)
movabsq $0x100000000, %rsi      # imm = 0x100000000
movq %rsi, 0x24(%r15)
movl $0x1, 0x98(%r15)
movl %ecx, 0x90(%r15)
movq %rdx, 0x80(%r15)
leal 0x2(%rax,%rax), %eax
leal (%rax,%rax,4), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x88(%r15)
xorl %eax, %eax
callq 0x2de4a
jmp 0x57cac
movq (%r14,%rbp,8), %rsi
jmp 0x57c9e
movq (%r14,%r15,8), %rsi
leaq 0x4b565(%rip), %rdi     # 0xa320a
xorl %eax, %eax
callq 0x4030
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq