// File: /workspace/github_c_makefile_star2_O3/GregorR[P]lstg/ImageBuilder/imageBuilder.c
// Function: main
int main(void)
{
  FILE           *fd;
  struct object  *bootMethod = 0;

  /*
     big bang -- create the first classes 
   */
  bigBang();
  addArgument("self");

  if((fin = fopen(defaultInputName, "rb")) == NULL)
    sysError("file in error", defaultInputName);

  /*
     then read the image source file 
   */
  lineNo = 1;
  while(fgets((char *) inputBuffer, 1000, fin))
  {
    lineNo++;
    p = inputBuffer;
    skipSpaces();
    readIdentifier();

    if(strcmp(tokenBuffer, "") == 0)
    {
      /* ignore empty line */
    }
    else if(strcmp(tokenBuffer, "BEGIN") == 0)
    {
      bootMethod = BeginCommand();
    }
    else if(strcmp(tokenBuffer, "RAWCLASS") == 0)
    {
      RawClassCommand();
    }
    else if(strcmp(tokenBuffer, "CLASS") == 0)
    {
      ClassCommand();
    }
    else if(strcmp(tokenBuffer, "COMMENT") == 0)
    {
      /*
         nothing 
       */ ;
    }
    else if(strcmp(tokenBuffer, "METHOD") == 0)
    {
      MethodCommand();
    }
    else if(strcmp(tokenBuffer, "END") == 0)
    {
      break;
    }
    else
    {
      sysError("unknown command ", tokenBuffer);
    }
  }

  fclose(fin);

  /*
     then create the tree of symbols 
   */
  SymbolClass->data[symbolsInMetaSymbol] = fixSymbols();
  fixGlobals();

  /*
     see if anything was never defined in the class source 
   */
  checkGlobals();

  if((fd = fopen(defaultImageName, "wb")) == NULL)
  {
    sysError("file out error", "image");
  }
  printf("starting to file out\n");
  imageOut(fd, nilObject);
  imageOut(fd, trueObject);
  imageOut(fd, falseObject);
  imageOut(fd, globalValues);
  imageOut(fd, SmallIntClass);
  imageOut(fd, IntegerClass);
  imageOut(fd, ArrayClass);
  imageOut(fd, BlockClass);
  imageOut(fd, lookupGlobal("Context", 0));
  imageOut(fd, StringClass);
  imageOut(fd, bootMethod);
  imageOut(fd, newSymbol("<"));
  imageOut(fd, newSymbol("<="));
  imageOut(fd, newSymbol("+"));
  imageOut(fd, newSymbol("doesNotUnderstand:"));
  fclose(fd);
  printf("%d objects written\n", imageTop);
  printf("bye for now!\n");
  return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x1d7b
leaq 0x1716(%rip), %rdi      # 0x54df
callq 0x1cd1
leaq 0x15a7(%rip), %rdi      # 0x537c
leaq 0x1708(%rip), %rsi      # 0x54e4
callq 0x1110
movq %rax, 0x2c478(%rip)     # 0x30260
testq %rax, %rax
je 0x40be
movl $0x1, 0x2c46d(%rip)     # 0x30268
leaq 0x434e(%rip), %r14      # 0x8150
movq %r14, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
movq %rax, %rdx
callq 0x10d0
xorl %ebx, %ebx
testq %rax, %rax
je 0x3f0b
movl $0x49474542, %ebp       # imm = 0x49474542
movabsq $0x5353414c43574152, %r15 # imm = 0x5353414C43574152
movl $0x53414c43, %r12d      # imm = 0x53414C43
movabsq $0x544e454d4d4f43, %r13 # imm = 0x544E454D4D4F43
incl 0x2c426(%rip)           # 0x30268
movq %r14, 0x5307(%rip)      # 0x9150
callq 0x15b7
callq 0x169e
cmpb $0x0, 0x2c416(%rip)     # 0x30270
je 0x3eee
movl 0x2c40a(%rip), %eax     # 0x30270
xorl %ebp, %eax
movzwl 0x2c405(%rip), %ecx     # 0x30274
xorl $0x4e, %ecx
orl %eax, %ecx
je 0x3ed8
movq 0x2c3f3(%rip), %rax     # 0x30270
xorq %r15, %rax
movzbl 0x2c3f1(%rip), %ecx     # 0x30278
orq %rax, %rcx
je 0x3ee2
movl 0x2c3de(%rip), %eax     # 0x30270
xorl %r12d, %eax
movzwl 0x2c3d8(%rip), %ecx     # 0x30274
xorl $0x53, %ecx
orl %eax, %ecx
je 0x3ee9
movq 0x2c3c6(%rip), %rax     # 0x30270
cmpq %r13, %rax
je 0x3eee
movl 0x2c3bb(%rip), %ecx     # 0x30270
movl $0x4854454d, %edx       # imm = 0x4854454D
xorl %edx, %ecx
movl 0x2c3b1(%rip), %edx     # 0x30273
movl $0x444f48, %esi         # imm = 0x444F48
xorl %esi, %edx
orl %ecx, %edx
jne 0x409c
callq 0x35da
jmp 0x3eee
callq 0x33fb
movq %rax, %rbx
jmp 0x3eee
callq 0x3699
jmp 0x3eee
callq 0x3824
movq 0x2c36b(%rip), %rdx     # 0x30260
movq %r14, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x10d0
testq %rax, %rax
jne 0x3e3c
movq 0x2c34e(%rip), %rdi     # 0x30260
callq 0x1080
callq 0x3ba9
movq 0x375c5(%rip), %rcx     # 0x3b4e8
movq %rax, 0x40(%rcx)
callq 0x3c61
callq 0x3d58
leaq 0x15e4(%rip), %rdi      # 0x551c
leaq 0x15f3(%rip), %rsi      # 0x5532
callq 0x1110
testq %rax, %rax
je 0x40d5
movq %rax, %r14
leaq 0x1634(%rip), %rdi      # 0x558b
callq 0x1070
movq 0x41dd(%rip), %rsi      # 0x8140
movq %r14, %rdi
callq 0x3944
movq 0x3759e(%rip), %rsi     # 0x3b510
movq %r14, %rdi
callq 0x3944
movq 0x37597(%rip), %rsi     # 0x3b518
movq %r14, %rdi
callq 0x3944
movq 0x375a0(%rip), %rsi     # 0x3b530
movq %r14, %rdi
callq 0x3944
movq 0x37561(%rip), %rsi     # 0x3b500
movq %r14, %rdi
callq 0x3944
movq 0x3755a(%rip), %rsi     # 0x3b508
movq %r14, %rdi
callq 0x3944
movq 0x37563(%rip), %rsi     # 0x3b520
movq %r14, %rdi
callq 0x3944
movq 0x37524(%rip), %rsi     # 0x3b4f0
movq %r14, %rdi
callq 0x3944
leaq 0x1569(%rip), %rdi      # 0x5544
xorl %esi, %esi
callq 0x1496
movq %r14, %rdi
movq %rax, %rsi
callq 0x3944
movq 0x37534(%rip), %rsi     # 0x3b528
movq %r14, %rdi
callq 0x3944
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3944
leaq 0x1265(%rip), %rdi      # 0x5273
callq 0x180c
movq %r14, %rdi
movq %rax, %rsi
callq 0x3944
leaq 0x1250(%rip), %rdi      # 0x5275
callq 0x180c
movq %r14, %rdi
movq %rax, %rsi
callq 0x3944
leaq 0x123c(%rip), %rdi      # 0x5278
callq 0x180c
movq %r14, %rdi
movq %rax, %rsi
callq 0x3944
leaq 0x14f9(%rip), %rdi      # 0x554c
callq 0x180c
movq %r14, %rdi
movq %rax, %rsi
callq 0x3944
movq %r14, %rdi
callq 0x1080
movl 0x374ef(%rip), %esi     # 0x3b560
leaq 0x14e7(%rip), %rdi      # 0x555f
xorl %eax, %eax
callq 0x10a0
leaq 0x151a(%rip), %rdi      # 0x55a0
callq 0x1070
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x444e45, %eax         # imm = 0x444E45
je 0x3f0b
leaq 0xf92(%rip), %rdi       # 0x5040
leaq 0x1456(%rip), %rsi      # 0x550b
leaq 0x2c1b4(%rip), %rdx     # 0x30270
jmp 0x40ea
leaq 0xf7b(%rip), %rdi       # 0x5040
leaq 0x141b(%rip), %rsi      # 0x54e7
leaq 0x12a9(%rip), %rdx      # 0x537c
jmp 0x40ea
leaq 0xf64(%rip), %rdi       # 0x5040
leaq 0x1452(%rip), %rsi      # 0x5535
leaq 0x1442(%rip), %rdx      # 0x552c
xorl %eax, %eax
callq 0x10a0
movl $0x1, %edi
callq 0x1140