// File: /workspace/github_c_makefile_star2_O1/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 0x2da74
leaq 0x7bae4(%rip), %rsi     # 0xa888f
movq %rbx, %rdi
callq 0x40f0
movq %rax, %rbx
leaq 0x3822fb(%rip), %r14    # 0x3af0b8
leaq 0x4(%r14), %rdx
leaq 0x124(%r14), %r8
leaq 0x78b11(%rip), %rsi     # 0xa58e0
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 0x78ae2(%rip), %rsi     # 0xa58e3
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
leaq 0x780e6(%rip), %rsi     # 0xa4ef8
leaq 0x30(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4070
movq 0x40(%r14), %rdi
movq %r15, %rsi
callq 0x3a404
movq %rax, 0x40(%r14)
leaq 0x20(%r14), %rdx
leaq 0x24(%r14), %rcx
leaq 0x10(%r14), %r8
leaq 0x18(%r14), %r9
leaq 0x78aa1(%rip), %rsi     # 0xa58ec
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
leaq 0x74(%r14), %rdx
leaq 0x68(%r14), %rcx
leaq 0x78a96(%rip), %r15     # 0xa58fa
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 0x2cf2c
movslq 0x20(%r14), %rdi
shlq $0x3, %rdi
leaq 0x78a35(%rip), %rsi     # 0xa5907
movl $0xc, %edx
callq 0x390f5
movq %rax, 0x30(%r14)
cmpl $0x0, 0x20(%r14)
jle 0x2cf34
leaq 0x7800a(%rip), %r15     # 0xa4ef8
leaq 0x30(%rsp), %r12
xorl %r13d, %r13d
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 0x3a404
movq 0x30(%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
movslq 0x20(%r14), %rax
cmpq %rax, %r13
jl 0x2cef6
jmp 0x2cf34
movq $0x0, 0x30(%r14)
leaq 0x78(%r14), %rdx
leaq 0xa8(%r14), %rcx
leaq 0x98(%r14), %r8
leaq 0x78996(%rip), %rsi     # 0xa58e3
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
cmpl $0x0, 0x78(%r14)
je 0x2d0c6
leaq 0x77f8f(%rip), %rsi     # 0xa4ef8
leaq 0x30(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4070
movq 0xb0(%r14), %rdi
movq %r15, %rsi
callq 0x3a404
movq %rax, 0xb0(%r14)
leaq 0x90(%r14), %rdx
leaq 0x94(%r14), %rcx
leaq 0x80(%r14), %r8
leaq 0x88(%r14), %r9
leaq 0x78938(%rip), %rsi     # 0xa58ec
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
leaq 0xe4(%r14), %rdx
leaq 0xd8(%r14), %rcx
leaq 0x78927(%rip), %r15     # 0xa58fa
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 0x2d0dc
movslq 0x90(%r14), %rdi
shlq $0x3, %rdi
leaq 0x788aa(%rip), %rsi     # 0xa5907
movl $0xc, %edx
callq 0x390f5
movq %rax, 0xa0(%r14)
cmpl $0x0, 0x90(%r14)
jle 0x2d0e7
leaq 0x77e79(%rip), %r15     # 0xa4ef8
leaq 0x30(%rsp), %r12
xorl %r13d, %r13d
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 0x3a404
movq 0xa0(%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
movslq 0x90(%r14), %rax
cmpq %rax, %r13
jl 0x2d087
jmp 0x2d0e7
movq $0x0, 0xb0(%r14)
movl $0x0, 0xa8(%r14)
movq $0x0, 0xa0(%r14)
movslq 0x124(%r14), %rax
shlq $0x5, %rax
leaq (%rax,%rax,2), %rdi
leaq 0x7880a(%rip), %rsi     # 0xa5907
movl $0x19, %edx
callq 0x390f5
movq %rax, 0x128(%r14)
cmpl $0x0, 0x124(%r14)
jle 0x2d321
movl $0x38, %r13d
leaq 0x80a34(%rip), %r12     # 0xadb5d
xorl %r15d, %r15d
movq %rbx, 0x20(%rsp)
movq 0x128(%r14), %rax
movq %r15, %rcx
shlq $0x5, %rcx
leaq (%rcx,%rcx,2), %rbp
leaq (%rax,%rbp), %rcx
addq $0x24, %rcx
leaq 0x20(%rax,%rbp), %r8
movq %rbx, %rdi
leaq 0x78789(%rip), %rsi     # 0xa58e3
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 0x7876f(%rip), %rsi     # 0xa58fa
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 0x2d30a
leaq (%rax,%rbp), %r9
leaq 0x7866d(%rip), %rdx     # 0xa5838
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 0x78704(%rip), %rsi     # 0xa58f2
xorl %eax, %eax
callq 0x4070
movq %rbx, %rdi
leaq 0x77cf9(%rip), %rsi     # 0xa4ef8
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 0x20(%rsp), %rbx
callq 0x3a404
movq 0x128(%r14), %rcx
movq %rax, 0x38(%rcx,%rbp)
jmp 0x2d30a
leaq 0x28(%r9), %r8
leaq 0x38(%r9), %rdx
leaq 0x40(%r9), %rcx
addq $0x30, %r9
movq %rbx, %rdi
leaq 0x786be(%rip), %rsi     # 0xa5916
jmp 0x2d2e1
leaq 0x28(%r9), %rdx
addq $0x30, %r9
movq %rbx, %rdi
leaq 0x7aa19(%rip), %rsi     # 0xa7c88
movq %r9, %rcx
xorl %eax, %eax
callq 0x4070
xorl %ebp, %ebp
movq 0x128(%r14), %rdx
addq %r13, %rdx
addq %rbp, %rdx
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x4070
addq $0x4, %rbp
cmpq $0x28, %rbp
jne 0x2d27b
jmp 0x2d30a
leaq 0x28(%r9), %rdx
addq $0x30, %r9
movq %rbx, %rdi
leaq 0x7863f(%rip), %rsi     # 0xa58f2
movq %r9, %rcx
xorl %eax, %eax
callq 0x4070
jmp 0x2d30a
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 0x78631(%rip), %rsi     # 0xa5912
xorl %eax, %eax
callq 0x4070
jmp 0x2d30a
leaq 0x28(%r9), %rdx
leaq 0x30(%r9), %rcx
addq $0x38, %r9
movq %rbx, %rdi
leaq 0x7861a(%rip), %rsi     # 0xa591a
movq %r9, %r8
xorl %eax, %eax
callq 0x4070
incq %r15
movslq 0x124(%r14), %rax
addq $0x60, %r13
cmpq %rax, %r15
jl 0x2d131
leaq 0xec(%r14), %rcx
leaq 0x785b7(%rip), %rsi     # 0xa58e6
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 0x7859a(%rip), %rsi     # 0xa58fa
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 0x78566(%rip), %rsi     # 0xa5907
movl $0x19, %edx
callq 0x390f5
movq %rax, 0x100(%r14)
movl 0xec(%r14), %eax
testl %eax, %eax
jle 0x2d409
leaq 0x77b34(%rip), %r15     # 0xa4ef8
leaq 0x30(%rsp), %r12
xorl %r13d, %r13d
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 0x3a404
movq 0x100(%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
movslq 0xec(%r14), %rax
cmpq %rax, %r13
jl 0x2d3cc
movslq %eax, %rdi
shlq $0x2, %rdi
leaq 0x784f0(%rip), %rsi     # 0xa5907
movl $0x1a, %edx
callq 0x390f5
movq %rax, 0xf0(%r14)
movl 0xec(%r14), %eax
testl %eax, %eax
jle 0x2d470
leaq 0x80723(%rip), %r15     # 0xadb5d
leaq 0x14(%rsp), %r12
xorl %r13d, %r13d
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
movslq 0xec(%r14), %rax
cmpq %rax, %r13
jl 0x2d442
movslq %eax, %rdi
leaq 0x7848d(%rip), %rsi     # 0xa5907
movl $0x1e, %edx
callq 0x390f5
movq %rax, 0xf8(%r14)
cmpl $0x0, 0xec(%r14)
jle 0x2d4c5
leaq 0x798c4(%rip), %r15     # 0xa6d60
xorl %r12d, %r12d
movq 0xf8(%r14), %rdx
addq %r12, %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x4070
incq %r12
movslq 0xec(%r14), %rax
cmpq %rax, %r12
jl 0x2d49f
movq %rbx, %rdi
callq 0x42a0
addq $0x7a158, %rsp          # imm = 0x7A158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq