// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/plot.c
// Function: histogram_plot
void histogram_plot(char* filename, int bincount)
{
 /*!Last Changed 11.10.2010*/
 Point p1, p2;
 char st[MAXLENGTH], pst[READLINELENGTH];
 double prev, max = -INT_MAX, min = +INT_MAX, obs, binwidth, *observations, *distinct_observations = NULL;
 FILE* myfile;
 int i, j, bin, *counts, filesize = file_length(filename), distinctcount;
 observations = safemalloc(filesize * sizeof(double), "histogram_plot", 20);
 if (!get_parameter_o("hold"))
   clear_image();
 myfile = fopen(filename, "r");
 if (!myfile)
  {
   printf(m1274, filename);
   return;
  }
 i = 0;
 while (fscanf(myfile, "%lf\n", &obs) != EOF)
  {
   if (obs > max)
     max = obs;
   if (obs < min)
     min = obs;
   observations[i] = obs;
   i++;
  }
 fclose(myfile);
 if (bincount == 0)
  {
   qsort(observations, filesize, sizeof(double), sort_function_double_ascending);
   distinctcount = 1;
   prev = observations[0];
   for (i = 1; i < filesize; i++)
     if (observations[i] != prev)
      {
       prev = observations[i];
       distinctcount++;
      }
   distinct_observations = safemalloc(distinctcount * sizeof(double), "histogram_plot", 35);
   counts = safecalloc(distinctcount, sizeof(int), "histogram_plot", 36);
   distinct_observations[0] = observations[0];
   prev = observations[0];
   counts[0] = 1;
   j = 0;
   for (i = 1; i < filesize; i++)
     if (observations[i] != prev)
      {
       j++;
       distinct_observations[j] = observations[i];
       prev = observations[i];
       counts[j] = 1;
      }
     else
       counts[j]++;
  }
 else
  {
   counts = safecalloc(bincount, sizeof(int), "histogram_plot", 3);
   binwidth = (max - min) / bincount;
   for (i = 0; i < filesize; i++)
    {
     bin = (int)((observations[i] - min) / binwidth);
     if (bin == bincount)
       bin--;
      counts[bin]++;
    }
  }
 img.xaxis.limitsset = 1;
 if (bincount != 0)
   img.xaxis.namesavailable = bincount;
 else 
   img.xaxis.namesavailable = distinctcount;
 img.xaxis.lim.division = img.xaxis.namesavailable;
 img.xaxis.lim.min = 0;
 img.xaxis.lim.max = img.xaxis.namesavailable;
 img.xaxis.lim.precision = 0;
 if (bincount != 0)
   img.xaxis.names = safemalloc(bincount * sizeof(char*), "histogram_plot", 24); 
 else 
   img.xaxis.names = safemalloc(distinctcount * sizeof(char*), "histogram_plot", 24); 
 img.yaxis.limitsset = 1;
 img.yaxis.lim.division = 10;
 img.yaxis.lim.min = 0;
 if (bincount != 0)
   img.yaxis.lim.max = counts[find_max_in_list(counts, bincount)];
 else
   img.yaxis.lim.max = counts[find_max_in_list(counts, distinctcount)];  
 img.yaxis.namesavailable = 0;
 img.yaxis.lim.precision = 0;
 if (bincount != 0)
  {
   for (i = 0; i < bincount; i++)
    {
     set_precision(pst, NULL, NULL);
     sprintf(st, pst, min + binwidth * i);  
     img.xaxis.names[i] = strcopy(img.xaxis.names[i], st);
     p1.x = i;
     p1.y = MARGIN;
     p2.x = 0;
     p2.y = counts[i];
     add_object(OBJECT_RECTANGLE, p1, p2, dummyp, "");
    }
  }
 else 
  {
   for (i = 0; i < distinctcount; i++)
    {
     set_precision(pst, NULL, NULL);
     sprintf(st, pst, distinct_observations[i]);  
     img.xaxis.names[i] = strcopy(img.xaxis.names[i], st);
     p1.x = i;
     p1.y = MARGIN;
     p2.x = 0;
     p2.y = counts[i];
     add_object(OBJECT_RECTANGLE, p1, p2, dummyp, "");
    }
   safe_free(distinct_observations);
  }
 safe_free(observations);
 safe_free(counts);
 export_image();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf42e0, %rsp          # imm = 0xF42E0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movsd 0x63abe(%rip), %xmm0    # 0xe2008
movsd %xmm0, -0xf4280(%rbp)
movsd 0x63ab6(%rip), %xmm0    # 0xe2010
movsd %xmm0, -0xf4288(%rbp)
movq $0x0, -0xf42a8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x50f90
movl %eax, -0xf42cc(%rbp)
movslq -0xf42cc(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x691b6(%rip), %rsi     # 0xe7744
movl $0x14, %edx
callq 0x52d70
movq %rax, -0xf42a0(%rbp)
leaq 0x68d62(%rip), %rdi     # 0xe7308
callq 0x79440
cmpl $0x0, %eax
jne 0x7e5b7
movb $0x0, %al
callq 0x41a40
movq -0x8(%rbp), %rdi
leaq 0x69be4(%rip), %rsi     # 0xe81a6
callq 0x40c0
movq %rax, -0xf42b0(%rbp)
cmpq $0x0, -0xf42b0(%rbp)
jne 0x7e5ef
movq -0x8(%rbp), %rsi
leaq 0x648a7(%rip), %rdi     # 0xe2e8a
movb $0x0, %al
callq 0x4030
jmp 0x7ed9f
movl $0x0, -0xf42b4(%rbp)
movq -0xf42b0(%rbp), %rdi
leaq 0x6919f(%rip), %rsi     # 0xe77a6
leaq -0xf4290(%rbp), %rdx
movb $0x0, %al
callq 0x4070
cmpl $-0x1, %eax
je 0x7e691
movsd -0xf4290(%rbp), %xmm0
ucomisd -0xf4280(%rbp), %xmm0
jbe 0x7e63c
movsd -0xf4290(%rbp), %xmm0
movsd %xmm0, -0xf4280(%rbp)
movsd -0xf4290(%rbp), %xmm1
movsd -0xf4288(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7e662
movsd -0xf4290(%rbp), %xmm0
movsd %xmm0, -0xf4288(%rbp)
movsd -0xf4290(%rbp), %xmm0
movq -0xf42a0(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0xf42b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf42b4(%rbp)
jmp 0x7e5f9
movq -0xf42b0(%rbp), %rdi
callq 0x4250
cmpl $0x0, -0xc(%rbp)
jne 0x7e8b6
movq -0xf42a0(%rbp), %rdi
movslq -0xf42cc(%rbp), %rsi
movl $0x8, %edx
leaq -0x2b201(%rip), %rcx    # 0x534c0
callq 0x41f0
movl $0x1, -0xf42d0(%rbp)
movq -0xf42a0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xf4278(%rbp)
movl $0x1, -0xf42b4(%rbp)
movl -0xf42b4(%rbp), %eax
cmpl -0xf42cc(%rbp), %eax
jge 0x7e759
movq -0xf42a0(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd -0xf4278(%rbp), %xmm0
jne 0x7e71c
jp 0x7e71c
jmp 0x7e746
movq -0xf42a0(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xf4278(%rbp)
movl -0xf42d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf42d0(%rbp)
jmp 0x7e748
movl -0xf42b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf42b4(%rbp)
jmp 0x7e6ed
movslq -0xf42d0(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x68fd9(%rip), %rsi     # 0xe7744
movl $0x23, %edx
callq 0x52d70
movq %rax, -0xf42a8(%rbp)
movslq -0xf42d0(%rbp), %rdi
movl $0x4, %esi
leaq 0x68fb5(%rip), %rdx     # 0xe7744
movl $0x24, %ecx
callq 0x52f40
movq %rax, -0xf42c8(%rbp)
movq -0xf42a0(%rbp), %rax
movsd (%rax), %xmm0
movq -0xf42a8(%rbp), %rax
movsd %xmm0, (%rax)
movq -0xf42a0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xf4278(%rbp)
movq -0xf42c8(%rbp), %rax
movl $0x1, (%rax)
movl $0x0, -0xf42b8(%rbp)
movl $0x1, -0xf42b4(%rbp)
movl -0xf42b4(%rbp), %eax
cmpl -0xf42cc(%rbp), %eax
jge 0x7e8b1
movq -0xf42a0(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd -0xf4278(%rbp), %xmm0
jne 0x7e81d
jp 0x7e81d
jmp 0x7e884
movl -0xf42b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf42b8(%rbp)
movq -0xf42a0(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0xf42a8(%rbp), %rax
movslq -0xf42b8(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0xf42a0(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xf4278(%rbp)
movq -0xf42c8(%rbp), %rax
movslq -0xf42b8(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x7e89b
movq -0xf42c8(%rbp), %rax
movslq -0xf42b8(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x7e89d
movl -0xf42b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf42b4(%rbp)
jmp 0x7e7ea
jmp 0x7e981
movslq -0xc(%rbp), %rdi
movl $0x4, %esi
leaq 0x68e7e(%rip), %rdx     # 0xe7744
movl $0x3, %ecx
callq 0x52f40
movq %rax, -0xf42c8(%rbp)
movsd -0xf4280(%rbp), %xmm0
subsd -0xf4288(%rbp), %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xf4298(%rbp)
movl $0x0, -0xf42b4(%rbp)
movl -0xf42b4(%rbp), %eax
cmpl -0xf42cc(%rbp), %eax
jge 0x7e97f
movq -0xf42a0(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
subsd -0xf4288(%rbp), %xmm0
divsd -0xf4298(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xf42bc(%rbp)
movl -0xf42bc(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x7e957
movl -0xf42bc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xf42bc(%rbp)
movq -0xf42c8(%rbp), %rax
movslq -0xf42bc(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0xf42b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf42b4(%rbp)
jmp 0x7e902
jmp 0x7e981
leaq 0x363700(%rip), %rax    # 0x3e2088
movl $0x1, 0x28(%rax)
cmpl $0x0, -0xc(%rbp)
je 0x7e9a4
movl -0xc(%rbp), %ecx
leaq 0x3636e9(%rip), %rax    # 0x3e2088
movl %ecx, 0x38(%rax)
jmp 0x7e9b4
movl -0xf42d0(%rbp), %ecx
leaq 0x3636d7(%rip), %rax    # 0x3e2088
movl %ecx, 0x38(%rax)
leaq 0x3636cd(%rip), %rax    # 0x3e2088
movl 0x38(%rax), %ecx
leaq 0x3636c3(%rip), %rax    # 0x3e2088
movl %ecx, 0x20(%rax)
leaq 0x3636b9(%rip), %rax    # 0x3e2088
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rax)
leaq 0x3636aa(%rip), %rax    # 0x3e2088
cvtsi2sdl 0x38(%rax), %xmm0
leaq 0x36369e(%rip), %rax    # 0x3e2088
movsd %xmm0, 0x18(%rax)
leaq 0x363692(%rip), %rax    # 0x3e2088
movl $0x0, 0x24(%rax)
cmpl $0x0, -0xc(%rbp)
je 0x7ea2c
movslq -0xc(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x68d32(%rip), %rsi     # 0xe7744
movl $0x18, %edx
callq 0x52d70
movq %rax, %rcx
leaq 0x363662(%rip), %rax    # 0x3e2088
movq %rcx, 0x30(%rax)
jmp 0x7ea56
movslq -0xf42d0(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x68d06(%rip), %rsi     # 0xe7744
movl $0x18, %edx
callq 0x52d70
movq %rax, %rcx
leaq 0x363636(%rip), %rax    # 0x3e2088
movq %rcx, 0x30(%rax)
leaq 0x36362b(%rip), %rax    # 0x3e2088
movl $0x1, 0x98(%rax)
leaq 0x36361a(%rip), %rax    # 0x3e2088
movl $0xa, 0x90(%rax)
leaq 0x363609(%rip), %rax    # 0x3e2088
xorps %xmm0, %xmm0
movsd %xmm0, 0x80(%rax)
cmpl $0x0, -0xc(%rbp)
je 0x7eacf
movq -0xf42c8(%rbp), %rax
movq %rax, -0xf42d8(%rbp)
movq -0xf42c8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x50070
movl %eax, %ecx
movq -0xf42d8(%rbp), %rax
movslq %ecx, %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
leaq 0x3635c3(%rip), %rax    # 0x3e2088
movsd %xmm0, 0x88(%rax)
jmp 0x7eb0f
movq -0xf42c8(%rbp), %rax
movq %rax, -0xf42e0(%rbp)
movq -0xf42c8(%rbp), %rdi
movl -0xf42d0(%rbp), %esi
callq 0x50070
movl %eax, %ecx
movq -0xf42e0(%rbp), %rax
movslq %ecx, %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
leaq 0x363581(%rip), %rax    # 0x3e2088
movsd %xmm0, 0x88(%rax)
leaq 0x363572(%rip), %rax    # 0x3e2088
movl $0x0, 0xa8(%rax)
leaq 0x363561(%rip), %rax    # 0x3e2088
movl $0x0, 0x94(%rax)
cmpl $0x0, -0xc(%rbp)
je 0x7ec5f
movl $0x0, -0xf42b4(%rbp)
movl -0xf42b4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x7ec5a
leaq -0xf4270(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x53310
leaq -0x7a150(%rbp), %rdi
leaq -0xf4270(%rbp), %rsi
movsd -0xf4288(%rbp), %xmm1
movsd -0xf4298(%rbp), %xmm0
cvtsi2sdl -0xf42b4(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movb $0x1, %al
callq 0x4170
leaq 0x3634e5(%rip), %rax    # 0x3e2088
movq 0x30(%rax), %rax
movslq -0xf42b4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x7a150(%rbp), %rsi
callq 0x54ba0
movq %rax, %rdx
leaq 0x3634c0(%rip), %rax    # 0x3e2088
movq 0x30(%rax), %rax
movslq -0xf42b4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cvtsi2sdl -0xf42b4(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd 0x65d9c(%rip), %xmm0    # 0xe4988
movsd %xmm0, -0x18(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0xf42c8(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x20(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
movsd -0x28(%rbp), %xmm3
movsd 0x86413(%rip), %xmm4    # 0x105040
movsd 0x86413(%rip), %xmm5    # 0x105048
movl $0x2, %edi
leaq 0x6f399(%rip), %rsi     # 0xedfda
callq 0x3f100
movl -0xf42b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf42b4(%rbp)
jmp 0x7eb45
jmp 0x7ed80
movl $0x0, -0xf42b4(%rbp)
movl -0xf42b4(%rbp), %eax
cmpl -0xf42d0(%rbp), %eax
jge 0x7ed74
leaq -0xf4270(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x53310
leaq -0x7a150(%rbp), %rdi
leaq -0xf4270(%rbp), %rsi
movq -0xf42a8(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movb $0x1, %al
callq 0x4170
leaq 0x3633cb(%rip), %rax    # 0x3e2088
movq 0x30(%rax), %rax
movslq -0xf42b4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x7a150(%rbp), %rsi
callq 0x54ba0
movq %rax, %rdx
leaq 0x3633a6(%rip), %rax    # 0x3e2088
movq 0x30(%rax), %rax
movslq -0xf42b4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cvtsi2sdl -0xf42b4(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd 0x65c82(%rip), %xmm0    # 0xe4988
movsd %xmm0, -0x18(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0xf42c8(%rbp), %rax
movslq -0xf42b4(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x20(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
movsd -0x28(%rbp), %xmm3
movsd 0x862f9(%rip), %xmm4    # 0x105040
movsd 0x862f9(%rip), %xmm5    # 0x105048
movl $0x2, %edi
leaq 0x6f27f(%rip), %rsi     # 0xedfda
callq 0x3f100
movl -0xf42b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf42b4(%rbp)
jmp 0x7ec69
movq -0xf42a8(%rbp), %rdi
callq 0x52e80
movq -0xf42a0(%rbp), %rdi
callq 0x52e80
movq -0xf42c8(%rbp), %rdi
callq 0x52e80
movb $0x0, %al
callq 0x42280
addq $0xf42e0, %rsp          # imm = 0xF42E0
popq %rbp
retq
nopl (%rax,%rax)