// File: /workspace/github_c_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
callq 0x5773
cmpl $0x5, %eax
ja 0x518b
movl %eax, %eax
leaq 0x22fe(%rip), %rcx      # 0x7348
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2432(%rip), %rdi      # 0x748c
xorl %esi, %esi
callq 0x4418
movq %rbx, %rdi
callq 0x5773
movl %eax, %ebp
movl %eax, %edi
callq 0x4e05
movq %rax, %r14
movq 0x41b04(%rip), %rax     # 0x46b80
movslq 0x41b0d(%rip), %rcx     # 0x46b90
leal 0x1(%rcx), %edx
movl %edx, 0x41b04(%rip)     # 0x46b90
movq %r14, (%rax,%rcx,8)
movq %rbx, %rdi
callq 0x5024
movq %rax, 0x8(%r14)
testl %ebp, %ebp
jle 0x518e
movl %ebp, %r15d
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x5024
movq %rax, 0x10(%r14,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0x50aa
jmp 0x518e
movq %rbx, %rdi
callq 0x5773
movq 0x41aad(%rip), %rcx     # 0x46b80
cltq
movq (%rcx,%rax,8), %r14
jmp 0x518e
leaq 0xc(%rsp), %r14
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x20c0
movslq (%r14), %rax
leaq 0x1(,%rax,2), %r14
jmp 0x518e
movq %rbx, %rdi
callq 0x5773
movl %eax, %r15d
leal 0x7(%r15), %eax
leal 0xe(%r15), %edi
testl %eax, %eax
cmovnsl %eax, %edi
sarl $0x3, %edi
callq 0x4e05
movq %rax, %r14
leal 0x2(,%r15,4), %eax
movl %eax, (%r14)
movq 0x41a43(%rip), %rax     # 0x46b80
movslq 0x41a4c(%rip), %rcx     # 0x46b90
leal 0x1(%rcx), %edx
movl %edx, 0x41a43(%rip)     # 0x46b90
movq %r14, (%rax,%rcx,8)
testl %r15d, %r15d
jle 0x5171
movl %r15d, %r15d
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x5773
movb %al, 0x10(%r14,%r12)
incq %r12
cmpq %r12, %r15
jne 0x515c
movq %rbx, %rdi
callq 0x5024
movq %rax, 0x8(%r14)
jmp 0x518e
movq 0x419fa(%rip), %rax     # 0x46b80
movq (%rax), %r14
jmp 0x518e
xorl %r14d, %r14d
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq