// File: /workspace/github_c_makefile_star2_O0/taeguk[P]Compiler-Proj-Cminus/src/analyze.c
// Function: setSymbolInfo
static SymbolInfo * setSymbolInfo (TreeNode *t)
{
  SymbolInfo * symbolInfo;

  if (t == NULL) return NULL;
  MALLOC(symbolInfo, sizeof(*symbolInfo));

  switch (t->nodeKind)
    {
      case VariableDeclarationK:
        if (tokenToExpType(t->attr.varDecl.type_spec->attr.TOK) != IntT)
          {
            printError(t, "Type", "Variable '%s' cannot be void type.", t->attr.varDecl._var->attr.ID);
            return NULL;
          }
        symbolInfo->nodeType = IntT;
        symbolInfo->attr.intInfo.isParam = 0;
        break;


      case ArrayDeclarationK:
        if (tokenToExpType(t->attr.funcDecl.type_spec->attr.TOK) != IntT)
          {
            printError(t, "Type", "Array '%s' cannot be void type.", t->attr.varDecl._var->attr.ID);
            return NULL;
          }
        symbolInfo->nodeType = IntArrayT;
        symbolInfo->attr.arrInfo.arrLen = t->attr.arrDecl._num->attr.NUM;
        symbolInfo->attr.intInfo.isParam = 0;
        break;


      case FunctionDeclarationK:
        if (tokenToExpType(t->attr.funcDecl.type_spec->attr.TOK) == ErrorT)
          {
            DONT_OCCUR_PRINT;
            return NULL;
          }
        symbolInfo->nodeType = FuncT;
        symbolInfo->attr.funcInfo.retType =
          tokenToExpType(t->attr.funcDecl.type_spec->attr.TOK);

        TreeNode * param_node;
        ExpType * newParamList;
        int n_param;
        int i;

        n_param = 0;
        param_node = t->attr.funcDecl.params;

        while (param_node)
          {
            ++ n_param;
            param_node = param_node->sibling;
          }

        MALLOC(newParamList, n_param * sizeof(ExpType));

        param_node = t->attr.funcDecl.params;
        i = 0;
        while (param_node)
          {
            if (param_node->nodeKind == VariableParameterK)
              newParamList[i] =
                tokenToExpType(param_node->attr.varParam.type_spec->attr.TOK); // Is it need type check?
            else if (param_node->nodeKind == ArrayParameterK)
              {
                newParamList[i] =
                  tokenToExpType(param_node->attr.arrParam.type_spec->attr.TOK);
                if (newParamList[i] != IntT)
                  {
                    DONT_OCCUR_PRINT;
                    return NULL;
                  }
                newParamList[i] = IntArrayT;
              }
            else
              {
                DONT_OCCUR_PRINT;
                return NULL;
              }

            ++i;
            param_node = param_node->sibling;
          }

        symbolInfo->attr.funcInfo.paramTypeList = newParamList;
        symbolInfo->attr.funcInfo.paramLen = n_param;
        break;


      case VariableParameterK:
        if (tokenToExpType(t->attr.varParam.type_spec->attr.TOK) != IntT)
          {
            printError(t, "Type", "Variable parameter '%s' cannot be void type.", t->attr.varDecl._var->attr.ID);
            return NULL;
          }
        symbolInfo->nodeType = IntT;
        symbolInfo->attr.intInfo.isParam = TRUE;
        break;


      case ArrayParameterK:
        if (tokenToExpType(t->attr.arrParam.type_spec->attr.TOK) != IntT)
          {
            printError(t, "Type", "Array parameter '%s' cannot be void type.", t->attr.varDecl._var->attr.ID);
            return NULL;
          }
        symbolInfo->nodeType = IntArrayT;
        symbolInfo->attr.intInfo.isParam = TRUE;
        break;

      default:
        DONT_OCCUR_PRINT;
        free(symbolInfo);
        //symbolInfo = NULL;
        break;
    }

  return symbolInfo;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x22f0
movq $0x0, -0x8(%rbp)
jmp 0x26d5
jmp 0x22f2
movl $0x18, %edi
callq 0x1160
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x2351
leaq 0xbf02(%rip), %rax      # 0xe210
movq (%rax), %rdi
leaq 0x70a9(%rip), %rsi      # 0x93c1
leaq 0x70c7(%rip), %rdx      # 0x93e6
movl $0x34, %ecx
leaq 0x70ef(%rip), %r8       # 0x941a
movb $0x0, %al
callq 0x1120
leaq 0x70c2(%rip), %rdi      # 0x93fb
leaq 0x70a6(%rip), %rsi      # 0x93e6
movl $0x34, %edx
leaq 0x70dc(%rip), %rcx      # 0x9428
callq 0x10e0
jmp 0x2353
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x4, %eax
ja 0x26c4
movq -0x38(%rbp), %rax
leaq 0x6d2e(%rip), %rcx      # 0x90a4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x20(%rax), %edi
callq 0x2790
cmpl $0x4, %eax
je 0x23c6
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rcx
leaq 0x6d0d(%rip), %rsi      # 0x90b8
leaq 0x709c(%rip), %rdx      # 0x944e
movb $0x0, %al
callq 0x21d0
movq $0x0, -0x8(%rbp)
jmp 0x26d5
movq -0x18(%rbp), %rax
movl $0x4, (%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x8(%rax)
jmp 0x26cd
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x20(%rax), %edi
callq 0x2790
cmpl $0x4, %eax
je 0x2427
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rcx
leaq 0x6cac(%rip), %rsi      # 0x90b8
leaq 0x705e(%rip), %rdx      # 0x9471
movb $0x0, %al
callq 0x21d0
movq $0x0, -0x8(%rbp)
jmp 0x26d5
movq -0x18(%rbp), %rax
movl $0x5, (%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl 0x20(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x8(%rax)
jmp 0x26cd
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x20(%rax), %edi
callq 0x2790
cmpl $0x1, %eax
jne 0x2475
movq $0x0, -0x8(%rbp)
jmp 0x26d5
movq -0x18(%rbp), %rax
movl $0x6, (%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x20(%rax), %edi
callq 0x2790
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x24c8
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x24ab
jmp 0x24ca
movslq -0x2c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1160
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x252c
leaq 0xbd27(%rip), %rax      # 0xe210
movq (%rax), %rdi
leaq 0x6ece(%rip), %rsi      # 0x93c1
leaq 0x6eec(%rip), %rdx      # 0x93e6
movl $0x67, %ecx
leaq 0x6f14(%rip), %r8       # 0x941a
movb $0x0, %al
callq 0x1120
leaq 0x6ee7(%rip), %rdi      # 0x93fb
leaq 0x6ecb(%rip), %rsi      # 0x93e6
movl $0x67, %edx
leaq 0x6f01(%rip), %rcx      # 0x9428
callq 0x10e0
jmp 0x252e
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x25f0
movq -0x20(%rbp), %rax
cmpl $0x4, 0xc(%rax)
jne 0x2575
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x20(%rax), %edi
callq 0x2790
movl %eax, %edx
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x25d7
movq -0x20(%rbp), %rax
cmpl $0x5, 0xc(%rax)
jne 0x25c8
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x20(%rax), %edi
callq 0x2790
movl %eax, %edx
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
cmpl $0x4, (%rax,%rcx,4)
je 0x25b7
movq $0x0, -0x8(%rbp)
jmp 0x26d5
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl $0x5, (%rax,%rcx,4)
jmp 0x25d5
movq $0x0, -0x8(%rbp)
jmp 0x26d5
jmp 0x25d7
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x2541
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x2c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0x26cd
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x20(%rax), %edi
callq 0x2790
cmpl $0x4, %eax
je 0x2652
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rcx
leaq 0x6a81(%rip), %rsi      # 0x90b8
leaq 0x6e53(%rip), %rdx      # 0x9491
movb $0x0, %al
callq 0x21d0
movq $0x0, -0x8(%rbp)
jmp 0x26d5
movq -0x18(%rbp), %rax
movl $0x4, (%rax)
movq -0x18(%rbp), %rax
movl $0x1, 0x8(%rax)
jmp 0x26cd
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x20(%rax), %edi
callq 0x2790
cmpl $0x4, %eax
je 0x26ad
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rcx
leaq 0x6a23(%rip), %rsi      # 0x90b8
leaq 0x6e22(%rip), %rdx      # 0x94be
movb $0x0, %al
callq 0x21d0
movq $0x0, -0x8(%rbp)
jmp 0x26d5
movq -0x18(%rbp), %rax
movl $0x5, (%rax)
movq -0x18(%rbp), %rax
movl $0x1, 0x8(%rax)
jmp 0x26cd
movq -0x18(%rbp), %rdi
callq 0x1030
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop