// File: /workspace/github_c_makefile_star2_O3/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 0x2e342
leaq 0x7e31a(%rip), %rsi     # 0xab95b
movq %rbx, %rdi
callq 0x40f0
movq %rax, %rbx
leaq 0x384a65(%rip), %r14    # 0x3b20b8
leaq 0x4(%r14), %rdx
leaq 0x124(%r14), %r8
leaq 0x7b2f3(%rip), %rsi     # 0xa8958
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 0x7b2c4(%rip), %rsi     # 0xa895b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
leaq 0x7a8a8(%rip), %rsi     # 0xa7f50
leaq 0x30(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4070
movq 0x40(%r14), %rdi
movq %r15, %rsi
callq 0x3b494
movq %rax, 0x40(%r14)
leaq 0x20(%r14), %rdx
leaq 0x24(%r14), %rcx
leaq 0x10(%r14), %r8
leaq 0x18(%r14), %r9
leaq 0x7b283(%rip), %rsi     # 0xa8964
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
leaq 0x74(%r14), %rdx
leaq 0x68(%r14), %rcx
leaq 0x7b278(%rip), %r15     # 0xa8972
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 0x2d7c2
movslq 0x20(%r14), %rdi
shlq $0x3, %rdi
leaq 0x7b217(%rip), %rsi     # 0xa897f
movl $0xc, %edx
callq 0x3a0e1
movq %rax, 0x30(%r14)
cmpl $0x0, 0x20(%r14)
jle 0x2d7ca
leaq 0x7a7cc(%rip), %r15     # 0xa7f50
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 0x3b494
movq 0x30(%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
movslq 0x20(%r14), %rax
cmpq %rax, %r13
jl 0x2d78c
jmp 0x2d7ca
movq $0x0, 0x30(%r14)
leaq 0x78(%r14), %rdx
leaq 0xa8(%r14), %rcx
leaq 0x98(%r14), %r8
leaq 0x7b178(%rip), %rsi     # 0xa895b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
cmpl $0x0, 0x78(%r14)
je 0x2d95c
leaq 0x7a751(%rip), %rsi     # 0xa7f50
leaq 0x30(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4070
movq 0xb0(%r14), %rdi
movq %r15, %rsi
callq 0x3b494
movq %rax, 0xb0(%r14)
leaq 0x90(%r14), %rdx
leaq 0x94(%r14), %rcx
leaq 0x80(%r14), %r8
leaq 0x88(%r14), %r9
leaq 0x7b11a(%rip), %rsi     # 0xa8964
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4070
leaq 0xe4(%r14), %rdx
leaq 0xd8(%r14), %rcx
leaq 0x7b109(%rip), %r15     # 0xa8972
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 0x2d972
movslq 0x90(%r14), %rdi
shlq $0x3, %rdi
leaq 0x7b08c(%rip), %rsi     # 0xa897f
movl $0xc, %edx
callq 0x3a0e1
movq %rax, 0xa0(%r14)
cmpl $0x0, 0x90(%r14)
jle 0x2d97d
leaq 0x7a63b(%rip), %r15     # 0xa7f50
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 0x3b494
movq 0xa0(%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
movslq 0x90(%r14), %rax
cmpq %rax, %r13
jl 0x2d91d
jmp 0x2d97d
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 0x7afec(%rip), %rsi     # 0xa897f
movl $0x19, %edx
callq 0x3a0e1
movq %rax, 0x128(%r14)
cmpl $0x0, 0x124(%r14)
jle 0x2dbb7
movl $0x38, %r13d
leaq 0x83236(%rip), %r12     # 0xb0bf5
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 0x7af6b(%rip), %rsi     # 0xa895b
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 0x7af51(%rip), %rsi     # 0xa8972
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 0x2dba0
leaq (%rax,%rbp), %r9
leaq 0x7ae2f(%rip), %rdx     # 0xa8890
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 0x7aee6(%rip), %rsi     # 0xa896a
xorl %eax, %eax
callq 0x4070
movq %rbx, %rdi
leaq 0x7a4bb(%rip), %rsi     # 0xa7f50
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 0x3b494
movq 0x128(%r14), %rcx
movq %rax, 0x38(%rcx,%rbp)
jmp 0x2dba0
leaq 0x28(%r9), %r8
leaq 0x38(%r9), %rdx
leaq 0x40(%r9), %rcx
addq $0x30, %r9
movq %rbx, %rdi
leaq 0x7aea0(%rip), %rsi     # 0xa898e
jmp 0x2db77
leaq 0x28(%r9), %rdx
addq $0x30, %r9
movq %rbx, %rdi
leaq 0x7d233(%rip), %rsi     # 0xaad38
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 0x2db11
jmp 0x2dba0
leaq 0x28(%r9), %rdx
addq $0x30, %r9
movq %rbx, %rdi
leaq 0x7ae21(%rip), %rsi     # 0xa896a
movq %r9, %rcx
xorl %eax, %eax
callq 0x4070
jmp 0x2dba0
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 0x7ae13(%rip), %rsi     # 0xa898a
xorl %eax, %eax
callq 0x4070
jmp 0x2dba0
leaq 0x28(%r9), %rdx
leaq 0x30(%r9), %rcx
addq $0x38, %r9
movq %rbx, %rdi
leaq 0x7adfc(%rip), %rsi     # 0xa8992
movq %r9, %r8
xorl %eax, %eax
callq 0x4070
incq %r15
movslq 0x124(%r14), %rax
addq $0x60, %r13
cmpq %rax, %r15
jl 0x2d9c7
leaq 0xec(%r14), %rcx
leaq 0x7ad99(%rip), %rsi     # 0xa895e
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 0x7ad7c(%rip), %rsi     # 0xa8972
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 0x7ad48(%rip), %rsi     # 0xa897f
movl $0x19, %edx
callq 0x3a0e1
movq %rax, 0x100(%r14)
movslq 0xec(%r14), %rdi
testq %rdi, %rdi
jle 0x2dca0
leaq 0x7a2f5(%rip), %r15     # 0xa7f50
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 0x3b494
movq 0x100(%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
movslq 0xec(%r14), %rdi
cmpq %rdi, %r13
jl 0x2dc63
shlq $0x2, %rdi
leaq 0x7acd4(%rip), %rsi     # 0xa897f
movl $0x1a, %edx
callq 0x3a0e1
movq %rax, 0xf0(%r14)
movslq 0xec(%r14), %rdi
testq %rdi, %rdi
jle 0x2dd05
leaq 0x82f26(%rip), %r15     # 0xb0bf5
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), %rdi
cmpq %rdi, %r13
jl 0x2dcd7
leaq 0x7ac73(%rip), %rsi     # 0xa897f
movl $0x1e, %edx
callq 0x3a0e1
movq %rax, 0xf8(%r14)
cmpl $0x0, 0xec(%r14)
jle 0x2dd57
leaq 0x7c0a2(%rip), %r15     # 0xa9dd0
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 0x2dd31
movq %rbx, %rdi
callq 0x42a0
addq $0x7a158, %rsp          # imm = 0x7A158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq