// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/image.c
// Function: load_image
void load_image(char* fname)
{
 int i, j, objecttype, legendposition, coloringtype, fonttype, colortype;
 FILE* infile;
 char buffer[READLINELENGTH]; 
 clear_image();
 infile = fopen(fname, "r");
 fscanf(infile, "%d %d %d %d", &(img.width), &(img.height), &(img.objectcount), &coloringtype);
 img.groupcoloring = coloringtype;
 /* Load x axis */
 fscanf(infile, "%d %d %d", &(img.xaxis.available), &(img.xaxis.namesavailable), &(img.xaxis.limitsset));
 fscanf(infile, "%s", buffer);
 img.xaxis.label = strcopy(img.xaxis.label, buffer);
 fscanf(infile, "%d %d %lf %lf", &(img.xaxis.lim.division), &(img.xaxis.lim.precision), &(img.xaxis.lim.min), &(img.xaxis.lim.max));
 fscanf(infile, "%d %lf %d %d", &(img.xaxis.labelfnt.dashedtype), &(img.xaxis.labelfnt.fontsize), &fonttype, &colortype);
 img.xaxis.labelfnt.fontname = fonttype;
 img.xaxis.labelfnt.fontcolor = colortype;
 fscanf(infile, "%d %lf %d %d", &(img.xaxis.axisfnt.dashedtype), &(img.xaxis.axisfnt.fontsize), &fonttype, &colortype);
 img.xaxis.axisfnt.fontname = fonttype;
 img.xaxis.axisfnt.fontcolor = colortype;
 if (img.xaxis.namesavailable)
  {
   img.xaxis.names = safemalloc(img.xaxis.lim.division * sizeof(char *), "load_image", 12);
   for (i = 0; i < img.xaxis.lim.division; i++)
    {
     fscanf(infile, "%s", buffer);
     img.xaxis.names[i] = strcopy(img.xaxis.names[i], buffer);
    }
  }
 else
   img.xaxis.names = NULL;
 /* Load y axis */
 fscanf(infile, "%d %d %d", &(img.yaxis.available), &(img.yaxis.namesavailable), &(img.yaxis.limitsset));
 if (img.yaxis.available)
  {
   fscanf(infile, "%s", buffer);
   img.yaxis.label = strcopy(img.yaxis.label, buffer);
   fscanf(infile, "%d %d %lf %lf", &(img.yaxis.lim.division), &(img.yaxis.lim.precision), &(img.yaxis.lim.min), &(img.yaxis.lim.max));
   fscanf(infile, "%d %lf %d %d", &(img.yaxis.labelfnt.dashedtype), &(img.yaxis.labelfnt.fontsize), &fonttype, &colortype);
   img.yaxis.labelfnt.fontname = fonttype;
   img.yaxis.labelfnt.fontcolor = colortype;
   fscanf(infile, "%d %lf %d %d", &(img.yaxis.axisfnt.dashedtype), &(img.yaxis.axisfnt.fontsize), &fonttype, &colortype);
   img.yaxis.axisfnt.fontname = fonttype;
   img.yaxis.axisfnt.fontcolor = colortype;
   if (img.yaxis.namesavailable)
    {
     img.yaxis.names = safemalloc(img.yaxis.lim.division * sizeof(char *), "load_image", 12);
     for (i = 0; i < img.yaxis.lim.division; i++)
      {
       fscanf(infile, "%s", buffer);
       img.yaxis.names[i] = strcopy(img.yaxis.names[i], buffer);
      }
    }
   else
     img.yaxis.names = NULL;
  }
 else
  {
   img.yaxis.label = NULL;
   img.yaxis.namesavailable = BOOLEAN_FALSE;
   img.yaxis.names = NULL;
  }
 /* Load Objects */
 img.objects = safemalloc(img.objectcount * sizeof(Object), "load_image", 25);
 for (i = 0; i < img.objectcount; i++)
  {
   fscanf(infile, "%d %d %d", &objecttype, &(img.objects[i].index), &(img.objects[i].groupindex));
   img.objects[i].type = objecttype;
   fscanf(infile, "%d %lf %d %d", &(img.objects[i].fnt.dashedtype), &(img.objects[i].fnt.fontsize), &fonttype, &colortype);
   img.objects[i].fnt.fontname = fonttype;
   img.objects[i].fnt.fontcolor = colortype;
   switch (img.objects[i].type)
    {
     case      OBJECT_LINE:fscanf(infile, "%lf %lf %lf %lf", &(img.objects[i].obje.li.downright.x), &(img.objects[i].obje.li.downright.y), &(img.objects[i].obje.li.upleft.x), &(img.objects[i].obje.li.upleft.y));
                           break;
     case    OBJECT_CIRCLE:fscanf(infile, "%lf %lf %lf", &(img.objects[i].obje.ci.center.x), &(img.objects[i].obje.ci.center.y), &(img.objects[i].obje.ci.radius));
                           break;
     case      OBJECT_POINT:
     case     OBJECT_STRING:
     case OBJECT_NAMEDPOINT:fscanf(infile, "%lf %lf", &(img.objects[i].obje.st.p.x), &(img.objects[i].obje.st.p.y));
                           fscanf(infile, "%s", buffer);
                           img.objects[i].obje.st.st = strcopy(img.objects[i].obje.st.st, buffer);
                           break;
     case OBJECT_RECTANGLE:fscanf(infile, "%lf %lf %lf %lf", &(img.objects[i].obje.re.downright.x), &(img.objects[i].obje.re.downright.y), &(img.objects[i].obje.re.upleft.x), &(img.objects[i].obje.re.upleft.y));
                           break;
     case     OBJECT_MVBOX:fscanf(infile, "%lf %lf", &(img.objects[i].obje.mv.mean), &(img.objects[i].obje.mv.variance));
                           break;
     case   OBJECT_BOXPLOT:fscanf(infile, "%lf %lf %lf %lf %lf", &(img.objects[i].obje.box.lwhisker), &(img.objects[i].obje.box.swhisker), &(img.objects[i].obje.box.p75), &(img.objects[i].obje.box.p25), &(img.objects[i].obje.box.median));
                           break;
     case  OBJECT_ERRORHISTOGRAM:fscanf(infile, "%lf %lf\n", &(img.objects[i].obje.errorhist.min), &(img.objects[i].obje.errorhist.max));
                                 for (j = 0; j < 10; j++)
                                   fscanf(infile, "%d", &(img.objects[i].obje.errorhist.counts[j]));
                                 break;
    }
  }
 /* Load Legend */
 fscanf(infile, "%d %d", &legendposition, &(img.imagelegend.legendcount));
 img.imagelegend.position = legendposition;
 fscanf(infile, "%d %lf %d %d", &(img.imagelegend.fnt.dashedtype), &(img.imagelegend.fnt.fontsize), &fonttype, &colortype);
 img.imagelegend.fnt.fontname = fonttype;
 img.imagelegend.fnt.fontcolor = colortype;
 img.imagelegend.names = safemalloc(img.imagelegend.legendcount * sizeof(char *), "load_image", 25);
 for (i = 0; i < img.imagelegend.legendcount; i++)
  {
   fscanf(infile, "%s", buffer);
   img.imagelegend.names[i] = strcopy(img.imagelegend.names[i], buffer);
  } 
 img.imagelegend.colors = safemalloc(img.imagelegend.legendcount * sizeof(COLOR_TYPE), "load_image", 26);
 for (i = 0; i < img.imagelegend.legendcount; i++)
  {
   fscanf(infile, "%d", &colortype);
   img.imagelegend.colors[i] = colortype;
  }
 img.imagelegend.types = safemalloc(img.imagelegend.legendcount * sizeof(char), "load_image", 30);
 for (i = 0; i < img.imagelegend.legendcount; i++)
   fscanf(infile, "%c", &(img.imagelegend.types[i]));
 fclose(infile);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a158, %rsp          # imm = 0x7A158
movq %rdi, %rbx
callq 0x2a510
leaq 0x72006(%rip), %rsi     # 0x9b87f
movq %rbx, %rdi
callq 0x40f0
movq %rax, %rbx
leaq 0x38082d(%rip), %r14    # 0x3aa0b8
leaq 0x4(%r14), %rdx
leaq 0x124(%r14), %r8
leaq 0x6f03b(%rip), %rsi     # 0x988d8
leaq 0x28(%rsp), %r15
movq %rax, %rdi
movq %r14, %rcx
movq %r15, %r9
xorl %eax, %eax
callq 0x4070
movl (%r15), %eax
movl %eax, 0x120(%r14)
leaq 0x8(%r14), %rdx
leaq 0x38(%r14), %rcx
leaq 0x28(%r14), %r8
leaq 0x6f00c(%rip), %rsi     # 0x988db
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
leaq 0x6e5f0(%rip), %rsi     # 0x97ed0
leaq 0x30(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4070
movq 0x40(%r14), %rdi
movq %r15, %rsi
callq 0x3604c
movq %rax, 0x40(%r14)
leaq 0x20(%r14), %rdx
leaq 0x24(%r14), %rcx
leaq 0x10(%r14), %r8
leaq 0x18(%r14), %r9
leaq 0x6efcb(%rip), %rsi     # 0x988e4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
leaq 0x74(%r14), %rdx
leaq 0x68(%r14), %rcx
leaq 0x6efc0(%rip), %r15     # 0x988f2
leaq 0x18(%rsp), %r12
leaq 0x14(%rsp), %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x4070
movl (%r12), %eax
movl %eax, 0x60(%r14)
movl (%r13), %eax
movl %eax, 0x70(%r14)
leaq 0x5c(%r14), %rdx
leaq 0x50(%r14), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x4070
movl (%r12), %eax
movl %eax, 0x48(%r14)
movl (%r13), %eax
movl %eax, 0x58(%r14)
cmpl $0x0, 0x38(%r14)
je 0x299f1
movslq 0x20(%r14), %rdi
shlq $0x3, %rdi
leaq 0x6ef5f(%rip), %rsi     # 0x988ff
pushq $0xc
popq %rdx
callq 0x34f59
movq %rax, 0x30(%r14)
leaq 0x6e51d(%rip), %r15     # 0x97ed0
leaq 0x30(%rsp), %r12
xorl %r13d, %r13d
movslq 0x20(%r14), %rax
cmpq %rax, %r13
jge 0x299f6
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x4070
movq 0x30(%r14), %rax
movq (%rax,%r13,8), %rdi
movq %r12, %rsi
callq 0x3604c
movq 0x30(%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
jmp 0x299bb
andq $0x0, 0x30(%r14)
leaq 0x78(%r14), %rdx
leaq 0xa8(%r14), %rcx
leaq 0x98(%r14), %r8
leaq 0x6eecc(%rip), %rsi     # 0x988db
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
cmpl $0x0, 0x78(%r14)
je 0x29b78
leaq 0x6e4a5(%rip), %rsi     # 0x97ed0
leaq 0x30(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4070
movq 0xb0(%r14), %rdi
movq %r15, %rsi
callq 0x3604c
movq %rax, 0xb0(%r14)
leaq 0x90(%r14), %rdx
leaq 0x94(%r14), %rcx
leaq 0x80(%r14), %r8
leaq 0x88(%r14), %r9
leaq 0x6ee6e(%rip), %rsi     # 0x988e4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
leaq 0xe4(%r14), %rdx
leaq 0xd8(%r14), %rcx
leaq 0x6ee5d(%rip), %r15     # 0x988f2
leaq 0x18(%rsp), %r12
leaq 0x14(%rsp), %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x4070
movl (%r12), %eax
movl %eax, 0xd0(%r14)
movl (%r13), %eax
movl %eax, 0xe0(%r14)
leaq 0xcc(%r14), %rdx
leaq 0xc0(%r14), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x4070
movl (%r12), %eax
movl %eax, 0xb8(%r14)
movl (%r13), %eax
movl %eax, 0xc8(%r14)
cmpl $0x0, 0xa8(%r14)
je 0x29b88
movslq 0x90(%r14), %rdi
shlq $0x3, %rdi
leaq 0x6ede4(%rip), %rsi     # 0x988ff
pushq $0xc
popq %rdx
callq 0x34f59
movq %rax, 0xa0(%r14)
leaq 0x6e39f(%rip), %r15     # 0x97ed0
leaq 0x30(%rsp), %r12
xorl %r13d, %r13d
movslq 0x90(%r14), %rax
cmpq %rax, %r13
jge 0x29b90
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x4070
movq 0xa0(%r14), %rax
movq (%rax,%r13,8), %rdi
movq %r12, %rsi
callq 0x3604c
movq 0xa0(%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
jmp 0x29b39
andq $0x0, 0xb0(%r14)
andl $0x0, 0xa8(%r14)
andq $0x0, 0xa0(%r14)
movslq 0x124(%r14), %rax
imulq $0x60, %rax, %rdi
leaq 0x6ed5d(%rip), %rsi     # 0x988ff
pushq $0x19
popq %rdx
callq 0x34f59
movq %rax, 0x128(%r14)
pushq $0x38
popq %r13
leaq 0x76f9d(%rip), %r12     # 0xa0b59
xorl %r15d, %r15d
movslq 0x124(%r14), %rax
cmpq %rax, %r15
jge 0x29dbc
movq 0x128(%r14), %rax
imulq $0x60, %r15, %rbp
leaq (%rax,%rbp), %rcx
addq $0x24, %rcx
leaq 0x20(%rax,%rbp), %r8
movq %rbx, %rdi
leaq 0x6ecea(%rip), %rsi     # 0x988db
leaq 0x1c(%rsp), %rdx
xorl %eax, %eax
callq 0x4070
movl 0x1c(%rsp), %eax
movq 0x128(%r14), %rcx
leaq (%rcx,%rbp), %rdx
addq $0x1c, %rdx
movl %eax, -0x1c(%rdx)
leaq 0x10(%rcx,%rbp), %rcx
movq %rbx, %rdi
leaq 0x6ecd0(%rip), %rsi     # 0x988f2
leaq 0x18(%rsp), %r8
leaq 0x14(%rsp), %r9
xorl %eax, %eax
callq 0x4070
movl 0x18(%rsp), %ecx
movq 0x128(%r14), %rax
movl %ecx, 0x8(%rax,%rbp)
movl 0x14(%rsp), %ecx
movl %ecx, 0x18(%rax,%rbp)
movl (%rax,%rbp), %ecx
cmpq $0x8, %rcx
ja 0x29db0
leaq (%rax,%rbp), %r9
leaq 0x6ebae(%rip), %rdx     # 0x98810
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq (%rax,%rbp), %rdx
addq $0x28, %rdx
leaq (%rax,%rbp), %rcx
addq $0x30, %rcx
movq %rbx, %rdi
leaq 0x6ec65(%rip), %rsi     # 0x988ea
xorl %eax, %eax
callq 0x4070
movq %rbx, %rdi
leaq 0x6e23a(%rip), %rsi     # 0x97ed0
movq %r15, 0x20(%rsp)
movq %rbx, %r15
movq %r12, %rbx
leaq 0x30(%rsp), %r12
movq %r12, %rdx
xorl %eax, %eax
callq 0x4070
movq 0x128(%r14), %rax
movq 0x38(%rax,%rbp), %rdi
movq %r12, %rsi
movq %rbx, %r12
movq %r15, %rbx
movq 0x20(%rsp), %r15
callq 0x3604c
movq 0x128(%r14), %rcx
movq %rax, 0x38(%rcx,%rbp)
jmp 0x29db0
leaq 0x28(%r9), %r8
leaq 0x38(%r9), %rdx
leaq 0x40(%r9), %rcx
addq $0x30, %r9
movq %rbx, %rdi
leaq 0x6ec14(%rip), %rsi     # 0x9890e
jmp 0x29d87
leaq 0x28(%r9), %rdx
addq $0x30, %r9
movq %rbx, %rdi
leaq 0x70f57(%rip), %rsi     # 0x9ac68
movq %r9, %rcx
xorl %eax, %eax
callq 0x4070
xorl %ebp, %ebp
cmpq $0x28, %rbp
je 0x29db0
movq 0x128(%r14), %rdx
addq %r13, %rdx
addq %rbp, %rdx
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x4070
addq $0x4, %rbp
jmp 0x29d1d
leaq 0x28(%r9), %rdx
addq $0x30, %r9
movq %rbx, %rdi
leaq 0x6eb91(%rip), %rsi     # 0x988ea
movq %r9, %rcx
xorl %eax, %eax
callq 0x4070
jmp 0x29db0
leaq 0x28(%r9), %rax
leaq 0x48(%r9), %rdx
leaq 0x40(%r9), %rcx
leaq 0x38(%r9), %r8
addq $0x30, %r9
movq %rax, (%rsp)
movq %rbx, %rdi
leaq 0x6eb83(%rip), %rsi     # 0x9890a
xorl %eax, %eax
callq 0x4070
jmp 0x29db0
leaq 0x28(%r9), %rdx
leaq 0x30(%r9), %rcx
addq $0x38, %r9
movq %rbx, %rdi
leaq 0x6eb6c(%rip), %rsi     # 0x98912
movq %r9, %r8
xorl %eax, %eax
callq 0x4070
incq %r15
addq $0x60, %r13
jmp 0x29bbf
leaq 0xec(%r14), %rcx
leaq 0x6eb14(%rip), %rsi     # 0x988de
leaq 0x2c(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4070
movl (%r15), %eax
movl %eax, 0xe8(%r14)
leaq 0x11c(%r14), %rdx
leaq 0x110(%r14), %rcx
leaq 0x6eaf7(%rip), %rsi     # 0x988f2
leaq 0x18(%rsp), %r15
leaq 0x14(%rsp), %r12
movq %rbx, %rdi
movq %r15, %r8
movq %r12, %r9
xorl %eax, %eax
callq 0x4070
movl (%r15), %eax
movl %eax, 0x108(%r14)
movl (%r12), %eax
movl %eax, 0x118(%r14)
movslq 0xec(%r14), %rdi
shlq $0x3, %rdi
leaq 0x6eac3(%rip), %rsi     # 0x988ff
pushq $0x19
popq %rdx
callq 0x34f59
movq %rax, 0x100(%r14)
leaq 0x6e07e(%rip), %r15     # 0x97ed0
leaq 0x30(%rsp), %r12
xorl %r13d, %r13d
movslq 0xec(%r14), %rdi
cmpq %rdi, %r13
jge 0x29e99
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x4070
movq 0x100(%r14), %rax
movq (%rax,%r13,8), %rdi
movq %r12, %rsi
callq 0x3604c
movq 0x100(%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
jmp 0x29e5a
shlq $0x2, %rdi
leaq 0x6ea5b(%rip), %rsi     # 0x988ff
pushq $0x1a
popq %rdx
callq 0x34f59
movq %rax, 0xf0(%r14)
leaq 0x76c9f(%rip), %r15     # 0xa0b59
leaq 0x14(%rsp), %r12
xorl %r13d, %r13d
movslq 0xec(%r14), %rdi
cmpq %rdi, %r13
jge 0x29ef2
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x4070
movl 0x14(%rsp), %eax
movq 0xf0(%r14), %rcx
movl %eax, (%rcx,%r13,4)
incq %r13
jmp 0x29ec2
leaq 0x6ea06(%rip), %rsi     # 0x988ff
pushq $0x1e
popq %rdx
callq 0x34f59
movq %rax, 0xf8(%r14)
leaq 0x6fde9(%rip), %r15     # 0x99cf8
xorl %r12d, %r12d
movslq 0xec(%r14), %rax
cmpq %rax, %r12
jge 0x29f3a
movq 0xf8(%r14), %rdx
addq %r12, %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x4070
incq %r12
jmp 0x29f12
movq %rbx, %rdi
callq 0x42a0
addq $0x7a158, %rsp          # imm = 0x7A158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq