// File: /workspace/github_c_makefile_star2_O2/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 0x676e(%rip), %rax      # 0xb10c
cmpl $0x0, (%rax)
je 0x4bd2
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x2fcb(%rip), %rdi      # 0x798a
pushq $0x1
popq %rdx
movl $0x84, %esi
movq %rbx, %rcx
callq 0x11c0
pushq $0xa
popq %r13
leaq 0x308f(%rip), %r14      # 0x7a69
xorl %ecx, %ecx
cmpq $0xd3, %rcx
je 0x4bb9
leaq 0x1a240(%rip), %rax     # 0x1ec30
movq %rcx, -0x30(%rbp)
leaq (%rax,%rcx,8), %r15
movl 0x6812(%rip), %eax      # 0xb210
movq (%r15), %r15
testq %r15, %r15
je 0x4b98
cmpl %eax, 0x20(%r15)
jle 0x4b98
addq $0x28, %r15
jmp 0x49fe
movq (%r15), %rdx
movq 0x18(%r15), %r12
movq %rbx, %rdi
leaq 0x2fe4(%rip), %rsi      # 0x7a0f
xorl %eax, %eax
callq 0x1120
movl 0x20(%r15), %edx
movq %rbx, %rdi
leaq 0x2fd6(%rip), %rsi      # 0x7a16
xorl %eax, %eax
callq 0x1120
movl 0x24(%r15), %edx
movq %rbx, %rdi
leaq 0x2fc6(%rip), %rsi      # 0x7a1b
xorl %eax, %eax
callq 0x1120
movl (%r12), %eax
cmpl $0x6, %eax
je 0x4b0c
cmpl $0x5, %eax
je 0x4abd
cmpl $0x4, %eax
jne 0x4b69
cmpl $0x0, 0x8(%r12)
leaq 0x2f9e(%rip), %rdx      # 0x7a22
leaq 0x2f9b(%rip), %rax      # 0x7a26
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x2fad(%rip), %rsi      # 0x7a46
xorl %eax, %eax
callq 0x1120
movq %rbx, %rdi
leaq 0x2f80(%rip), %rsi      # 0x7a2a
leaq 0x2f86(%rip), %rdx      # 0x7a37
pushq $0x2d
popq %rcx
leaq 0x2f7f(%rip), %r8       # 0x7a3a
jmp 0x4b03
cmpl $0x0, 0x8(%r12)
leaq 0x2f58(%rip), %rdx      # 0x7a22
leaq 0x2f55(%rip), %rax      # 0x7a26
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x2f67(%rip), %rsi      # 0x7a46
xorl %eax, %eax
callq 0x1120
movl 0x14(%r12), %ecx
movq %rbx, %rdi
leaq 0x2f49(%rip), %rsi      # 0x7a3e
leaq 0x2f4f(%rip), %rdx      # 0x7a4b
leaq 0x2f4e(%rip), %r8       # 0x7a51
xorl %eax, %eax
callq 0x1120
jmp 0x4b69
movq %rbx, %rdi
leaq 0x2f41(%rip), %rsi      # 0x7a57
leaq 0x2f47(%rip), %rdx      # 0x7a64
leaq 0x2f13(%rip), %rcx      # 0x7a37
pushq $0x2d
popq %r8
xorl %eax, %eax
callq 0x1120
movl 0x8(%r12), %eax
cmpl $0x3, %eax
je 0x4b51
cmpl $0x4, %eax
jne 0x4b69
movq %rbx, %rdi
leaq 0x2eea(%rip), %rsi      # 0x7a32
leaq 0x2eeb(%rip), %rdx      # 0x7a3a
jmp 0x4b62
movq %rbx, %rdi
leaq 0x2ed7(%rip), %rsi      # 0x7a32
leaq 0x1a11(%rip), %rdx      # 0x6573
xorl %eax, %eax
callq 0x1120
movq %r15, %r12
movq 0x8(%r12), %r12
testq %r12, %r12
je 0x4b89
movl (%r12), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1120
jmp 0x4b6c
movl %r13d, %edi
movq %rbx, %rsi
callq 0x10f0
movq 0x28(%r15), %r15
testq %r15, %r15
je 0x4bad
movl 0x20(%r15), %eax
cmpl 0x6669(%rip), %eax      # 0xb210
je 0x4a1a
movq -0x30(%rbp), %rcx
incq %rcx
jmp 0x49dc
pushq $0xa
popq %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0
retq
nop