// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movl $0x0, 0x44(%rsp)
movq $0x0, 0x30(%rsp)
callq 0x2210
leaq 0x18c7(%rip), %rdi      # 0x6688
callq 0x2130
leaq 0x1729(%rip), %rdi      # 0x64f6
leaq 0x18b9(%rip), %rsi      # 0x668d
callq 0x10f0
movq %rax, 0x2c470(%rip)     # 0x31250
cmpq $0x0, %rax
jne 0x4df9
leaq 0x18a3(%rip), %rdi      # 0x6690
leaq 0x1702(%rip), %rsi      # 0x64f6
callq 0x1250
movl $0x1, 0x2c455(%rip)     # 0x31258
movq 0x2c446(%rip), %rdx     # 0x31250
leaq 0x432f(%rip), %rdi      # 0x9140
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x10b0
cmpq $0x0, %rax
je 0x4f48
movl 0x2c42d(%rip), %eax     # 0x31258
addl $0x1, %eax
movl %eax, 0x2c424(%rip)     # 0x31258
leaq 0x4305(%rip), %rax      # 0x9140
movq %rax, 0x52fe(%rip)      # 0xa140
callq 0x1630
callq 0x18a0
leaq 0x2c40d(%rip), %rdi     # 0x31260
leaq 0x18f1(%rip), %rsi      # 0x674b
callq 0x10c0
cmpl $0x0, %eax
jne 0x4e69
jmp 0x4f43
leaq 0x2c3f0(%rip), %rdi     # 0x31260
leaq 0x1827(%rip), %rsi      # 0x669e
callq 0x10c0
cmpl $0x0, %eax
jne 0x4e90
callq 0x4180
movq %rax, 0x30(%rsp)
jmp 0x4f41
leaq 0x2c3c9(%rip), %rdi     # 0x31260
leaq 0x1806(%rip), %rsi      # 0x66a4
callq 0x10c0
cmpl $0x0, %eax
jne 0x4eb2
callq 0x4550
jmp 0x4f3f
leaq 0x2c3a7(%rip), %rdi     # 0x31260
leaq 0x17e7(%rip), %rsi      # 0x66a7
callq 0x10c0
cmpl $0x0, %eax
jne 0x4ed1
callq 0x4720
jmp 0x4f3d
leaq 0x2c388(%rip), %rdi     # 0x31260
leaq 0x17ce(%rip), %rsi      # 0x66ad
callq 0x10c0
cmpl $0x0, %eax
jne 0x4eeb
jmp 0x4f3b
leaq 0x2c36e(%rip), %rdi     # 0x31260
leaq 0x17bc(%rip), %rsi      # 0x66b5
callq 0x10c0
cmpl $0x0, %eax
jne 0x4f0a
callq 0x4480
jmp 0x4f39
leaq 0x2c34f(%rip), %rdi     # 0x31260
leaq 0x17a4(%rip), %rsi      # 0x66bc
callq 0x10c0
cmpl $0x0, %eax
jne 0x4f24
jmp 0x4f48
leaq 0x1795(%rip), %rdi      # 0x66c0
leaq 0x2c32e(%rip), %rsi     # 0x31260
callq 0x1250
jmp 0x4f39
jmp 0x4f3b
jmp 0x4f3d
jmp 0x4f3f
jmp 0x4f41
jmp 0x4f43
jmp 0x4e03
movq 0x2c301(%rip), %rdi     # 0x31250
callq 0x1060
callq 0x4ba0
movq %rax, %rcx
movq 0x37575(%rip), %rax     # 0x3c4d8
movq %rcx, 0x40(%rax)
callq 0x4c30
callq 0x4d30
leaq 0x1759(%rip), %rdi      # 0x66d1
leaq 0x1768(%rip), %rsi      # 0x66e7
callq 0x10f0
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
jne 0x4fa2
leaq 0x1754(%rip), %rdi      # 0x66ea
leaq 0x1744(%rip), %rsi      # 0x66e1
callq 0x1250
leaq 0x1750(%rip), %rdi      # 0x66f9
movb $0x0, %al
callq 0x1080
movq 0x38(%rsp), %rdi
movq 0x4174(%rip), %rsi      # 0x9130
callq 0x4870
movq 0x38(%rsp), %rdi
movq 0x37533(%rip), %rsi     # 0x3c500
callq 0x4870
movq 0x38(%rsp), %rdi
movq 0x3752a(%rip), %rsi     # 0x3c508
callq 0x4870
movq 0x38(%rsp), %rdi
movq 0x37531(%rip), %rsi     # 0x3c520
callq 0x4870
movq 0x38(%rsp), %rdi
movq 0x374f0(%rip), %rsi     # 0x3c4f0
callq 0x4870
movq 0x38(%rsp), %rdi
movq 0x374e7(%rip), %rsi     # 0x3c4f8
callq 0x4870
movq 0x38(%rsp), %rdi
movq 0x374ee(%rip), %rsi     # 0x3c510
callq 0x4870
movq 0x38(%rsp), %rdi
movq 0x374ad(%rip), %rsi     # 0x3c4e0
callq 0x4870
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x16c6(%rip), %rdi      # 0x670f
xorl %esi, %esi
callq 0x1470
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x4870
movq 0x38(%rsp), %rdi
movq 0x374af(%rip), %rsi     # 0x3c518
callq 0x4870
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x4870
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x131e(%rip), %rdi      # 0x63ac
callq 0x1b40
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x4870
movq 0x38(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x12fd(%rip), %rdi      # 0x63ae
callq 0x1b40
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x4870
movq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x12dd(%rip), %rdi      # 0x63b1
callq 0x1b40
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x4870
movq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x1620(%rip), %rdi      # 0x6717
callq 0x1b40
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x4870
movq 0x38(%rsp), %rdi
callq 0x1060
movl 0x37437(%rip), %esi     # 0x3c550
leaq 0x160a(%rip), %rdi      # 0x672a
movb $0x0, %al
callq 0x1080
leaq 0x1610(%rip), %rdi      # 0x673e
movb $0x0, %al
callq 0x1080
xorl %eax, %eax
addq $0x48, %rsp
retq