// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/eps.c
// Function: save_legend
void save_legend(FILE* myfile)
{
 /*!Last Changed 20.09.2006*/
 char st[100], st2[100];
 int posx = 0, posy = 0, direction = 0, i, legendy, legendheight, legendwidth, maxlength = 0;
 for (i = 0; i < img.imagelegend.legendcount; i++)
   if (strlen(img.imagelegend.names[i]) > maxlength)
     maxlength = strlen(img.imagelegend.names[i]);
 legendheight = img.imagelegend.fnt.fontsize;
 legendwidth = 1.1 * img.imagelegend.fnt.fontsize * maxlength;
 if (img.imagelegend.legendcount != 0 && img.imagelegend.position != NONE)
  {
   switch (img.imagelegend.position)
    {
     case DOWN_RIGHT:posx = epsaxis + MARGIN - legendwidth - 10;
                     posy = MARGIN + 20;
                     direction = 1;
                     break;
     case DOWN_LEFT :posx = MARGIN + 10;
                     posy = MARGIN + 20;
                     direction = 1;
                     break;
     case UP_RIGHT  :posx = epsaxis + MARGIN - legendwidth - 10;
                     posy = epsaxis + MARGIN - 20;
                     direction = -1;
                     break;
     case UP_LEFT   :posx = MARGIN + 10;
                     posy = epsaxis + MARGIN - 20;
                     direction = -1;
                     break;
     default        :break;
    }
   write_rectangle(myfile, posx, posy, posx + legendwidth, posy + direction * (img.imagelegend.legendcount + 1) * legendheight, FILL_NONE, BLACK);
   setfont(myfile, img.imagelegend.fnt);   
   for (i = 0; i < img.imagelegend.legendcount; i++)
    {
     setcolor(myfile, img.imagelegend.colors[i]);
     if (direction == 1)      
       legendy = posy + (img.imagelegend.legendcount - i) * legendheight;
     else
       legendy = posy - (i + 1) * legendheight;
     sprintf(st, "%s", img.imagelegend.names[i]);
     if (between(img.imagelegend.types[i], '0', '0' + MAX_FILL_TYPE - 1))
       write_rectangle(myfile, posx + 5, legendy, posx + 20, legendy + 10, img.imagelegend.types[i] - '0', BLACK);
     else
       if (between(img.imagelegend.types[i], 'a', 'z'))
        {
         setcolor(myfile, (img.imagelegend.types[i] - 'a') % COLORCOUNT);
         write_dashed_line(myfile, posx + 5, legendy, posx + 20, legendy, (img.imagelegend.types[i] - 'a') % MAX_LINE_TYPE);
         setcolor(myfile, BLACK);
        }
       else
         if (between(img.imagelegend.types[i], 'A', 'Z'))
          {
           setcolor(myfile, img.imagelegend.types[i] - 'A');
           write_line(myfile, posx + 5, legendy, posx + 20, legendy);
           setcolor(myfile, BLACK);
          } 
         else
          {
           sprintf(st2, "%c   %s", img.imagelegend.types[i], st);
           strcpy(st, st2);
          }
     write_string(myfile, posx + 25, legendy, st, ALIGN_LEFT);
    }  
  }    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movl $0x0, -0xe4(%rbp)
movl $0x0, -0xe8(%rbp)
movl $0x0, -0xec(%rbp)
movl $0x0, -0x100(%rbp)
movl $0x0, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
leaq 0x3afb9a(%rip), %rcx    # 0x3e2088
cmpl 0xec(%rcx), %eax
jge 0x32557
leaq 0x3afb8b(%rip), %rax    # 0x3e2088
movq 0x100(%rax), %rax
movslq -0xf0(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x4150
movslq -0x100(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x32544
leaq 0x3afb61(%rip), %rax    # 0x3e2088
movq 0x100(%rax), %rax
movslq -0xf0(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x4150
movl %eax, -0x100(%rbp)
jmp 0x32546
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x324e1
leaq 0x3afb2a(%rip), %rax    # 0x3e2088
cvttsd2si 0x110(%rax), %eax
movl %eax, -0xf8(%rbp)
movsd 0xb23e4(%rip), %xmm0    # 0xe4958
leaq 0x3afb0d(%rip), %rax    # 0x3e2088
mulsd 0x110(%rax), %xmm0
cvtsi2sdl -0x100(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xfc(%rbp)
leaq 0x3afae8(%rip), %rax    # 0x3e2088
cmpl $0x0, 0xec(%rax)
je 0x32a2b
leaq 0x3afad4(%rip), %rax    # 0x3e2088
cmpl $0x4, 0xe8(%rax)
je 0x32a2b
leaq 0x3afac0(%rip), %rax    # 0x3e2088
movl 0xe8(%rax), %eax
movq %rax, -0x108(%rbp)
subq $0x3, %rax
ja 0x3268a
movq -0x108(%rbp), %rax
leaq 0xb23c7(%rip), %rcx     # 0xe49b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x244, %eax            # imm = 0x244
subl -0xfc(%rbp), %eax
subl $0xa, %eax
movl %eax, -0xe4(%rbp)
movl $0x64, -0xe8(%rbp)
movl $0x1, -0xec(%rbp)
jmp 0x3268c
movl $0x5a, -0xe4(%rbp)
movl $0x64, -0xe8(%rbp)
movl $0x1, -0xec(%rbp)
jmp 0x3268c
movl $0x244, %eax            # imm = 0x244
subl -0xfc(%rbp), %eax
subl $0xa, %eax
movl %eax, -0xe4(%rbp)
movl $0x230, -0xe8(%rbp)     # imm = 0x230
movl $0xffffffff, -0xec(%rbp) # imm = 0xFFFFFFFF
jmp 0x3268c
movl $0x5a, -0xe4(%rbp)
movl $0x230, -0xe8(%rbp)     # imm = 0x230
movl $0xffffffff, -0xec(%rbp) # imm = 0xFFFFFFFF
jmp 0x3268c
jmp 0x3268c
movq -0x8(%rbp), %rdi
movl -0xe4(%rbp), %esi
movl -0xe8(%rbp), %edx
movl -0xe4(%rbp), %ecx
addl -0xfc(%rbp), %ecx
movl -0xe8(%rbp), %r8d
movl -0xec(%rbp), %eax
leaq 0x3af9cc(%rip), %r9     # 0x3e2088
movl 0xec(%r9), %r9d
addl $0x1, %r9d
imull %r9d, %eax
imull -0xf8(%rbp), %eax
addl %eax, %r8d
xorl %r9d, %r9d
movl $0x0, (%rsp)
callq 0x32d30
movq -0x8(%rbp), %rdi
leaq 0x3af999(%rip), %rax    # 0x3e2088
addq $0xe8, %rax
addq $0x20, %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x32b60
movl $0x0, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
leaq 0x3af95a(%rip), %rcx    # 0x3e2088
cmpl 0xec(%rcx), %eax
jge 0x32a29
movq -0x8(%rbp), %rdi
leaq 0x3af943(%rip), %rax    # 0x3e2088
movq 0xf0(%rax), %rax
movslq -0xf0(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x31ae0
cmpl $0x1, -0xec(%rbp)
jne 0x3278e
movl -0xe8(%rbp), %eax
leaq 0x3af917(%rip), %rcx    # 0x3e2088
movl 0xec(%rcx), %ecx
subl -0xf0(%rbp), %ecx
imull -0xf8(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0xf4(%rbp)
jmp 0x327ac
movl -0xe8(%rbp), %eax
movl -0xf0(%rbp), %ecx
addl $0x1, %ecx
imull -0xf8(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0xf4(%rbp)
leaq -0x70(%rbp), %rdi
leaq 0x3af8d1(%rip), %rax    # 0x3e2088
movq 0x100(%rax), %rax
movslq -0xf0(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0xb22c8(%rip), %rsi     # 0xe4a98
movb $0x0, %al
callq 0x4170
leaq 0x3af8aa(%rip), %rax    # 0x3e2088
movq 0xf8(%rax), %rax
movslq -0xf0(%rbp), %rcx
movsbl (%rax,%rcx), %edi
movl $0x30, %esi
movl $0x36, %edx
callq 0x52600
cmpl $0x0, %eax
je 0x3285c
movq -0x8(%rbp), %rdi
movl -0xe4(%rbp), %esi
addl $0x5, %esi
movl -0xf4(%rbp), %edx
movl -0xe4(%rbp), %ecx
addl $0x14, %ecx
movl -0xf4(%rbp), %r8d
addl $0xa, %r8d
leaq 0x3af856(%rip), %rax    # 0x3e2088
movq 0xf8(%rax), %rax
movslq -0xf0(%rbp), %r9
movsbl (%rax,%r9), %r9d
subl $0x30, %r9d
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x32d30
jmp 0x329f6
leaq 0x3af825(%rip), %rax    # 0x3e2088
movq 0xf8(%rax), %rax
movslq -0xf0(%rbp), %rcx
movsbl (%rax,%rcx), %edi
movl $0x61, %esi
movl $0x7a, %edx
callq 0x52600
cmpl $0x0, %eax
je 0x32929
movq -0x8(%rbp), %rdi
leaq 0x3af7f0(%rip), %rax    # 0x3e2088
movq 0xf8(%rax), %rax
movslq -0xf0(%rbp), %rcx
movsbl (%rax,%rcx), %eax
subl $0x61, %eax
movl $0xc, %ecx
cltd
idivl %ecx
movl %edx, %esi
callq 0x31ae0
movq -0x8(%rbp), %rdi
movl -0xe4(%rbp), %esi
addl $0x5, %esi
movl -0xf4(%rbp), %eax
movl %eax, -0x10c(%rbp)
movl -0xe4(%rbp), %ecx
addl $0x14, %ecx
movl -0xf4(%rbp), %r8d
leaq 0x3af79c(%rip), %rax    # 0x3e2088
movq 0xf8(%rax), %rax
movslq -0xf0(%rbp), %rdx
movsbl (%rax,%rdx), %eax
subl $0x61, %eax
movl $0x5, %r9d
cltd
idivl %r9d
movl %edx, %r9d
movl -0x10c(%rbp), %edx
callq 0x32ab0
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x31ae0
jmp 0x329f4
leaq 0x3af758(%rip), %rax    # 0x3e2088
movq 0xf8(%rax), %rax
movslq -0xf0(%rbp), %rcx
movsbl (%rax,%rcx), %edi
movl $0x41, %esi
movl $0x5a, %edx
callq 0x52600
cmpl $0x0, %eax
je 0x329b0
movq -0x8(%rbp), %rdi
leaq 0x3af727(%rip), %rax    # 0x3e2088
movq 0xf8(%rax), %rax
movslq -0xf0(%rbp), %rcx
movsbl (%rax,%rcx), %esi
subl $0x41, %esi
callq 0x31ae0
movq -0x8(%rbp), %rdi
movl -0xe4(%rbp), %esi
addl $0x5, %esi
movl -0xf4(%rbp), %edx
movl -0xe4(%rbp), %ecx
addl $0x14, %ecx
movl -0xf4(%rbp), %r8d
callq 0x32a70
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x31ae0
jmp 0x329f2
leaq -0xe0(%rbp), %rdi
leaq 0x3af6ca(%rip), %rax    # 0x3e2088
movq 0xf8(%rax), %rax
movslq -0xf0(%rbp), %rcx
movsbl (%rax,%rcx), %edx
leaq -0x70(%rbp), %rcx
leaq 0xb20b8(%rip), %rsi     # 0xe4a93
movb $0x0, %al
callq 0x4170
leaq -0x70(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x4220
jmp 0x329f4
jmp 0x329f6
movq -0x8(%rbp), %rdi
movl -0xe4(%rbp), %esi
addl $0x19, %esi
movl -0xf4(%rbp), %edx
leaq -0x70(%rbp), %rcx
xorl %r8d, %r8d
callq 0x32c00
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x32721
jmp 0x32a2b
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)