// File: /workspace/github_c_makefile_star2_O3/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 0x534a0(%rip), %rdi     # 0xaa7b5
callq 0x54bec
testl %eax, %eax
jne 0x57325
xorl %eax, %eax
callq 0x2e342
movq %rbx, %rdi
callq 0x38b30
movq %rax, %r14
leaq 0x35ad81(%rip), %rax    # 0x3b20b8
movslq 0xec(%rax), %r12
leaq 0x7dd1b(%rip), %rax     # 0xd5060
movb (%r12,%rax), %al
movb %al, 0x6(%rsp)
movb $0x0, 0x7(%rsp)
leal 0x41(%r12), %ebp
movsbl %bpl, %edi
movq %r14, %rsi
callq 0x2cbc4
movq %r14, %rdi
callq 0x3a180
movq %rbx, %rdi
callq 0x38a4a
movl %eax, %r14d
leaq 0x545de(%rip), %rsi     # 0xab95b
movq %rbx, %rdi
callq 0x40f0
testq %rax, %rax
je 0x5768c
movq %rax, %r15
movl %ebp, 0x30(%rsp)
movq %r12, 0x48(%rsp)
movslq %r14d, %rbx
movl %r14d, %ebp
leaq (,%rbx,8), %r14
leaq 0x53928(%rip), %r12     # 0xaacd7
movq %r14, %rdi
movq %r12, %rsi
movl $0xd, %edx
callq 0x3a0e1
movq %rax, %r13
movq %rax, 0x60(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movl $0xe, %edx
callq 0x3a0e1
movq %rax, %r12
movq %rax, 0x68(%rsp)
testl %ebx, %ebx
movl %ebp, 0x18(%rsp)
jle 0x5749c
movl %ebp, %ebp
movq %r12, %r14
leaq 0x51573(%rip), %r12     # 0xa896a
movq %rbp, %rbx
movq %r13, 0x28(%rsp)
movq %r14, 0x8(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x4070
addq $0x8, %r14
addq $0x8, %r13
decq %rbx
jne 0x57404
movq %r15, %rdi
callq 0x42a0
cmpl $0x0, 0x18(%rsp)
movq 0x28(%rsp), %r13
movq 0x8(%rsp), %r12
jle 0x574a4
xorl %r14d, %r14d
leaq 0x6(%rsp), %r15
movsd (%r13,%r14,8), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm1
callq 0x2e0c5
movsd (%r12,%r14,8), %xmm1
movsd 0x7dc05(%rip), %xmm2    # 0xd5070
movsd 0x7dc05(%rip), %xmm3    # 0xd5078
movl $0x1, %edi
movsd 0x10(%rsp), %xmm0
movsd %xmm1, 0x20(%rsp)
movaps %xmm2, %xmm4
movaps %xmm3, %xmm5
movq %r15, %rsi
callq 0x2cc6c
incq %r14
cmpq %r14, %rbp
jne 0x57445
jmp 0x574a4
movq %r15, %rdi
callq 0x42a0
leaq 0x35ac0d(%rip), %rbp    # 0x3b20b8
movsd 0x10(%rbp), %xmm0
movsd 0x18(%rbp), %xmm1
movapd %xmm1, %xmm3
subsd %xmm0, %xmm3
leaq 0x60(%rsp), %rdi
leaq 0x78(%rsp), %r14
leaq 0x58(%rsp), %rcx
xorps %xmm2, %xmm2
movl 0x18(%rsp), %esi
movq %r14, %rdx
callq 0x55d4f
movq %r12, %r15
leaq 0x80(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3a535
movsd (%r14), %xmm0
movsd %xmm0, 0x38(%rsp)
movq %r13, %rbx
leaq 0x7a1a0(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x41b0
leaq 0x53776(%rip), %rdi     # 0xaac92
movq %r13, %rsi
callq 0x33827
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3a535
leaq 0x58(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r13, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x41b0
leaq 0x53748(%rip), %rdi     # 0xaac9b
movq %r13, %rsi
callq 0x33827
movq %rbx, %rdi
callq 0x3a180
movq %r15, %rdi
callq 0x3a180
movsd 0x10(%rbp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x38(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x8dd8e
movsd 0x10(%rsp), %xmm1
movsd 0x536c3(%rip), %xmm2    # 0xaac58
mulsd 0x8(%rsp), %xmm2
movsd %xmm2, 0x50(%rsp)
mulsd %xmm2, %xmm0
movsd 0x4df73(%rip), %xmm2    # 0xa5520
addsd %xmm2, %xmm0
leaq 0x45(%rsp), %rbx
movl 0x30(%rsp), %eax
movb %al, (%rbx)
movb $0x0, 0x1(%rbx)
movl $0x1f3, %r14d           # imm = 0x1F3
movq 0x48(%rsp), %r15
movsd %xmm0, 0x28(%rsp)
movsd %xmm1, 0x10(%rsp)
movsd %xmm2, 0x18(%rsp)
movsd 0x10(%rbp), %xmm0
movsd 0x18(%rbp), %xmm4
subsd %xmm0, %xmm4
divsd 0x50825(%rip), %xmm4    # 0xa7e18
mulsd %xmm2, %xmm4
addsd %xmm0, %xmm4
movsd %xmm4, 0x20(%rsp)
movapd %xmm1, %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x8dd8e
movapd %xmm0, %xmm3
mulsd 0x50(%rsp), %xmm3
movsd 0x4def8(%rip), %xmm0    # 0xa5520
addsd %xmm0, %xmm3
movsd %xmm3, 0x30(%rsp)
movsd 0x7da36(%rip), %xmm4    # 0xd5070
movsd 0x7da36(%rip), %xmm5    # 0xd5078
xorl %edi, %edi
movsd 0x10(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movq %rbx, %rsi
callq 0x2cc6c
movsd 0x18(%rsp), %xmm2
movl %r15d, 0x18(%rax)
addsd 0x4deb0(%rip), %xmm2    # 0xa5520
movsd 0x30(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
decl %r14d
jne 0x575cb
xorl %eax, %eax
callq 0x2e6d0
addq $0xf42c8, %rsp          # imm = 0xF42C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq