// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/plot.c
// Function: plotgauss
void plotgauss(char* names)
{
 /*!Last Changed 20.09.2006*/
 /*!Last Changed 07.10.2004 added img.xaxis.lim and img.yaxis.lim*/
 /*!Last Changed 02.02.2004 added safemalloc*/
 double obs, sum, divisionx, startx;
 double means;
 double variances;
 double* observations = NULL;
 Point p1, p2;
 char st2[3], *legendname;
 FILE* myfile;
 int datacount, j, color;
 Objectptr obj;
 if (!get_parameter_o("hold"))
   clear_image();
 legendname = file_only_name(names);
 color = img.imagelegend.legendcount;
 add_legend((char)('A' + color), legendname);
 safe_free(legendname);
 datacount = 0;
 sum = 0;
 myfile = fopen(names, "r");
 if (!myfile)
   return;
 while (fscanf(myfile,"%lf\n",&obs)!=EOF)
  {
   datacount++;
   observations = alloc(observations,datacount*sizeof(double),datacount);
   observations[datacount-1]=obs;
   sum += obs;
  }
 if (datacount != 0)
   means = sum / datacount;
 else
   means = 0;
 sum = 0;
 for (j = 0;j < datacount;j++)
   sum += (observations[j] - means) * (observations[j] - means);
 if (datacount > 1)
   variances = sqrt(sum / (datacount - 1));
 else
   variances = 0;
 safe_free(observations);
 fclose(myfile);
 img.yaxis.available = 0;
 img.height = (img.imagelegend.legendcount + 1) * 20 + MARGIN + 20;
 if (img.yaxis.lim.min > img.yaxis.lim.max)
  {
   img.yaxis.lim.min = 0;
   img.yaxis.lim.max = 1;
  }
 divisionx = variances * 6 / PARTITIONS;
 startx = means - 3 * variances;
 p1.x = startx;
 p1.y = gaussian(p1.x, means, variances);
 sprintf(st2, "%c", 'A' + color);
 for (j = 1; j < PARTITIONS; j++)
  {
   p2.x = startx + divisionx * j;
   p2.y = gaussian(p1.x, means, variances);
   obj = add_object(OBJECT_LINE, p1, p2, dummyp, st2);
   obj->fnt.fontcolor = color;
   p1.x = p2.x;
   p1.y = p2.y;
  }
 export_image();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
leaq 0x4a334(%rip), %rdi     # 0x9a6e5
callq 0x4cff1
testl %eax, %eax
jne 0x503c1
xorl %eax, %eax
callq 0x2a510
movq %rbx, %rdi
callq 0x34033
movq %rax, %r14
leaq 0x359ce5(%rip), %rax    # 0x3aa0b8
movl 0xec(%rax), %r15d
leal 0x41(%r15), %ebp
movsbl %bpl, %edi
movq %r14, %rsi
callq 0x28ee8
movq %r14, %rdi
callq 0x34ff7
leaq 0x4b486(%rip), %rsi     # 0x9b87f
movq %rbx, %rdi
callq 0x40f0
testq %rax, %rax
je 0x5065c
movq %rax, %rbx
movl %ebp, 0x20(%rsp)
movq %r15, 0x38(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x8
popq %r15
pushq $0x1
popq %rbp
leaq 0x60(%rsp), %r13
xorl %r12d, %r12d
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0x4a830(%rip), %rsi     # 0x9ac6c
movq %r13, %rdx
xorl %eax, %eax
callq 0x4070
cmpl $-0x1, %eax
je 0x50483
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x34f30
movq %rax, %r14
movsd 0x60(%rsp), %xmm0
movsd %xmm0, -0x8(%rax,%r15)
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
decq %r12
addq $0x8, %r15
incl %ebp
jmp 0x50432
movq %r12, %rax
negq %rax
cvtsi2sd %eax, %xmm0
movsd 0x8(%rsp), %xmm2
divsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
movq 0x38(%rsp), %r15
movl 0x20(%rsp), %ebp
cmpq %rcx, %rax
je 0x504c2
movsd (%r14,%rcx,8), %xmm1
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rcx
jmp 0x504a6
xorpd %xmm1, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd %xmm1, 0x18(%rsp)
testq %r12, %r12
je 0x504dd
movsd %xmm2, 0x18(%rsp)
cmpq $0x2, %rax
jb 0x5050a
notl %r12d
cvtsi2sd %r12d, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x504ff
sqrtsd %xmm0, %xmm0
jmp 0x50504
callq 0x4300
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0x34ff7
movq %rbx, %rdi
callq 0x42a0
leaq 0x359b97(%rip), %rcx    # 0x3aa0b8
andl $0x0, 0x78(%rcx)
imull $0x14, 0xec(%rcx), %eax
addl $0x78, %eax
movl %eax, (%rcx)
movsd 0x80(%rcx), %xmm0
ucomisd 0x88(%rcx), %xmm0
jbe 0x50557
xorpd %xmm0, %xmm0
movhpd 0x44fd1(%rip), %xmm0    # xmm0 = xmm0[0],mem[0]
movupd %xmm0, 0x80(%rcx)
movsd 0x47739(%rip), %xmm0    # 0x97c98
movsd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
divsd 0x47827(%rip), %xmm0    # 0x97d98
movsd %xmm0, 0x40(%rsp)
movsd 0x4a611(%rip), %xmm0    # 0x9ab90
mulsd %xmm2, %xmm0
movsd 0x18(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
callq 0x803b8
movapd %xmm0, %xmm1
leaq 0x35(%rsp), %rbx
movb %bpl, (%rbx)
movb $0x0, 0x1(%rbx)
movsd 0x44f70(%rip), %xmm2    # 0x95520
movl $0x1f3, %ebp            # imm = 0x1F3
movsd 0x28(%rsp), %xmm0
subl $0x1, %ebp
jb 0x50655
movsd 0x40(%rsp), %xmm3
mulsd %xmm2, %xmm3
addsd 0x28(%rsp), %xmm3
movsd %xmm3, 0x8(%rsp)
movsd %xmm2, 0x20(%rsp)
movsd %xmm1, 0x58(%rsp)
movsd 0x18(%rsp), %xmm1
movsd %xmm0, 0x48(%rsp)
movsd 0x10(%rsp), %xmm2
callq 0x803b8
movaps %xmm0, %xmm3
movsd %xmm0, 0x50(%rsp)
movsd 0x7ca62(%rip), %xmm4    # 0xcd070
movsd 0x7ca62(%rip), %xmm5    # 0xcd078
xorl %edi, %edi
movsd 0x48(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
movq %rbx, %rsi
callq 0x28f8d
movsd 0x20(%rsp), %xmm2
movl %r15d, 0x18(%rax)
addsd 0x44edc(%rip), %xmm2    # 0x95520
movsd 0x8(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
jmp 0x505bb
xorl %eax, %eax
callq 0x2a858
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq