// File: /workspace/github_c_makefile_star2_O2/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 0x451a
movq 0x8(%rsi), %rsi
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
callq 0x1060
pushq $0x2e
popq %rsi
movq %rbx, %rdi
callq 0x10c0
testq %rax, %rax
jne 0x43cc
leaq -0x90(%rbp), %rdi
callq 0x10b0
movl $0x796e742e, -0x90(%rbp,%rax) # imm = 0x796E742E
movb $0x0, -0x8c(%rbp,%rax)
leaq 0x3651(%rip), %rsi      # 0x7a24
leaq -0x90(%rbp), %rdi
callq 0x1180
movq %rax, 0x6e12(%rip)      # 0xb1f8
testq %rax, %rax
je 0x4530
movq 0x6bda(%rip), %rax      # 0xafd0
movq (%rax), %rax
movq %rax, 0x6e00(%rip)      # 0xb200
callq 0x435f
movq %rax, %rbx
cmpl $0x0, 0x6de1(%rip)      # 0xb1f0
je 0x4432
movq 0x6de8(%rip), %rcx      # 0xb200
leaq 0x346e(%rip), %rdi      # 0x788d
pushq $0xe
popq %rsi
pushq $0x1
popq %rdx
callq 0x11c0
movq %rbx, %rdi
callq 0x5309
cmpl $0x0, 0x6dbb(%rip)      # 0xb1f4
jne 0x4501
cmpl $0x0, 0x6cc6(%rip)      # 0xb10c
je 0x4461
movq 0x6db1(%rip), %rcx      # 0xb200
leaq 0x3446(%rip), %rdi      # 0x789c
pushq $0x1a
popq %rsi
pushq $0x1
popq %rdx
callq 0x11c0
movq %rbx, %rdi
callq 0x12dc
cmpl $0x0, 0x6d84(%rip)      # 0xb1f4
jne 0x4501
xorl %eax, %eax
xorl %r15d, %r15d
movzbl -0x90(%rbp,%rax), %ecx
cmpl $0x2e, %ecx
je 0x448e
testl %ecx, %ecx
jne 0x4491
jmp 0x4496
movl %eax, %r15d
incq %rax
jmp 0x447b
leal 0x3(%r15), %eax
movslq %eax, %rdi
pushq $0x1
popq %rsi
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 0x2db3(%rip), %rsi      # 0x7289
movq %r14, %rdi
callq 0x1180
movq %rax, 0x6d23(%rip)      # 0xb208
testq %rax, %rax
je 0x4557
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1e9c
movq 0x6d0c(%rip), %rdi      # 0xb208
callq 0x10a0
movq 0x6cf0(%rip), %rdi      # 0xb1f8
callq 0x10a0
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x6ad7(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq (%rsi), %rdx
leaq 0x3331(%rip), %rsi      # 0x785f
jmp 0x4548
movq 0x6ac1(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x3339(%rip), %rsi      # 0x787a
leaq -0x90(%rbp), %rdx
xorl %eax, %eax
callq 0x1120
pushq $0x1
popq %rdi
callq 0x11b0
leaq 0x335c(%rip), %rdi      # 0x78ba
movq %r14, %rsi
xorl %eax, %eax
callq 0x10d0
jmp 0x454f
nop