// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %rdi, %rbx
leaq 0x50b8b(%rip), %rdi     # 0xa7715
callq 0x536e7
testl %eax, %eax
jne 0x56b9a
xorl %eax, %eax
callq 0x2da74
movq %rbx, %rdi
callq 0x37f08
movq %rax, %r14
leaq 0x35850c(%rip), %r12    # 0x3af0b8
movl 0xec(%r12), %r15d
leal 0x41(%r15), %ebp
movsbl %bpl, %edi
movq %rax, %rsi
callq 0x2c324
movq %r14, %rdi
callq 0x39194
leaq 0x51cbc(%rip), %rsi     # 0xa888f
movq %rbx, %rdi
callq 0x40f0
testq %rax, %rax
je 0x56e78
leaq 0x510a1(%rip), %rsi     # 0xa7c8c
xorl %ebx, %ebx
leaq 0x20(%rsp), %rdx
movq %rax, 0x8(%rsp)
movq %rax, %rdi
xorl %eax, %eax
callq 0x4070
xorpd %xmm0, %xmm0
cmpl $-0x1, %eax
je 0x56c9b
movl %ebp, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movsd %xmm0, (%rsp)
movl $0x8, %r12d
leaq 0x20(%rsp), %rbp
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x8(%rsp), %r13
movq %rbx, %r15
incq %rbx
movq %r14, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x390c8
movq %rax, %r14
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax,%r15,8)
movsd (%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rsp)
movq %r13, %rdi
leaq 0x5101f(%rip), %rsi     # 0xa7c8c
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4070
addq $0x8, %r12
cmpl $-0x1, %eax
jne 0x56c31
movq 0x18(%rsp), %r15
movl 0x10(%rsp), %ebp
leaq 0x358428(%rip), %r12    # 0x3af0b8
xorpd %xmm0, %xmm0
movsd (%rsp), %xmm2
jmp 0x56ca2
xorl %r14d, %r14d
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
testl %ebx, %ebx
je 0x56cb9
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
divsd %xmm1, %xmm2
movapd %xmm2, %xmm1
je 0x56cd9
movl %ebx, %eax
xorl %ecx, %ecx
movsd (%r14,%rcx,8), %xmm2
subsd %xmm1, %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rcx
cmpq %rcx, %rax
jne 0x56cbf
movsd %xmm1, 0x38(%rsp)
xorpd %xmm1, %xmm1
cmpl $0x2, %ebx
jb 0x56d11
decl %ebx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x56d08
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x56d11
callq 0x4300
movapd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
movq %r14, %rdi
callq 0x39194
movq 0x8(%rsp), %rdi
callq 0x42a0
movl $0x0, 0x78(%r12)
movl 0xec(%r12), %eax
leal (%rax,%rax,4), %eax
leal 0x78(,%rax,4), %eax
movl %eax, (%r12)
movsd 0x80(%r12), %xmm0
ucomisd 0x88(%r12), %xmm0
jbe 0x56d7c
movq $0x0, 0x80(%r12)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x88(%r12)
movsd 0x4deec(%rip), %xmm0    # 0xa4c70
movsd 0x30(%rsp), %xmm2
mulsd %xmm2, %xmm0
divsd 0x4dffa(%rip), %xmm0    # 0xa4d90
movsd %xmm0, 0x48(%rsp)
movsd 0x50e0c(%rip), %xmm0    # 0xa7bb0
mulsd %xmm2, %xmm0
movsd 0x38(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
callq 0x8b5f2
movapd %xmm0, %xmm1
leaq 0x45(%rsp), %rbx
movb %bpl, (%rbx)
movb $0x0, 0x1(%rbx)
movsd 0x4b74b(%rip), %xmm3    # 0xa2520
movl $0x1f3, %ebp            # imm = 0x1F3
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd %xmm1, 0x10(%rsp)
movsd %xmm3, 0x8(%rsp)
movsd 0x48(%rsp), %xmm2
mulsd %xmm3, %xmm2
addsd 0x28(%rsp), %xmm2
movsd %xmm2, (%rsp)
movsd 0x38(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
callq 0x8b5f2
movaps %xmm0, %xmm3
movsd %xmm0, 0x18(%rsp)
movsd 0x7b247(%rip), %xmm4    # 0xd2070
movsd 0x7b247(%rip), %xmm5    # 0xd2078
xorl %edi, %edi
movsd 0x50(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd (%rsp), %xmm2
movq %rbx, %rsi
callq 0x2c3cc
movsd 0x8(%rsp), %xmm3
movl %r15d, 0x18(%rax)
addsd 0x4b6c2(%rip), %xmm3    # 0xa2520
movsd 0x18(%rsp), %xmm1
movsd (%rsp), %xmm0
decl %ebp
jne 0x56de0
xorl %eax, %eax
callq 0x2de4a
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq