// File: /workspace/github_c_makefile_star2_O1/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 0x610a(%rip), %rax      # 0xb10c
cmpl $0x0, (%rax)
je 0x5236
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x2967(%rip), %rdi      # 0x798a
movl $0x84, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x2a2d(%rip), %r13      # 0x7a69
xorl %r14d, %r14d
leaq 0x19bea(%rip), %rax     # 0x1ec30
movq (%rax,%r14,8), %r15
testq %r15, %r15
je 0x51f6
movl 0x61b7(%rip), %eax      # 0xb210
cmpl %eax, 0x20(%r15)
jle 0x51f6
movq 0x28(%r15), %r15
testq %r15, %r15
jne 0x5059
jmp 0x51f6
movq (%r15), %rdx
movq 0x18(%r15), %r12
movq %rbx, %rdi
leaq 0x298d(%rip), %rsi      # 0x7a0f
xorl %eax, %eax
callq 0x1120
movl 0x20(%r15), %edx
movq %rbx, %rdi
leaq 0x297f(%rip), %rsi      # 0x7a16
xorl %eax, %eax
callq 0x1120
movl 0x24(%r15), %edx
movq %rbx, %rdi
leaq 0x296f(%rip), %rsi      # 0x7a1b
xorl %eax, %eax
callq 0x1120
movl (%r12), %eax
cmpl $0x6, %eax
je 0x5165
cmpl $0x5, %eax
je 0x5116
cmpl $0x4, %eax
jne 0x51c4
cmpl $0x0, 0x8(%r12)
leaq 0x2947(%rip), %rdx      # 0x7a22
leaq 0x2944(%rip), %rax      # 0x7a26
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x2956(%rip), %rsi      # 0x7a46
xorl %eax, %eax
callq 0x1120
movq %rbx, %rdi
leaq 0x2929(%rip), %rsi      # 0x7a2a
leaq 0x292f(%rip), %rdx      # 0x7a37
movl $0x2d, %ecx
leaq 0x2926(%rip), %r8       # 0x7a3a
jmp 0x515c
cmpl $0x0, 0x8(%r12)
leaq 0x28ff(%rip), %rdx      # 0x7a22
leaq 0x28fc(%rip), %rax      # 0x7a26
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x290e(%rip), %rsi      # 0x7a46
xorl %eax, %eax
callq 0x1120
movl 0x14(%r12), %ecx
movq %rbx, %rdi
leaq 0x28f0(%rip), %rsi      # 0x7a3e
leaq 0x28f6(%rip), %rdx      # 0x7a4b
leaq 0x28f5(%rip), %r8       # 0x7a51
xorl %eax, %eax
callq 0x1120
jmp 0x51c4
movq %rbx, %rdi
leaq 0x28e8(%rip), %rsi      # 0x7a57
leaq 0x28ee(%rip), %rdx      # 0x7a64
leaq 0x28ba(%rip), %rcx      # 0x7a37
movl $0x2d, %r8d
xorl %eax, %eax
callq 0x1120
movl 0x8(%r12), %eax
cmpl $0x3, %eax
je 0x51ac
cmpl $0x4, %eax
jne 0x51c4
movq %rbx, %rdi
leaq 0x288f(%rip), %rsi      # 0x7a32
leaq 0x2890(%rip), %rdx      # 0x7a3a
jmp 0x51bd
movq %rbx, %rdi
leaq 0x287c(%rip), %rsi      # 0x7a32
leaq 0x13b6(%rip), %rdx      # 0x6573
xorl %eax, %eax
callq 0x1120
movq 0x8(%r15), %r12
testq %r12, %r12
je 0x51e5
movl (%r12), %edx
movq %rbx, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x1120
movq 0x8(%r12), %r12
jmp 0x51c8
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10f0
movq 0x28(%r15), %r15
testq %r15, %r15
je 0x520b
movl 0x20(%r15), %eax
cmpl 0x600b(%rip), %eax      # 0xb210
je 0x5071
incq %r14
cmpq $0xd3, %r14
jne 0x503f
movl $0xa, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0
retq
nop