// File: /workspace/github_c_makefile_star2_O2/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 0x52886
movq %rax, %rbx
leaq 0x4a054(%rip), %rdi     # 0x9a6e5
callq 0x4cff1
testl %eax, %eax
jne 0x506a1
xorl %eax, %eax
callq 0x2a510
movq %r15, %rdi
callq 0x34033
movq %rax, %r15
leal 0x41(%r14), %ebp
movsbl %bpl, %edi
movq %rax, %rsi
callq 0x28ee8
movq %r15, %rdi
callq 0x34ff7
leaq 0x3599ed(%rip), %r15    # 0x3aa0b8
movl $0x1, 0x78(%r15)
movl 0x2c(%rsp), %esi
leaq 0x50(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %rbx, %rdi
callq 0x525b4
xorpd %xmm2, %xmm2
movsd 0x45c3b(%rip), %xmm1    # 0x96330
movsd 0x456d3(%rip), %xmm0    # 0x95dd0
movsd %xmm0, 0x40(%rsp)
movl $0x1f5, %r12d           # imm = 0x1F5
subl $0x1, %r12d
jb 0x5078e
movsd %xmm1, 0x30(%rsp)
movsd 0x50(%rsp), %xmm1
movsd 0x48(%rsp), %xmm0
subsd %xmm1, %xmm0
divsd 0x4766b(%rip), %xmm0    # 0x97d98
movsd %xmm2, 0x38(%rsp)
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
callq 0x526fc
movsd 0x80(%r15), %xmm1
ucomisd 0x88(%r15), %xmm1
jae 0x50763
movsd 0x30(%rsp), %xmm1
jmp 0x5077b
movapd %xmm0, %xmm1
minsd 0x30(%rsp), %xmm1
ucomisd 0x40(%rsp), %xmm0
jbe 0x5077b
movsd %xmm0, 0x40(%rsp)
movsd 0x38(%rsp), %xmm2
addsd 0x44d97(%rip), %xmm2    # 0x95520
jmp 0x50709
movsd 0x80(%r15), %xmm0
ucomisd 0x88(%r15), %xmm0
jb 0x507ba
movsd %xmm1, 0x80(%r15)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x88(%r15)
movsd 0x10(%r15), %xmm0
ucomisd 0x18(%r15), %xmm0
movsd 0x50(%rsp), %xmm0
jb 0x507e0
movsd %xmm0, 0x10(%r15)
movsd 0x48(%rsp), %xmm1
movsd %xmm1, 0x18(%r15)
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
movsd %xmm0, 0x30(%rsp)
callq 0x526fc
movsd 0x30(%rsp), %xmm1
movaps %xmm0, %xmm3
leaq 0x5d(%rsp), %r15
movb %bpl, (%r15)
movb $0x0, 0x1(%r15)
movl $0x1f4, %ebp            # imm = 0x1F4
movsd 0x44d0b(%rip), %xmm2    # 0x95520
subl $0x1, %ebp
jb 0x508bd
movsd 0x50(%rsp), %xmm0
movsd 0x48(%rsp), %xmm4
subsd %xmm0, %xmm4
divsd 0x47562(%rip), %xmm4    # 0x97d98
mulsd %xmm2, %xmm4
addsd %xmm0, %xmm4
movsd %xmm4, 0x38(%rsp)
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
movaps %xmm1, %xmm0
movsd %xmm1, 0x30(%rsp)
movsd %xmm2, 0x40(%rsp)
movsd %xmm3, 0x60(%rsp)
callq 0x526fc
movaps %xmm0, %xmm3
movsd %xmm0, 0x68(%rsp)
movsd 0x7c7fa(%rip), %xmm4    # 0xcd070
movsd 0x7c7fa(%rip), %xmm5    # 0xcd078
xorl %edi, %edi
movsd 0x30(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movq %r15, %rsi
callq 0x28f8d
movsd 0x40(%rsp), %xmm2
movl %r14d, 0x18(%rax)
addsd 0x44c74(%rip), %xmm2    # 0x95520
movsd 0x38(%rsp), %xmm1
movsd 0x68(%rsp), %xmm3
jmp 0x50815
xorl %r14d, %r14d
movq %rbx, %r15
movslq 0x2c(%rsp), %rax
cmpq %rax, %r14
jge 0x508ed
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x5295c
incq %r14
addq $0x20, %r15
jmp 0x508c3
movq %rbx, %rdi
callq 0x34ff7
xorl %eax, %eax
callq 0x2a858
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq