// File: /workspace/github_c_makefile_star2_O2/GregorR[P]lstg/source/memory.c
// Function: objectRead
static struct object *objectRead(FILE * fp)
{
  int             type,
                  size,
                  i;
  struct object  *newObj = 0;
  struct byteObject *bnewObj;

  type = readWord(fp);

  switch (type)
  {
    case 0:                    /* nil obj */
      sysError("read in a null object", 0);

    case 1:                    /* ordinary object */
      size = readWord(fp);
      newObj = staticAllocate(size);
      indirArray[indirtop++] = newObj;
      newObj->class = objectRead(fp);
      for(i = 0; i < size; i++)
        newObj->data[i] = objectRead(fp);
      break;

    case 2:                    /* integer */
    {
      int             val;

      (void) fread(&val, sizeof(val), 1, fp);
      newObj = newInteger(NTOHS(val));
    }
      break;

    case 3:                    /* byte arrays */
      size = readWord(fp);
      newObj = staticIAllocate(size);
      indirArray[indirtop++] = newObj;
      bnewObj = (struct byteObject *) newObj;
      for(i = 0; i < size; i++)
      {
        type = readWord(fp);
        bnewObj->bytes[i] = type;
      }
      bnewObj->class = objectRead(fp);
      break;

    case 4:                    /* previous object */
      size = readWord(fp);
      newObj = indirArray[size];
      break;

    case 5:                    /* object 0 (nil object) */
      newObj = indirArray[0];
      break;
  }
  return newObj;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x522d
cmpl $0x5, %eax
ja 0x4c75
movl %eax, %eax
leaq 0x27e7(%rip), %rcx      # 0x733c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x291b(%rip), %rdi      # 0x7480
xorl %esi, %esi
callq 0x3fac
movq %rbx, %rdi
callq 0x522d
movl %eax, %r15d
movl %eax, %edi
callq 0x4924
movq %rax, %r14
movq 0x41ff8(%rip), %rax     # 0x46b80
movslq 0x42001(%rip), %rcx     # 0x46b90
leal 0x1(%rcx), %edx
movl %edx, 0x41ff8(%rip)     # 0x46b90
movq %r14, (%rax,%rcx,8)
movq %rbx, %rdi
callq 0x4b33
movq %rax, 0x8(%r14)
xorl %r12d, %r12d
testl %r15d, %r15d
cmovlel %r12d, %r15d
cmpq %r12, %r15
je 0x4c78
movq %rbx, %rdi
callq 0x4b33
movq %rax, 0x10(%r14,%r12,8)
incq %r12
jmp 0x4bb2
movq %rbx, %rdi
callq 0x522d
movq 0x41fa4(%rip), %rcx     # 0x46b80
cltq
movq (%rcx,%rax,8), %r14
jmp 0x4c78
leaq 0x4(%rsp), %r14
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x20c0
movslq (%r14), %rax
leaq 0x1(,%rax,2), %r14
jmp 0x4c78
movq %rbx, %rdi
callq 0x522d
movl %eax, %r15d
movl %eax, %edi
callq 0x4969
movq %rax, %r14
movq 0x41f5a(%rip), %rax     # 0x46b80
movslq 0x41f63(%rip), %rcx     # 0x46b90
leal 0x1(%rcx), %edx
movl %edx, 0x41f5a(%rip)     # 0x46b90
movq %r14, (%rax,%rcx,8)
xorl %r12d, %r12d
testl %r15d, %r15d
cmovlel %r12d, %r15d
cmpq %r12, %r15
je 0x4c5b
movq %rbx, %rdi
callq 0x522d
movb %al, 0x10(%r14,%r12)
incq %r12
jmp 0x4c44
movq %rbx, %rdi
callq 0x4b33
movq %rax, 0x8(%r14)
jmp 0x4c78
movq 0x41f10(%rip), %rax     # 0x46b80
movq (%rax), %r14
jmp 0x4c78
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq