// File: /workspace/github_c_makefile_star2_O3/taeguk[P]Compiler-Proj-Cminus/src/symtab.c
// Function: printSymTab
void printSymTab(FILE * listing)
{
  if(!TraceAnalyze) return;
  int i;
  fprintf(listing,
          "Name\t\tScope\tLoc\tV/P/F\tArray?\tArrSize\tType\tLine Numbers\n"
          "----------------------------------------------------------------------------\n");

  for (i=0;i<SIZE;++i)
    {
      BucketList l;

      // skip symbols in deeper scopes.
      for (l = hashTable[i]; 
           l && l->scope_level > cur_scope_level;
           l = l->next);

      for (; 
           l && l->scope_level == cur_scope_level; 
           l = l->next)
        {
          SymbolInfo* symbolInfo = l->symbolInfo;
          int is_arr, size_arr = 0;


          /* print name */
          fprintf(listing, "%-15s ", l->name);

          /* print scope */
          fprintf(listing, "%-8d", l->scope_level);

          /* print Memory Location */
          fprintf(listing, "%-6d  ", l->memloc);

          /* print ID Type, V/P/F = 0,1,2 */
          switch (symbolInfo->nodeType)
            {
            case IntT:
              if (symbolInfo->attr.intInfo.isParam)
                fprintf(listing, "%-8s", "Par");
              else
                fprintf(listing, "%-8s", "Var");

              fprintf(listing, "%-8s%-8c%-5s", "No", '-', "int");
              break;
            case IntArrayT:
              if (symbolInfo->attr.arrInfo.isParam)
                fprintf(listing, "%-8s", "Par");
              else
                fprintf(listing, "%-8s", "Var");

              fprintf(listing, "%-8s%-8d%-8s",
                      "Array", symbolInfo->attr.arrInfo.arrLen, "array");
              break;
            case FuncT: /* Function */
              fprintf(listing, "%-8s%-8s%-8c", "Func", "No", '-');
              if (symbolInfo->attr.funcInfo.retType == IntT)
                fprintf(listing, "%-5s", "int");
              else if (symbolInfo->attr.funcInfo.retType == VoidT)
                fprintf(listing, "%-5s", "void");
              else
                DONT_OCCUR_PRINT;
              break;
            default:
              DONT_OCCUR_PRINT;
              break;
            }

          /* line numbers */
          LineList t = l->lines;
          while (t != NULL)
            {
              fprintf(listing,"%8d",t->lineno);
              t = t->next;
            }
          fprintf(listing, "\n");
        }
    }
  fprintf(listing, "\n");
}

// Assembly:
leaq 0x62cd(%rip), %rax      # 0xb10c
cmpl $0x0, (%rax)
je 0x5073
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x2b2a(%rip), %rdi      # 0x798a
movl $0x84, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x2bf0(%rip), %r13      # 0x7a69
xorl %r14d, %r14d
leaq 0x19dad(%rip), %rax     # 0x1ec30
movq (%rax,%r14,8), %r15
testq %r15, %r15
je 0x5048
movl 0x637a(%rip), %eax      # 0xb210
cmpl %eax, 0x20(%r15)
jle 0x4eaa
movq 0x28(%r15), %r15
testq %r15, %r15
jne 0x4e96
jmp 0x5048
movl 0x20(%r15), %eax
cmpl 0x635c(%rip), %eax      # 0xb210
jne 0x5048
movq (%r15), %rdx
movq 0x18(%r15), %r12
movq %rbx, %rdi
leaq 0x2b44(%rip), %rsi      # 0x7a0f
xorl %eax, %eax
callq 0x1120
movl 0x20(%r15), %edx
movq %rbx, %rdi
leaq 0x2b36(%rip), %rsi      # 0x7a16
xorl %eax, %eax
callq 0x1120
movl 0x24(%r15), %edx
movq %rbx, %rdi
leaq 0x2b26(%rip), %rsi      # 0x7a1b
xorl %eax, %eax
callq 0x1120
movl (%r12), %eax
cmpl $0x6, %eax
je 0x4fae
cmpl $0x5, %eax
je 0x4f5f
cmpl $0x4, %eax
jne 0x500d
cmpl $0x0, 0x8(%r12)
leaq 0x2afe(%rip), %rdx      # 0x7a22
leaq 0x2afb(%rip), %rax      # 0x7a26
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x2b0d(%rip), %rsi      # 0x7a46
xorl %eax, %eax
callq 0x1120
movq %rbx, %rdi
leaq 0x2ae0(%rip), %rsi      # 0x7a2a
leaq 0x2ae6(%rip), %rdx      # 0x7a37
movl $0x2d, %ecx
leaq 0x2add(%rip), %r8       # 0x7a3a
jmp 0x4fa5
cmpl $0x0, 0x8(%r12)
leaq 0x2ab6(%rip), %rdx      # 0x7a22
leaq 0x2ab3(%rip), %rax      # 0x7a26
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x2ac5(%rip), %rsi      # 0x7a46
xorl %eax, %eax
callq 0x1120
movl 0x14(%r12), %ecx
movq %rbx, %rdi
leaq 0x2aa7(%rip), %rsi      # 0x7a3e
leaq 0x2aad(%rip), %rdx      # 0x7a4b
leaq 0x2aac(%rip), %r8       # 0x7a51
xorl %eax, %eax
callq 0x1120
jmp 0x500d
movq %rbx, %rdi
leaq 0x2a9f(%rip), %rsi      # 0x7a57
leaq 0x2aa5(%rip), %rdx      # 0x7a64
leaq 0x2a71(%rip), %rcx      # 0x7a37
movl $0x2d, %r8d
xorl %eax, %eax
callq 0x1120
movl 0x8(%r12), %eax
cmpl $0x3, %eax
je 0x4ff5
cmpl $0x4, %eax
jne 0x500d
movq %rbx, %rdi
leaq 0x2a46(%rip), %rsi      # 0x7a32
leaq 0x2a47(%rip), %rdx      # 0x7a3a
jmp 0x5006
movq %rbx, %rdi
leaq 0x2a33(%rip), %rsi      # 0x7a32
leaq 0x156d(%rip), %rdx      # 0x6573
xorl %eax, %eax
callq 0x1120
movq 0x8(%r15), %r12
testq %r12, %r12
je 0x502e
movl (%r12), %edx
movq %rbx, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x1120
movq 0x8(%r12), %r12
jmp 0x5011
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10f0
movq 0x28(%r15), %r15
testq %r15, %r15
jne 0x4eaa
incq %r14
cmpq $0xd3, %r14
jne 0x4e7c
movl $0xa, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0
retq