// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DASCRUBBER/DB.c
// Function: Read_Extra
int Read_Extra(FILE *afile, char *aname, DAZZ_EXTRA *extra)
{ int   vtype, nelem, accum, slen;
  char *name;
  void *value;

#define EREAD(v,s,n,file,ret)                                                           \
  { if (fread(v,s,n,file) != (size_t) n)                                                \
      { if (ferror(file))                                                               \
          EPRINTF(EPLACE,"%s: System error, read failed!\n",Prog_Name);       		\
        else if (ret)                                                                   \
          return (1);									\
        else										\
          EPRINTF(EPLACE,"%s: The file %s is corrupted\n",Prog_Name,aname);		\
        EXIT(-1);									\
      }                                                                                 \
  }

  EREAD(&vtype,sizeof(int),1,afile,1)
  EREAD(&nelem,sizeof(int),1,afile,0)
  EREAD(&accum,sizeof(int),1,afile,0)
  EREAD(&slen,sizeof(int),1,afile,0)

  if (extra == NULL)
    { if (fseeko(afile,slen+8*nelem,SEEK_CUR) < 0)
        { EPRINTF(EPLACE,"%s: System error, read failed!\n",Prog_Name);
          EXIT(-1);
        }
      return (0);
    }

  name  = (char *) Malloc(slen+1,"Allocating extra name");
  value = Malloc(8*nelem,"Allocating extra value");
  if (value == NULL || name == NULL)
    { free(name);
      free(value);
      EXIT(-1);
    }

  EREAD(name,1,slen,afile,0);
  EREAD(value,8,nelem,afile,0);
  name[slen] = '\0';
  
  if (extra->nelem == 0)
    { extra->vtype = vtype;
      extra->nelem = nelem;
      extra->accum = accum;
      extra->name  = name;
      extra->value = value;
      return (0);
    }

  if (vtype != extra->vtype)
    { EPRINTF(EPLACE,"%s: Type of extra %s does not agree with previous .anno block files\n",
                     Prog_Name,name);
      goto error;
    }
  if (nelem != extra->nelem)
    { EPRINTF(EPLACE,"%s: Length of extra %s does not agree with previous .anno block files\n",
                     Prog_Name,name);
      goto error;
    }
  if (accum != extra->accum)
    { EPRINTF(EPLACE,
           "%s: Reduction indicator of extra %s does not agree with previous .anno block files\n",
           Prog_Name,name);
      goto error;
    }
  if (strcmp(name,extra->name) != 0)
    { EPRINTF(EPLACE,"%s: Expecting extra %s in .anno block file, not %s\n",
                     Prog_Name,extra->name,name);
      goto error;
    }

  if (vtype == DB_INT)
    { int64 *ival = (int64 *) value;
      int64 *eval = (int64 *) (extra->value);
      int    j;

      if (accum == DB_EXACT)
        { for (j = 0; j < nelem; j++)
            if (eval[j] != ival[j])
              { EPRINTF(EPLACE,
                    "%s: Value of extra %s doe not agree with previous .anno block files\n",
                    Prog_Name,name);
                goto error;
              }
        }
      else
        { for (j = 0; j < nelem; j++)
            eval[j] += ival[j];
        }
    }

  else
    { double *ival = (double *) value;
      double *eval = (double *) (extra->value);
      int     j;

      if (accum == DB_EXACT)
        { for (j = 0; j < nelem; j++)
            if (eval[j] != ival[j])
              { EPRINTF(EPLACE,
                    "%s: Value of extra %s doe not agree with previous .anno block files\n",
                    Prog_Name,name);
                goto error;
              }
        }
      else
        { for (j = 0; j < nelem; j++)
            eval[j] += ival[j];
        }
    }

  free(value);
  free(name);
  return (0);

error:
  free(value);
  free(name);
  EXIT(-2);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r13
leaq 0x1c(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x5516
leaq 0x14(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x5693
leaq 0x10(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x5693
leaq 0x18(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x5693
movslq 0x18(%rsp), %rbp
testq %r12, %r12
je 0x552a
movq %rbx, 0x20(%rsp)
leaq 0x1(%rbp), %rdi
leaq 0x46b7(%rip), %rsi      # 0x9aa9
callq 0x1bad
movq %rax, %r14
movl 0x14(%rsp), %ebx
movslq %ebx, %r15
leaq (,%r15,8), %rdi
leaq 0x46af(%rip), %rsi      # 0x9abf
callq 0x1bad
movq %r14, %rdi
movq %rax, %r14
testq %rdi, %rdi
je 0x5704
testq %r14, %r14
je 0x5704
pushq $0x1
popq %rsi
movq %rdi, 0x8(%rsp)
movq %rbp, %rdx
movq %r13, %rcx
callq 0x10b0
cmpq %rbp, %rax
jne 0x56bc
pushq $0x8
popq %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %r13, %rcx
callq 0x10b0
cmpq %r15, %rax
jne 0x56bc
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rbp)
movl 0x4(%r12), %eax
movl 0x1c(%rsp), %ebp
testl %eax, %eax
je 0x5563
cmpl (%r12), %ebp
jne 0x55d7
cmpl %eax, %ebx
jne 0x55f1
movl 0x10(%rsp), %r13d
cmpl 0x8(%r12), %r13d
jne 0x560b
movq 0x10(%r12), %r15
movq %rcx, %rdi
movq %r15, %rsi
callq 0x1190
testl %eax, %eax
jne 0x562f
xorl %eax, %eax
testl %ebx, %ebx
cmovgl %ebx, %eax
movq 0x18(%r12), %rcx
xorl %edx, %edx
testl %ebp, %ebp
je 0x5581
testl %r13d, %r13d
jne 0x54e7
jmp 0x550c
movsd (%r14,%rdx,8), %xmm0
addsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x54d4
jmp 0x55b4
movsd (%rcx,%rdx,8), %xmm0
ucomisd (%r14,%rdx,8), %xmm0
leaq 0x1(%rdx), %rdx
jne 0x5671
jp 0x5671
cmpq %rdx, %rax
jne 0x54f1
jmp 0x55b4
movq %r13, %rdi
callq 0x10a0
testl %eax, %eax
jne 0x554d
pushq $0x1
popq %rax
jmp 0x55c8
movslq 0x14(%rsp), %rax
leaq (,%rax,8), %rsi
addq %rbp, %rsi
pushq $0x1
popq %rdx
movq %r13, %rdi
callq 0x1230
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
jns 0x55c8
movq 0x8aa4(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xb38a(%rip), %rdx      # 0x108e8
jmp 0x56f1
movl %ebp, (%r12)
movl %ebx, 0x4(%r12)
movl 0x10(%rsp), %eax
movl %eax, 0x8(%r12)
movq %rcx, 0x10(%r12)
movq %r14, 0x18(%r12)
jmp 0x55c6
testl %r13d, %r13d
jne 0x5593
jmp 0x55af
movq (%r14,%rdx,8), %rsi
addq %rsi, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5588
jmp 0x55b4
movq (%rcx,%rdx,8), %rsi
leaq 0x1(%rdx), %rdi
cmpq (%r14,%rdx,8), %rsi
movq %rdi, %rdx
jne 0x5671
cmpq %rdx, %rax
jne 0x559a
movq %r14, %rdi
callq 0x1030
movq 0x8(%rsp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8a1a(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xb300(%rip), %rdx      # 0x108e8
leaq 0x44e7(%rip), %rsi      # 0x9ad6
jmp 0x5623
movq 0x8a00(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xb2e6(%rip), %rdx      # 0x108e8
leaq 0x4512(%rip), %rsi      # 0x9b1b
jmp 0x5623
movq 0x89e6(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xb2cc(%rip), %rdx      # 0x108e8
leaq 0x453f(%rip), %rsi      # 0x9b62
movq %rcx, %rbx
xorl %eax, %eax
callq 0x11a0
jmp 0x5659
movq 0x89c2(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xb2a8(%rip), %rdx      # 0x108e8
leaq 0x456f(%rip), %rsi      # 0x9bb6
movq %r15, %rcx
movq 0x8(%rsp), %rbx
movq %rbx, %r8
xorl %eax, %eax
callq 0x11a0
movq %r14, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
pushq $0x1
popq %rdi
callq 0x1270
movq 0x8980(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xb266(%rip), %rdx      # 0x108e8
leaq 0x4561(%rip), %rsi      # 0x9bea
movq 0x8(%rsp), %rbx
movq %rbx, %rcx
jmp 0x5626
movq %r13, %rdi
callq 0x10a0
movq 0x8956(%rip), %rcx      # 0xdff8
movq (%rcx), %rdi
movq 0xb23c(%rip), %rdx      # 0x108e8
testl %eax, %eax
jne 0x56f1
leaq 0x43d4(%rip), %rsi      # 0x9a8b
movq %rbx, %rcx
jmp 0x56e5
movq %r13, %rdi
callq 0x10a0
movq 0x892d(%rip), %rcx      # 0xdff8
movq (%rcx), %rdi
movq 0xb213(%rip), %rdx      # 0x108e8
testl %eax, %eax
jne 0x56f1
leaq 0x43ab(%rip), %rsi      # 0x9a8b
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0x5669
leaq 0x3925(%rip), %rsi      # 0x901d
xorl %eax, %eax
callq 0x11a0
jmp 0x5669
callq 0x1030
movq %r14, %rdi
jmp 0x5664