// File: /workspace/github_c_makefile_star2_O0/taeguk[P]Compiler-Proj-Cminus/src/main.c
// Function: main
int
main(int argc, char* argv[])
{
  TreeNode * syntaxTree;
  char pgm[120]; /* source code file name */
  if (argc != 2)
    {
      fprintf(stderr,"usage: %s <filename>\n",argv[0]);
      exit(1);
    }
  strcpy(pgm,argv[1]) ;
  if (strchr (pgm, '.') == NULL)
    {
     strcat(pgm,".tny");
    }
  source = fopen(pgm,"r");
  if (source==NULL)
  {
    fprintf(stderr,"File %s not found\n",pgm);
    exit(1);
  }
  listing = stdout; /* send listing to screen */
#if NO_PARSE
  if (TraceScan)
    {
      int divider_cnt = 80;
      fprintf(listing,"\n\tline number\t\ttoken\t\t\tlexeme\n");
      while(divider_cnt--) putchar('-');
      putchar('\n');
    }
  while (getToken()!=ENDFILE);
#else
  syntaxTree = parse();
  if (TraceParse)
    {
      fprintf(listing,"\nSyntax tree:\n");
      printTree(syntaxTree);
    }
#if !NO_ANALYZE
  if (! Error)
  {
    if (TraceAnalyze) fprintf(listing,"\nBuilding Symbol Table...\n");
    buildSymtab(syntaxTree);
    /*
    if (TraceAnalyze) fprintf(listing,"\nChecking Types...\n");
    typeCheck(syntaxTree);
    if (TraceAnalyze) fprintf(listing,"\nType Checking Finished\n");
    */
  }
#if !NO_CODE
  if (! Error)
  {
    char * codefile;
    int fnlen = 0, i;
    for(i=0; pgm[i]!='\0'; ++i)
      if(pgm[i] == '.') fnlen = i;
    codefile = (char *) calloc(fnlen+3, sizeof(char));
    strncpy(codefile,pgm,fnlen);
    strcat(codefile,".s");
    code = fopen(codefile,"w");
    if (code == NULL)
    {
      printf("Unable to open %s\n",codefile);
      exit(1);
    }
    codeGen(syntaxTree, code);
    fclose(code);
  }
#endif
#endif
#endif
  fclose(source);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
je 0x6728
movq 0x78f2(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x4239(%rip), %rsi      # 0xa950
movb $0x0, %al
callq 0x1120
movl $0x1, %edi
callq 0x11c0
leaq -0x90(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x1060
leaq -0x90(%rbp), %rdi
movl $0x2e, %esi
callq 0x10c0
cmpq $0x0, %rax
jne 0x6766
leaq -0x90(%rbp), %rdi
leaq 0x4205(%rip), %rsi      # 0xa966
callq 0x11b0
leaq -0x90(%rbp), %rdi
leaq 0x43a1(%rip), %rsi      # 0xab15
callq 0x1180
movq %rax, 0x7a88(%rip)      # 0xe208
cmpq $0x0, 0x7a80(%rip)      # 0xe208
jne 0x67b3
movq 0x7867(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq -0x90(%rbp), %rdx
leaq 0x41c9(%rip), %rsi      # 0xa96b
movb $0x0, %al
callq 0x1120
movl $0x1, %edi
callq 0x11c0
movq 0x7816(%rip), %rax      # 0xdfd0
movq (%rax), %rax
movq %rax, 0x7a4c(%rip)      # 0xe210
callq 0x66c0
movq %rax, -0x18(%rbp)
cmpl $0x0, 0x7a2c(%rip)      # 0xe200
je 0x67f4
movq 0x7a33(%rip), %rdi      # 0xe210
leaq 0x419a(%rip), %rsi      # 0xa97e
movb $0x0, %al
callq 0x1120
movq -0x18(%rbp), %rdi
callq 0x7ea0
cmpl $0x0, 0x7a09(%rip)      # 0xe204
jne 0x6824
cmpl $0x0, 0x7918(%rip)      # 0xe11c
je 0x681b
movq 0x7a03(%rip), %rdi      # 0xe210
leaq 0x4179(%rip), %rsi      # 0xa98d
movb $0x0, %al
callq 0x1120
movq -0x18(%rbp), %rdi
callq 0x12f0
cmpl $0x0, 0x79d9(%rip)      # 0xe204
jne 0x6935
movl $0x0, -0x9c(%rbp)
movl $0x0, -0xa0(%rbp)
movslq -0xa0(%rbp), %rax
movsbl -0x90(%rbp,%rax), %eax
cmpl $0x0, %eax
je 0x688c
movslq -0xa0(%rbp), %rax
movsbl -0x90(%rbp,%rax), %eax
cmpl $0x2e, %eax
jne 0x6879
movl -0xa0(%rbp), %eax
movl %eax, -0x9c(%rbp)
jmp 0x687b
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x6845
movl -0x9c(%rbp), %eax
addl $0x3, %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x1100
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movslq -0x9c(%rbp), %rdx
callq 0x1050
movq -0x98(%rbp), %rdi
leaq 0x40d7(%rip), %rsi      # 0xa9a8
callq 0x11b0
movq -0x98(%rbp), %rdi
leaq 0x39d5(%rip), %rsi      # 0xa2b9
callq 0x1180
movq %rax, 0x7928(%rip)      # 0xe218
cmpq $0x0, 0x7920(%rip)      # 0xe218
jne 0x6919
movq -0x98(%rbp), %rsi
leaq 0x40a3(%rip), %rdi      # 0xa9ab
movb $0x0, %al
callq 0x10d0
movl $0x1, %edi
callq 0x11c0
movq -0x18(%rbp), %rdi
movq 0x78f4(%rip), %rsi      # 0xe218
callq 0x2850
movq 0x78e8(%rip), %rdi      # 0xe218
callq 0x10a0
movq 0x78cc(%rip), %rdi      # 0xe208
callq 0x10a0
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)