// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/plot.c
// Function: plotinvgauss
void plotinvgauss(char* names)
{
 /*!Last Changed 20.09.2006*/
 /*!Last Changed 26.12.2004 added aout1, aout2 array values*/
 /*!Last Changed 27.10.2004*/
 char varvalue[MAXLENGTH], pst[READLINELENGTH];
 char st[2], st2[3], *legendname;
 double *observations[2], mean, stdev;
 int datacount, j, color;
 Point p1, p2;
 FILE *infile;
 Objectptr obj;
 if (!get_parameter_o("hold"))
   clear_image();
 legendname = file_only_name(names);
 color = img.imagelegend.legendcount;
 st[0] = plots[color];
 st[1] = '\0';
 add_legend((char)('A' + color), legendname);
 safe_free(legendname);
 datacount = file_length(names);
 infile = fopen(names, "r");
 if (!infile)
   return;
 observations[0] = (double *)safemalloc(datacount * sizeof(double), "plotinvgauss", 13);
 observations[1] = (double *)safemalloc(datacount * sizeof(double), "plotinvgauss", 14);
 for (j = 0; j < datacount; j++)
   fscanf(infile, "%lf %lf", &(observations[0][j]), &(observations[1][j]));
 fclose(infile);
 for (j = 0; j < datacount; j++)
  {
   p1.x = (double) observations[0][j];
   check_x_range(p1);   
   p1.y = (double) observations[1][j];
   add_object(OBJECT_STRING, p1, dummyp, dummyp, st);
  }
 solve_inv_gauss(observations, datacount, img.xaxis.lim.min, img.xaxis.lim.max, 0, img.xaxis.lim.max - img.xaxis.lim.min, &mean, &stdev);
 set_precision(pst, NULL, NULL);
 sprintf(varvalue, pst, mean);
 set_variable("aout1[1]", varvalue);
 set_precision(pst, NULL, NULL);
 sprintf(varvalue, pst, stdev);
 set_variable("aout2[1]", varvalue);
 safe_free(observations[0]);
 safe_free(observations[1]);
 p1.x = img.xaxis.lim.min;
 p1.y = 1 - stdev * sqrt(2 * PI) * gaussian(p1.x, mean, stdev);
 sprintf(st2, "%c", 'A' + color); 
 for (j = 1; j < PARTITIONS; j++)
  {
   p2.x = img.xaxis.lim.min + j * ((img.xaxis.lim.max - img.xaxis.lim.min) / PARTITIONS);
   p2.y = 1 - stdev * sqrt(2 * PI) * gaussian(p1.x, mean, stdev);
   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 $0xf42c8, %rsp          # imm = 0xF42C8
movq %rdi, %rbx
leaq 0x4b0b4(%rip), %rdi     # 0x9a6e5
callq 0x4cff1
testl %eax, %eax
jne 0x4f641
xorl %eax, %eax
callq 0x2a510
movq %rbx, %rdi
callq 0x34033
movq %rax, %r14
leaq 0x35aa65(%rip), %rax    # 0x3aa0b8
movslq 0xec(%rax), %r12
leaq 0x7d9ff(%rip), %rax     # 0xcd060
movb (%r12,%rax), %al
movb %al, 0xe(%rsp)
movb $0x0, 0xf(%rsp)
leal 0x41(%r12), %ebp
movsbl %bpl, %edi
movq %r14, %rsi
callq 0x28ee8
movq %r14, %rdi
callq 0x34ff7
movq %rbx, %rdi
callq 0x33f62
movl %eax, %r14d
leaq 0x4c1e6(%rip), %rsi     # 0x9b87f
movq %rbx, %rdi
callq 0x40f0
testq %rax, %rax
je 0x4f98d
movq %rax, %r15
movl %ebp, 0x30(%rsp)
movq %r12, 0x48(%rsp)
movl %r14d, 0x28(%rsp)
movslq %r14d, %r13
leaq (,%r13,8), %r14
leaq 0x4b53a(%rip), %r12     # 0x9ac07
pushq $0xd
popq %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x34f59
movq %rax, %rbx
movq %rax, 0x60(%rsp)
pushq $0xe
popq %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x34f59
movq %rax, %r14
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
movq %r14, 0x68(%rsp)
movq %r13, %r12
leaq (,%r13,8), %r13
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0x4f733
leaq (%rbx,%rbp), %rdx
leaq (%r14,%rbp), %rcx
movq %r15, %rdi
leaq 0x491c4(%rip), %rsi     # 0x988ea
xorl %eax, %eax
callq 0x4070
addq $0x8, %rbp
jmp 0x4f70f
movq %r15, %rdi
callq 0x42a0
xorl %r13d, %r13d
pushq $0x1
popq %r15
leaq 0xe(%rsp), %rbp
cmpq %r13, %r12
je 0x4f79b
movsd (%rbx,%r13,8), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm1
callq 0x2a296
movsd (%r14,%r13,8), %xmm1
movsd 0x7d8ff(%rip), %xmm2    # 0xcd070
movsd 0x7d8ff(%rip), %xmm3    # 0xcd078
movl %r15d, %edi
movsd 0x10(%rsp), %xmm0
movsd %xmm1, 0x18(%rsp)
movaps %xmm2, %xmm4
movaps %xmm3, %xmm5
movq %rbp, %rsi
callq 0x28f8d
incq %r13
jmp 0x4f747
leaq 0x35a916(%rip), %r13    # 0x3aa0b8
movsd 0x10(%r13), %xmm0
movsd 0x18(%r13), %xmm1
movapd %xmm1, %xmm3
subsd %xmm0, %xmm3
leaq 0x60(%rsp), %rdi
leaq 0x78(%rsp), %r15
leaq 0x70(%rsp), %rbp
xorps %xmm2, %xmm2
movl 0x28(%rsp), %esi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x4e041
leaq 0x80(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x35305
movsd (%r15), %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0x7a1a0(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x41b0
leaq 0x4b3b0(%rip), %rdi     # 0x9abc2
movq %r15, %rsi
callq 0x2f4fc
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x35305
movsd (%rbp), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x41b0
leaq 0x4b386(%rip), %rdi     # 0x9abcb
movq %r15, %rsi
callq 0x2f4fc
movq %rbx, %rdi
callq 0x34ff7
movq %r14, %rdi
callq 0x34ff7
movsd 0x10(%r13), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x38(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x803b8
movsd 0x10(%rsp), %xmm1
movapd %xmm0, %xmm2
movsd 0x4b2fc(%rip), %xmm0    # 0x9ab88
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
mulsd %xmm0, %xmm2
movsd 0x45c7c(%rip), %xmm0    # 0x95520
addsd %xmm0, %xmm2
leaq 0x45(%rsp), %rbx
movl 0x30(%rsp), %eax
movb %al, (%rbx)
movb $0x0, 0x1(%rbx)
movl $0x1f3, %ebp            # imm = 0x1F3
movapd %xmm0, %xmm3
movq 0x48(%rsp), %r14
subl $0x1, %ebp
jb 0x4f986
movsd 0x10(%r13), %xmm0
movsd 0x18(%r13), %xmm4
subsd %xmm0, %xmm4
divsd 0x484b2(%rip), %xmm4    # 0x97d98
mulsd %xmm3, %xmm4
addsd %xmm0, %xmm4
movsd %xmm4, 0x18(%rsp)
movapd %xmm1, %xmm0
movsd %xmm1, 0x10(%rsp)
movsd 0x38(%rsp), %xmm1
movsd %xmm2, 0x28(%rsp)
movsd 0x20(%rsp), %xmm2
movsd %xmm3, 0x30(%rsp)
callq 0x803b8
movapd %xmm0, %xmm3
mulsd 0x50(%rsp), %xmm3
movsd 0x45bf3(%rip), %xmm0    # 0x95520
addsd %xmm0, %xmm3
movsd %xmm3, 0x58(%rsp)
movsd 0x7d731(%rip), %xmm4    # 0xcd070
movsd 0x7d731(%rip), %xmm5    # 0xcd078
xorl %edi, %edi
movsd 0x10(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movq %rbx, %rsi
callq 0x28f8d
movsd 0x30(%rsp), %xmm3
movl %r14d, 0x18(%rax)
addsd 0x45bab(%rip), %xmm3    # 0x95520
movsd 0x18(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
jmp 0x4f8c5
xorl %eax, %eax
callq 0x2a858
addq $0xf42c8, %rsp          # imm = 0xF42C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq