// File: /workspace/github_c_makefile_star2_O3/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 0x5195a(%rip), %rdi     # 0xaa7b5
callq 0x54bec
testl %eax, %eax
jne 0x58e6b
xorl %eax, %eax
callq 0x2e342
testl %ebx, %ebx
movl %ebx, 0x1c(%rsp)
jle 0x5916f
movl %ebx, %eax
movq %rax, 0x30(%rsp)
movsd 0x4c692(%rip), %xmm0    # 0xa5518
movsd %xmm0, 0x10(%rsp)
movsd 0x4c67c(%rip), %xmm0    # 0xa5510
movsd %xmm0, 0x8(%rsp)
leaq 0x52aba(%rip), %r15     # 0xab95b
leaq 0x51e94(%rip), %r12     # 0xaad3c
leaq 0x28(%rsp), %r13
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
movq %r15, %rsi
callq 0x40f0
testq %rax, %rax
je 0x59158
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x4070
cmpl $-0x1, %eax
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
je 0x58f27
movsd 0x28(%rsp), %xmm2
movapd %xmm2, %xmm3
maxsd %xmm1, %xmm3
movsd %xmm3, 0x10(%rsp)
minsd %xmm0, %xmm2
movsd %xmm2, 0x8(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x4070
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
cmpl $-0x1, %eax
jne 0x58ee8
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, 0x10(%rsp)
movq %rbp, %rdi
callq 0x42a0
incq %rbx
cmpq 0x30(%rsp), %rbx
jne 0x58eaf
leaq 0x359168(%rip), %rax    # 0x3b20b8
movl 0xa8(%rax), %ebp
cmpl $0x0, 0x1c(%rsp)
jle 0x5917c
movsd 0x8(%rsp), %xmm0
subsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
leaq 0x51dc2(%rip), %r12     # 0xaad3c
leaq 0x28(%rsp), %r13
xorl %ebx, %ebx
movq %r14, 0x20(%rsp)
movq (%r14,%rbx,8), %rdi
leaq 0x529ca(%rip), %rsi     # 0xab95b
callq 0x40f0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movapd %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
testq %rax, %rax
je 0x59158
movq %rax, %r15
xorl %r14d, %r14d
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x4070
cmpl $-0x1, %eax
je 0x5903b
xorl %r14d, %r14d
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jne 0x58fed
jnp 0x5901a
movsd 0x28(%rsp), %xmm0
subsd %xmm1, %xmm0
mulsd 0x4edb9(%rip), %xmm0    # 0xa7db8
divsd 0x58(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl $0x9, %ecx
cmpl $0xa, %eax
je 0x59015
movl %eax, %ecx
movslq %ecx, %rax
jmp 0x5901f
movl $0x5, %eax
incl 0x60(%rsp,%rax,4)
incl %r14d
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x4070
cmpl $-0x1, %eax
jne 0x58fd9
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x50(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x48(%rsp)
movq %r15, %rdi
callq 0x42a0
xorl %ecx, %ecx
movl 0x60(%rsp,%rcx,4), %eax
leal (%rax,%rax), %edx
shll $0x5, %eax
subl %edx, %eax
cltd
idivl %r14d
addb $0x30, %al
movb %al, 0x3d(%rsp,%rcx)
incq %rcx
cmpq $0xa, %rcx
jne 0x5905f
movb $0x0, 0x47(%rsp)
movl $0x5, %edi
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
movsd 0x48(%rsp), %xmm3
leaq 0x3d(%rsp), %rsi
callq 0x2cc6c
leaq 0x359007(%rip), %r14    # 0x3b20b8
movl 0xa8(%r14), %ebp
testl %ebp, %ebp
je 0x590c4
incq %rbx
jmp 0x59146
movq 0x20(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x38b30
movq %rax, %r15
movq %rax, %rdi
movl $0x2d, %esi
callq 0x4220
movq %rax, %rbp
movq 0x30(%r14), %rdi
leaq 0x1(%rbx), %r14
leaq 0x8(,%rbx,8), %rsi
movl %r14d, %edx
callq 0x3a0b4
leaq 0x358fb4(%rip), %rcx    # 0x3b20b8
movq %rax, 0x30(%rcx)
leaq 0x1(%rbp), %rsi
testq %rbp, %rbp
movq (%rax,%rbx,8), %rdi
leaq 0x51bd9(%rip), %rax     # 0xaacf3
cmoveq %rax, %rsi
callq 0x3b494
leaq 0x358f8e(%rip), %rdx    # 0x3b20b8
movq 0x30(%rdx), %rcx
movq %rdx, %rbp
movq %rax, (%rcx,%rbx,8)
movq %r15, %rdi
callq 0x3a180
movl 0xa8(%rbp), %ebp
movq %r14, %rbx
movq 0x20(%rsp), %r14
cmpq 0x30(%rsp), %rbx
jne 0x58f86
jmp 0x5917c
movq (%r14,%rbx,8), %rsi
leaq 0x4d0a7(%rip), %rdi     # 0xa620a
xorl %eax, %eax
callq 0x4030
jmp 0x5925c
leaq 0x358f42(%rip), %rax    # 0x3b20b8
movl 0xa8(%rax), %ebp
movq %r14, %rbx
leaq 0x358f32(%rip), %r14    # 0x3b20b8
movq 0xa0(%r14), %rdi
movslq %ebp, %rax
incl %ebp
leaq 0x8(,%rax,8), %rsi
movl %ebp, %edx
callq 0x3a0b4
movq %rax, 0xa0(%r14)
movq (%rbx), %rdi
callq 0x38b30
movq %rax, %rbx
movq 0xa0(%r14), %rax
movslq 0xa8(%r14), %rcx
movq (%rax,%rcx,8), %rdi
movq %rbx, %rsi
callq 0x3b494
movq 0xa0(%r14), %rcx
movslq 0xa8(%r14), %rdx
movq %rax, (%rcx,%rdx,8)
movq %rbx, %rdi
callq 0x3a180
movl 0x1c(%rsp), %esi
movl %esi, 0x38(%r14)
movl 0xa8(%r14), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0xa8(%r14)
movl %esi, 0x20(%r14)
xorl %edx, %edx
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movq %rdx, 0x10(%r14)
movsd %xmm0, 0x18(%r14)
movabsq $0x100000000, %rsi      # imm = 0x100000000
movq %rsi, 0x24(%r14)
movl $0x1, 0x98(%r14)
movl %ecx, 0x90(%r14)
movq %rdx, 0x80(%r14)
leal 0x2(%rax,%rax), %eax
leal (%rax,%rax,4), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x88(%r14)
xorl %eax, %eax
callq 0x2e6d0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq