// File: /workspace/github_c_makefile_star2_O2/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 0x1a9e
leaq 0xdd7(%rip), %rdi       # 0x44a3
callq 0x1a1a
leaq 0xc68(%rip), %rdi       # 0x4340
leaq 0xdc9(%rip), %rsi       # 0x44a8
callq 0x1110
movq %rax, 0x2bb75(%rip)     # 0x2f260
testq %rax, %rax
je 0x39aa
movq %rax, %rdx
movl $0x1, 0x2bb67(%rip)     # 0x2f268
movq $0x0, (%rsp)
leaq 0x3a40(%rip), %r14      # 0x7150
leaq 0x2bb59(%rip), %r15     # 0x2f270
leaq 0xd9b(%rip), %r12       # 0x44b9
pushq $0x6
popq %r13
leaq 0xd96(%rip), %rbp       # 0x44bf
pushq $0x9
popq %rbx
movq %r14, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x10d0
testq %rax, %rax
je 0x3818
incl 0x2bb20(%rip)           # 0x2f268
movq %r14, 0x4a01(%rip)      # 0x8150
callq 0x149d
callq 0x1582
cmpb $0x0, 0x2bb10(%rip)     # 0x2f270
je 0x3800
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1100
testl %eax, %eax
je 0x37e9
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x1100
testl %eax, %eax
je 0x37f4
movq %r15, %rdi
leaq 0xd2e(%rip), %rsi       # 0x44c2
movq %r13, %rdx
callq 0x1100
testl %eax, %eax
je 0x37fb
movq %r12, %r13
movq %rbx, %r12
movq %rbp, %rbx
movq 0x2bac0(%rip), %rbp     # 0x2f270
movabsq $0x544e454d4d4f43, %rax # imm = 0x544E454D4D4F43
cmpq %rax, %rbp
je 0x37da
movq %r15, %rdi
leaq 0xcff(%rip), %rsi       # 0x44c8
pushq $0x7
popq %rdx
callq 0x1100
testl %eax, %eax
jne 0x380c
callq 0x3036
movq %rbx, %rbp
movq %r12, %rbx
movq %r13, %r12
pushq $0x6
popq %r13
jmp 0x3800
callq 0x2ec3
movq %rax, (%rsp)
jmp 0x3800
callq 0x30d7
jmp 0x3800
callq 0x321a
movq 0x2ba59(%rip), %rdx     # 0x2f260
jmp 0x372c
cmpl $0x444e45, %ebp         # imm = 0x444E45
jne 0x39d0
movq 0x2ba41(%rip), %rdi     # 0x2f260
callq 0x1080
callq 0x3543
movq 0x36cb8(%rip), %rcx     # 0x3a4e8
movq %rax, 0x40(%rcx)
callq 0x35a5
callq 0x366e
leaq 0xc9b(%rip), %rdi       # 0x44e0
leaq 0xcaa(%rip), %rsi       # 0x44f6
callq 0x1110
testq %rax, %rax
je 0x39bd
movq %rax, %r14
leaq 0xceb(%rip), %rdi       # 0x454f
callq 0x1070
movq 0x38d0(%rip), %rsi      # 0x7140
movq %r14, %rdi
callq 0x3325
movq 0x36c91(%rip), %rsi     # 0x3a510
movq %r14, %rdi
callq 0x3325
movq 0x36c8a(%rip), %rsi     # 0x3a518
movq %r14, %rdi
callq 0x3325
movq 0x36c93(%rip), %rsi     # 0x3a530
movq %r14, %rdi
callq 0x3325
movq 0x36c54(%rip), %rsi     # 0x3a500
movq %r14, %rdi
callq 0x3325
movq 0x36c4d(%rip), %rsi     # 0x3a508
movq %r14, %rdi
callq 0x3325
movq 0x36c56(%rip), %rsi     # 0x3a520
movq %r14, %rdi
callq 0x3325
movq 0x36c17(%rip), %rsi     # 0x3a4f0
movq %r14, %rdi
callq 0x3325
leaq 0xc20(%rip), %rdi       # 0x4508
xorl %esi, %esi
callq 0x1390
movq %r14, %rdi
movq %rax, %rsi
callq 0x3325
movq 0x36c27(%rip), %rsi     # 0x3a528
movq %r14, %rdi
callq 0x3325
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x3325
leaq 0x91b(%rip), %rdi       # 0x4237
callq 0x1696
movq %r14, %rdi
movq %rax, %rsi
callq 0x3325
leaq 0x906(%rip), %rdi       # 0x4239
callq 0x1696
movq %r14, %rdi
movq %rax, %rsi
callq 0x3325
leaq 0x8f2(%rip), %rdi       # 0x423c
callq 0x1696
movq %r14, %rdi
movq %rax, %rsi
callq 0x3325
leaq 0xbaf(%rip), %rdi       # 0x4510
callq 0x1696
movq %r14, %rdi
movq %rax, %rsi
callq 0x3325
movq %r14, %rdi
callq 0x1080
movl 0x36be1(%rip), %esi     # 0x3a560
leaq 0xb9d(%rip), %rdi       # 0x4523
xorl %eax, %eax
callq 0x10a0
leaq 0xbd0(%rip), %rdi       # 0x4564
callq 0x1070
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xafa(%rip), %rdi       # 0x44ab
leaq 0x988(%rip), %rsi       # 0x4340
callq 0x126c
leaq 0xb35(%rip), %rdi       # 0x44f9
leaq 0xb25(%rip), %rsi       # 0x44f0
callq 0x126c
leaq 0xaf8(%rip), %rdi       # 0x44cf
leaq 0x2b892(%rip), %rsi     # 0x2f270
callq 0x126c