// File: /workspace/github_c_makefile_star2_O3/GregorR[P]lstg/ImageBuilder/imageBuilder.c
// Function: imageOut
void imageOut(FILE * fp, struct object *obj)
{
  int             i,
                  size;

  if(imageTop > imageMaxNumberOfObjects)
  {
    fprintf(stderr, "too many indirect objects\n");
    exit(1);
  }

  /*
     printf("writing out object %d\n", obj);
   */

  if(obj == 0)
  {
    sysError("writing out null object", "");
    return;
  }

  /*
     Integer objects are simply encoded as the binary value 
   */
  if(IS_SMALLINT(obj))
  {
    int             val = HTONL(integerValue(obj));

    writeWord(2, fp);
    fwrite(&val, sizeof(val), 1, fp);
    return;
  }

  /*
     see if already written 
   */
  for(i = 0; i < imageTop; i++)
  {
    if(obj == writtenObjects[i])
    {
      if(i == 0)
        writeWord(5, fp);
      else
      {
        writeWord(4, fp);
        writeWord(i, fp);
      }
      return;
    }
  }

  /*
     not written, do it now 
   */
  writtenObjects[imageTop++] = obj;

  if(obj->size & FLAG_BIN)
  {                             /* byte objects */
    struct byteObject *bobj = (struct byteObject *) obj;

    size = SIZE(obj);
    writeWord(3, fp);
    writeWord(size, fp);
    /* fprintf(fp, "3 %d \n", size); */
    for(i = 0; i < size; i++)
    {
      /* fprintf(fp," %d ", bobj->bytes[i]); */
      writeWord(bobj->bytes[i], fp);
      /* fprintf(fp,"\n"); */
    }
    if(obj->class == 0)
    {
      printf("byte object 0x%p has null class\n", obj);
    }
    imageOut(fp, obj->class);
    return;
  }

  /*
     ordinary objects 
   */
  size = SIZE(obj);
  /*
     fprintf(fp,"1 %d ", size);
   */
  writeWord(1, fp);
  writeWord(size, fp);
  if(obj->class == 0)
  {
    printf("object 0x%p has null class\n", obj);
  }
  imageOut(fp, obj->class);
  for(i = 0; i < size; i++)
  {
    imageOut(fp, obj->data[i]);
  }
  /*
     fprintf(fp,"\n");
   */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x37c0b(%rip), %eax     # 0x3b560
cmpl $0x2710, %eax           # imm = 0x2710
jg 0x3a2f
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x37c03(%rip), %r13     # 0x3b570
leaq 0x1b2d(%rip), %r15      # 0x54a1
testq %r14, %r14
je 0x3b02
testb $0x1, %r14b
jne 0x3a66
testl %eax, %eax
jle 0x39a8
movl %eax, %ecx
movq %r13, %rdx
xorl %r12d, %r12d
cmpq %r14, (%rdx)
je 0x3a34
incq %r12
addq $0x8, %rdx
cmpq %r12, %rcx
jne 0x3993
leal 0x1(%rax), %ecx
movl %ecx, 0x37baf(%rip)     # 0x3b560
cltq
movq %r14, (%r13,%rax,8)
movl (%r14), %ebp
movl %ebp, %r12d
shrl $0x2, %r12d
testb $0x2, %bpl
je 0x3a95
movl $0x3, %edi
movq %rbx, %rsi
callq 0x38e3
movl %r12d, %edi
movq %rbx, %rsi
callq 0x38e3
cmpl $0x4, %ebp
jb 0x3a01
xorl %ebp, %ebp
movzbl 0x10(%r14,%rbp), %edi
movq %rbx, %rsi
callq 0x38e3
incq %rbp
cmpq %rbp, %r12
jne 0x39eb
movq 0x8(%r14), %rcx
testq %rcx, %rcx
jne 0x3a1b
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x10a0
movq 0x8(%r14), %rcx
movl 0x37b3f(%rip), %eax     # 0x3b560
movq %rcx, %r14
cmpl $0x2710, %eax           # imm = 0x2710
jle 0x3974
callq 0x1180
testq %r12, %r12
je 0x3a4b
movl $0x4, %edi
movq %rbx, %rsi
callq 0x38e3
movl %r12d, %edi
jmp 0x3a50
movl $0x5, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x38e3
shrq %r14
leaq 0x4(%rsp), %r15
movl %r14d, (%r15)
movl $0x2, %edi
movq %rbx, %rsi
callq 0x38e3
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x1150
jmp 0x3af3
movl $0x1, %edi
movq %rbx, %rsi
callq 0x38e3
movl %r12d, %edi
movq %rbx, %rsi
callq 0x38e3
movq 0x8(%r14), %rsi
testq %rsi, %rsi
jne 0x3acb
leaq 0x19e9(%rip), %rdi      # 0x54a6
movq %r14, %rsi
xorl %eax, %eax
callq 0x10a0
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x3944
cmpl $0x4, %ebp
jb 0x3af3
movl %r12d, %r15d
xorl %r12d, %r12d
movq 0x10(%r14,%r12,8), %rsi
movq %rbx, %rdi
callq 0x3944
incq %r12
cmpq %r12, %r15
jne 0x3ade
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1537(%rip), %rdi      # 0x5040
leaq 0x1979(%rip), %rsi      # 0x5489
leaq 0x1a5b(%rip), %rdx      # 0x5572
xorl %eax, %eax
callq 0x10a0
movl $0x1, %edi
callq 0x1140