// File: /workspace/github_c_makefile_star2_O3/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 0x48ee
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 0x4796
leaq -0x90(%rbp), %rdi
callq 0x10b0
movl $0x796e742e, -0x90(%rbp,%rax) # imm = 0x796E742E
movb $0x0, -0x8c(%rbp,%rax)
leaq 0x3287(%rip), %rsi      # 0x7a24
leaq -0x90(%rbp), %rdi
callq 0x1180
movq %rax, 0x6a48(%rip)      # 0xb1f8
testq %rax, %rax
je 0x48f6
movq 0x6810(%rip), %rax      # 0xafd0
movq (%rax), %rax
movq %rax, 0x6a36(%rip)      # 0xb200
callq 0x4729
movq %rax, %rbx
cmpl $0x0, 0x6a17(%rip)      # 0xb1f0
je 0x4800
movq 0x6a1e(%rip), %rcx      # 0xb200
leaq 0x30a4(%rip), %rdi      # 0x788d
movl $0xe, %esi
movl $0x1, %edx
callq 0x11c0
movq %rbx, %rdi
callq 0x57a3
cmpl $0x0, 0x69ed(%rip)      # 0xb1f4
jne 0x48d5
cmpl $0x0, 0x68f8(%rip)      # 0xb10c
je 0x4833
movq 0x69e3(%rip), %rcx      # 0xb200
leaq 0x3078(%rip), %rdi      # 0x789c
movl $0x1a, %esi
movl $0x1, %edx
callq 0x11c0
movq %rbx, %rdi
callq 0x133c
cmpl $0x0, 0x69b2(%rip)      # 0xb1f4
jne 0x48d5
xorl %eax, %eax
xorl %r15d, %r15d
movzbl -0x90(%rbp,%rax), %ecx
cmpl $0x2e, %ecx
je 0x4860
testl %ecx, %ecx
jne 0x4863
jmp 0x4868
movl %eax, %r15d
incq %rax
jmp 0x484d
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 0x29df(%rip), %rsi      # 0x7289
movq %r14, %rdi
callq 0x1180
movq %rax, 0x694f(%rip)      # 0xb208
testq %rax, %rax
je 0x4902
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1f40
movq 0x6938(%rip), %rdi      # 0xb208
callq 0x10a0
movq 0x691c(%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 0x2fb1(%rip), %rdi      # 0x78ba
movq %r14, %rsi
xorl %eax, %eax
callq 0x10d0
movl $0x1, %edi
callq 0x11b0
nopl (%rax)