// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x78, %rsp
cmpl $0x2, %edi
jne 0x4ab2
movq 0x8(%rsi), %rsi
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
callq 0x1060
movq %rbx, %rdi
movl $0x2e, %esi
callq 0x10c0
testq %rax, %rax
jne 0x495e
leaq -0x90(%rbp), %rdi
callq 0x10b0
movl $0x796e742e, -0x90(%rbp,%rax) # imm = 0x796E742E
movb $0x0, -0x8c(%rbp,%rax)
leaq 0x30bf(%rip), %rsi      # 0x7a24
leaq -0x90(%rbp), %rdi
callq 0x1180
movq %rax, 0x6880(%rip)      # 0xb1f8
testq %rax, %rax
je 0x4aba
movq 0x6648(%rip), %rax      # 0xafd0
movq (%rax), %rax
movq %rax, 0x686e(%rip)      # 0xb200
callq 0x48f2
movq %rax, %rbx
cmpl $0x0, 0x684f(%rip)      # 0xb1f0
je 0x49c8
movq 0x6856(%rip), %rcx      # 0xb200
leaq 0x2edc(%rip), %rdi      # 0x788d
movl $0xe, %esi
movl $0x1, %edx
callq 0x11c0
movq %rbx, %rdi
callq 0x596e
cmpl $0x0, 0x6825(%rip)      # 0xb1f4
jne 0x49ff
cmpl $0x0, 0x6734(%rip)      # 0xb10c
je 0x49f7
movq 0x681f(%rip), %rcx      # 0xb200
leaq 0x2eb4(%rip), %rdi      # 0x789c
movl $0x1a, %esi
movl $0x1, %edx
callq 0x11c0
movq %rbx, %rdi
callq 0x133c
cmpl $0x0, 0x67ee(%rip)      # 0xb1f4
jne 0x4a99
xorl %eax, %eax
xorl %r15d, %r15d
movzbl -0x90(%rbp,%rax), %ecx
cmpl $0x2e, %ecx
je 0x4a24
testl %ecx, %ecx
jne 0x4a27
jmp 0x4a2c
movl %eax, %r15d
incq %rax
jmp 0x4a11
leal 0x3(%r15), %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x1100
movq %rax, %r14
movslq %r15d, %rdx
leaq -0x90(%rbp), %rsi
movq %rax, %rdi
callq 0x1050
movq %r14, %rdi
callq 0x10b0
movw $0x732e, (%r14,%rax)    # imm = 0x732E
movb $0x0, 0x2(%r14,%rax)
leaq 0x281b(%rip), %rsi      # 0x7289
movq %r14, %rdi
callq 0x1180
movq %rax, 0x678b(%rip)      # 0xb208
testq %rax, %rax
je 0x4ac6
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1fbc
movq 0x6774(%rip), %rdi      # 0xb208
callq 0x10a0
movq 0x6758(%rip), %rdi      # 0xb1f8
callq 0x10a0
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rdi
callq 0x11f0
leaq -0x90(%rbp), %rdi
callq 0x121a
leaq 0x2ded(%rip), %rdi      # 0x78ba
movq %r14, %rsi
xorl %eax, %eax
callq 0x10d0
movl $0x1, %edi
callq 0x11b0
nopl (%rax)