// File: /workspace/github_c_makefile_star2_O1/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 0x1d9e
leaq 0x173c(%rip), %rdi      # 0x54df
callq 0x1cf4
leaq 0x15cd(%rip), %rdi      # 0x537c
leaq 0x172e(%rip), %rsi      # 0x54e4
callq 0x1110
movq %rax, 0x2c49e(%rip)     # 0x30260
testq %rax, %rax
je 0x409e
movl $0x1, 0x2c493(%rip)     # 0x30268
movq 0x2c484(%rip), %rdx     # 0x30260
leaq 0x436d(%rip), %r14      # 0x8150
movq %r14, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x10d0
xorl %ebx, %ebx
testq %rax, %rax
je 0x3ee6
movl $0x49474542, %ebp       # imm = 0x49474542
movabsq $0x5353414c43574152, %r15 # imm = 0x5353414C43574152
movl $0x53414c43, %r12d      # imm = 0x53414C43
movabsq $0x544e454d4d4f43, %r13 # imm = 0x544E454D4D4F43
incl 0x2c448(%rip)           # 0x30268
movq %r14, 0x5329(%rip)      # 0x9150
callq 0x15be
callq 0x16b9
cmpb $0x0, 0x2c438(%rip)     # 0x30270
je 0x3ec9
movl 0x2c42c(%rip), %eax     # 0x30270
xorl %ebp, %eax
movzwl 0x2c427(%rip), %ecx     # 0x30274
xorl $0x4e, %ecx
orl %eax, %ecx
je 0x3eb3
movq 0x2c415(%rip), %rax     # 0x30270
xorq %r15, %rax
movzbl 0x2c413(%rip), %ecx     # 0x30278
orq %rax, %rcx
je 0x3ebd
movl 0x2c400(%rip), %eax     # 0x30270
xorl %r12d, %eax
movzwl 0x2c3fa(%rip), %ecx     # 0x30274
xorl $0x53, %ecx
orl %eax, %ecx
je 0x3ec4
cmpq %r13, 0x2c3e8(%rip)     # 0x30270
je 0x3ec9
movl 0x2c3e0(%rip), %eax     # 0x30270
movl $0x4854454d, %ecx       # imm = 0x4854454D
xorl %ecx, %eax
movl 0x2c3d6(%rip), %ecx     # 0x30273
movl $0x444f48, %edx         # imm = 0x444F48
xorl %edx, %ecx
orl %eax, %ecx
jne 0x4077
callq 0x35c5
jmp 0x3ec9
callq 0x33d7
movq %rax, %rbx
jmp 0x3ec9
callq 0x3684
jmp 0x3ec9
callq 0x380f
movq 0x2c390(%rip), %rdx     # 0x30260
movq %r14, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x10d0
testq %rax, %rax
jne 0x3e1a
movq 0x2c373(%rip), %rdi     # 0x30260
callq 0x1080
callq 0x3b89
movq 0x375ea(%rip), %rcx     # 0x3b4e8
movq %rax, 0x40(%rcx)
callq 0x3c41
callq 0x3d32
leaq 0x1609(%rip), %rdi      # 0x551c
leaq 0x1618(%rip), %rsi      # 0x5532
callq 0x1110
testq %rax, %rax
je 0x40b5
movq %rax, %r14
leaq 0x1659(%rip), %rdi      # 0x558b
callq 0x1070
movq 0x4202(%rip), %rsi      # 0x8140
movq %r14, %rdi
callq 0x392d
movq 0x375c3(%rip), %rsi     # 0x3b510
movq %r14, %rdi
callq 0x392d
movq 0x375bc(%rip), %rsi     # 0x3b518
movq %r14, %rdi
callq 0x392d
movq 0x375c5(%rip), %rsi     # 0x3b530
movq %r14, %rdi
callq 0x392d
movq 0x37586(%rip), %rsi     # 0x3b500
movq %r14, %rdi
callq 0x392d
movq 0x3757f(%rip), %rsi     # 0x3b508
movq %r14, %rdi
callq 0x392d
movq 0x37588(%rip), %rsi     # 0x3b520
movq %r14, %rdi
callq 0x392d
movq 0x37549(%rip), %rsi     # 0x3b4f0
movq %r14, %rdi
callq 0x392d
leaq 0x158e(%rip), %rdi      # 0x5544
xorl %esi, %esi
callq 0x1496
movq %r14, %rdi
movq %rax, %rsi
callq 0x392d
movq 0x37559(%rip), %rsi     # 0x3b528
movq %r14, %rdi
callq 0x392d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x392d
leaq 0x128a(%rip), %rdi      # 0x5273
callq 0x182f
movq %r14, %rdi
movq %rax, %rsi
callq 0x392d
leaq 0x1275(%rip), %rdi      # 0x5275
callq 0x182f
movq %r14, %rdi
movq %rax, %rsi
callq 0x392d
leaq 0x1261(%rip), %rdi      # 0x5278
callq 0x182f
movq %r14, %rdi
movq %rax, %rsi
callq 0x392d
leaq 0x151e(%rip), %rdi      # 0x554c
callq 0x182f
movq %r14, %rdi
movq %rax, %rsi
callq 0x392d
movq %r14, %rdi
callq 0x1080
movl 0x37514(%rip), %esi     # 0x3b560
leaq 0x150c(%rip), %rdi      # 0x555f
xorl %eax, %eax
callq 0x10a0
leaq 0x153f(%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, 0x2c1ef(%rip) # imm = 0x444E45
je 0x3ee6
leaq 0xfb2(%rip), %rdi       # 0x5040
leaq 0x1476(%rip), %rsi      # 0x550b
leaq 0x2c1d4(%rip), %rdx     # 0x30270
jmp 0x40ca
leaq 0xf9b(%rip), %rdi       # 0x5040
leaq 0x143b(%rip), %rsi      # 0x54e7
leaq 0x12c9(%rip), %rdx      # 0x537c
jmp 0x40ca
leaq 0xf84(%rip), %rdi       # 0x5040
leaq 0x1472(%rip), %rsi      # 0x5535
leaq 0x1462(%rip), %rdx      # 0x552c
xorl %eax, %eax
callq 0x10a0
movl $0x1, %edi
callq 0x1140