// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/plot.c
// Function: functionplot
void functionplot(char* functiondefinition, int color)
{
 /*!Last Changed 20.09.2006*/
 /*!Last Changed 21.01.2005*/
 int i, functioncount;
 double minvaluey = +LONG_MAX, maxvaluey = -LONG_MAX, valuey, valuex, start, end;
 char st2[3], *legendname; 
 Point p1, p2;
 Functionptr fx = read_function_definition(functiondefinition, &functioncount);
 Objectptr obj;
 if (!get_parameter_o("hold"))
   clear_image();
 legendname = file_only_name(functiondefinition);
 add_legend((char)('A' + color), legendname);
 safe_free(legendname);
 img.yaxis.available = 1;
 find_function_bounds(fx, functioncount, &start, &end);
 for (i = 0; i <= PARTITIONS; i++)
  {
   valuex = start + i * ((end - start) / PARTITIONS);
   valuey = function_value(fx, functioncount, valuex);
   if (img.yaxis.lim.min >= img.yaxis.lim.max)
    {
     if (valuey < minvaluey)
       minvaluey = valuey;
     if (valuey > maxvaluey)
       maxvaluey = valuey;
    }
  }
 if (img.yaxis.lim.min >= img.yaxis.lim.max)
  {
   img.yaxis.lim.min = minvaluey;
   img.yaxis.lim.max = maxvaluey;
  }
 if (img.xaxis.lim.min >= img.xaxis.lim.max)
  {
   img.xaxis.lim.min = start;
   img.xaxis.lim.max = end;
  }
 p1.x = (double) start;
 p1.y = (double) (function_value(fx, functioncount, p1.x));
 sprintf(st2, "%c", 'A' + color);
 for (i = 1; i <= PARTITIONS; i++)
  {
   p2.x = (double) (start + i * ((end - start) / PARTITIONS));
   p2.y = (double) (function_value(fx, functioncount, p1.x));
   obj = add_object(OBJECT_LINE, p1, p2, dummyp, st2);
   obj->fnt.fontcolor = color;
   p1.x = p2.x;
   p1.y = p2.y;
  }
 for (i = 0;i < functioncount; i++)
   free_function(fx[i]);
 safe_free(fx);
 export_image();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movl %esi, %r14d
movq %rdi, %r15
leaq 0x2c(%rsp), %rsi
callq 0x5aa85
movq %rax, %rbx
leaq 0x523ab(%rip), %rdi     # 0xaa7b5
callq 0x54bec
testl %eax, %eax
jne 0x5841a
xorl %eax, %eax
callq 0x2e342
movq %r15, %rdi
callq 0x38b30
movq %rax, %r15
leal 0x41(%r14), %ebp
movsbl %bpl, %edi
movq %rax, %rsi
callq 0x2cbc4
movq %r15, %rdi
callq 0x3a180
leaq 0x359c74(%rip), %r15    # 0x3b20b8
movl $0x1, 0x78(%r15)
movl 0x2c(%rsp), %esi
leaq 0x48(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %rbx, %rdi
callq 0x5a6a1
movsd 0x4d95e(%rip), %xmm5    # 0xa5dc8
movsd 0x4debe(%rip), %xmm6    # 0xa6330
xorl %r12d, %r12d
movsd 0x4f99b(%rip), %xmm4    # 0xa7e18
movsd %xmm6, 0x30(%rsp)
movsd %xmm5, 0x38(%rsp)
movsd 0x48(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %r12d, %xmm2
movsd 0x40(%rsp), %xmm0
subsd %xmm1, %xmm0
divsd %xmm4, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
callq 0x5a853
movsd 0x80(%r15), %xmm1
movsd 0x88(%r15), %xmm2
ucomisd %xmm2, %xmm1
jae 0x584e7
incl %r12d
cmpl $0x1f5, %r12d           # imm = 0x1F5
movsd 0x4f935(%rip), %xmm4    # 0xa7e18
jne 0x58489
jmp 0x58534
movapd %xmm0, %xmm3
minsd 0x30(%rsp), %xmm3
maxsd 0x38(%rsp), %xmm0
leal 0x1(%r12), %eax
movapd %xmm3, %xmm6
movapd %xmm0, %xmm5
cmpl $0x1f4, %r12d           # imm = 0x1F4
movl %eax, %r12d
movsd 0x4f902(%rip), %xmm4    # 0xa7e18
jne 0x5847d
ucomisd %xmm2, %xmm1
jb 0x58534
movsd %xmm3, 0x80(%r15)
movsd %xmm0, 0x88(%r15)
movsd 0x10(%r15), %xmm0
ucomisd 0x18(%r15), %xmm0
movsd 0x48(%rsp), %xmm0
jb 0x5855a
movsd %xmm0, 0x10(%r15)
movsd 0x40(%rsp), %xmm1
movsd %xmm1, 0x18(%r15)
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
movsd %xmm0, 0x30(%rsp)
callq 0x5a853
movsd 0x30(%rsp), %xmm1
leaq 0x55(%rsp), %r15
movb %bpl, (%r15)
movb $0x0, 0x1(%r15)
movsd 0x4cf99(%rip), %xmm2    # 0xa5520
movl $0x1f4, %ebp            # imm = 0x1F4
movsd %xmm1, 0x30(%rsp)
movsd %xmm0, 0x58(%rsp)
movsd %xmm2, 0x68(%rsp)
movsd 0x48(%rsp), %xmm0
movsd 0x40(%rsp), %xmm4
subsd %xmm0, %xmm4
divsd 0x4f862(%rip), %xmm4    # 0xa7e18
mulsd %xmm2, %xmm4
addsd %xmm0, %xmm4
movsd %xmm4, 0x38(%rsp)
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
movapd %xmm1, %xmm0
callq 0x5a853
movapd %xmm0, %xmm3
movsd %xmm0, 0x60(%rsp)
movsd 0x7ca8a(%rip), %xmm4    # 0xd5070
movsd 0x7ca8a(%rip), %xmm5    # 0xd5078
xorl %edi, %edi
movsd 0x30(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movq %r15, %rsi
callq 0x2cc6c
movsd 0x68(%rsp), %xmm2
movl %r14d, 0x18(%rax)
addsd 0x4cf04(%rip), %xmm2    # 0xa5520
movsd 0x60(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
decl %ebp
jne 0x5858c
cmpl $0x0, 0x2c(%rsp)
jle 0x58667
xorl %r14d, %r14d
movq %rbx, %r15
movups (%r15), %xmm0
movupd 0x10(%r15), %xmm1
movupd %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x5ab77
incq %r14
movslq 0x2c(%rsp), %rax
addq $0x20, %r15
cmpq %rax, %r14
jl 0x5863d
movq %rbx, %rdi
callq 0x3a180
xorl %eax, %eax
callq 0x2e6d0
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq