// File: /workspace/github_c_makefile_star2_O2/zyearn[P]SmallC/codegen.cpp
// Function: genFT(treeNode*)
void genFT(treeNode* node)  //ÎªfunctionµÄ²ÎÊýºÍ¾Ö²¿±äÁ¿½¨Á¢symboltable
{
    int size = 0;
    if(FT[node->child[1]->child[0]->data] == 0)
    {
        FT[node->child[1]->child[0]->data] = new map<string, int>();
    }
    if(ISA[node->child[1]->child[0]->data] == 0)
    {
        ISA[node->child[1]->child[0]->data] = new map<string, int>();
    }   

    string tmp = node->child[1]->child[2]->data;
    if(tmp[tmp.length()-1] != ',')
    {   
        tmp += ",";
    }
    if(node->child[1]->child[2]->type != 3)
    {
        while(tmp.find(",")>=0 && tmp.find(",")<tmp.length())
        {
            string s = tmp.substr(0,tmp.find(","));
            tmp.erase(0,tmp.find(","));
            tmp.erase(tmp.find(","),1);
            size++;
            if((*FT[node->child[1]->child[0]->data])[s] == 0)
                (*FT[node->child[1]->child[0]->data])[s] = size*4;
            else
            {
                freopen(outputFile.c_str(), "w", stdout);
                cout << "Error.";
                fprintf(stderr, "\nCompile fail!\n");
                fprintf(stderr, "error occurs, %s is redefined\n", s.c_str() );
                exit(0);
            }
        }
    }
    
    int localn = 0;//¼ÇÂ¼¾Ö²¿±äÁ¿µÄ¸öÊý
    tmp = node->child[2]->child[1]->data;
    if(tmp[tmp.length()-1] != ',')
    {
        tmp += ",";
    }// + ","
    if(node->child[2]->child[1]->type == 1)
    {
        while(tmp.find(",")>=0 && tmp.find(",")<tmp.length() )
        {
            // int 
            if(tmp.find(",") < tmp.find("[") && tmp.find(",") <tmp.find("|"))
            {
                localn++;   
                string s = tmp.substr(0,tmp.find(","));
                tmp.erase(0,tmp.find(","));
                tmp.erase(tmp.find(","),1);
                size++;
                if((*FT[node->child[1]->child[0]->data])[s] == 0)
                    (*FT[node->child[1]->child[0]->data])[s] = size*4;
                else
                {
                    freopen(outputFile.c_str(), "w", stdout);
                    cout << "Error.";
                    fprintf(stderr, "\nCompile fail!\n");
                    fprintf(stderr, "error occurs, %s is redefined\n", s.c_str() );
                    exit(0);
                }
            }
            // Êý×é£¬eg a[10]
            else if(tmp.find("[") < tmp.find(",") && tmp.find("[") < tmp.find("|"))
            {
                string s = tmp.substr(0,tmp.find("["));
                string num = tmp.substr(tmp.find("[")+1, tmp.find("]"));
                tmp.erase(0,tmp.find(","));
                tmp.erase(tmp.find(","),1);             
                size += atoi(num.c_str());
                localn += atoi(num.c_str());
                if((*FT[node->child[1]->child[0]->data])[s] == 0)
                {
                    (*FT[node->child[1]->child[0]->data])[s] = size*4;
                    (*ISA[node->child[1]->child[0]->data])[s] = 1;
                }
                else
                {
                    freopen(outputFile.c_str(), "w", stdout);
                    cout << "Error.";
                    fprintf(stderr, "\nCompile fail!\n");
                    fprintf(stderr, "error occurs, %s is redefined\n", s.c_str() );
                    exit(0);
                }
            }
            //struct: |a,b,c|w| ÒÔºóÔÙËµ£¡
            /*else if(tmp.find("|") < tmp.find(",") && tmp.find("|") < tmp.find("["))
            {
                int n = tmp.find("|",1);
                int n2 = tmp.find("|",n+1);
                string t1 = tmp.substr(1,n);
                string t2 = tmp.substr(n+1,n2);
                t1
                
            }*/
            
        }
    }
    (*FT[node->child[1]->child[0]->data])["#"] = size*4;
    (*FT[node->child[1]->child[0]->data])["##"] = localn;
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movq 0x28(%rdi), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x16793(%rip), %rdi     # 0x1f2b8
callq 0x155d4
cmpq $0x0, (%rax)
jne 0x8b76
pushq $0x30
popq %rdi
callq 0x21c0
movq %rax, %r14
addq $0x8, %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
movq %rax, 0x18(%r14)
movq %rax, 0x20(%r14)
andq $0x0, 0x28(%r14)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1674a(%rip), %rdi     # 0x1f2b8
callq 0x155d4
movq %r14, (%rax)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1678c(%rip), %rdi     # 0x1f318
callq 0x155d4
cmpq $0x0, (%rax)
jne 0x8bdd
pushq $0x30
popq %rdi
callq 0x21c0
movq %rax, %r14
addq $0x8, %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
movq %rax, 0x18(%r14)
movq %rax, 0x20(%r14)
andq $0x0, 0x28(%r14)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x16743(%rip), %rdi     # 0x1f318
callq 0x155d4
movq %r14, (%rax)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rsi
leaq -0x80(%rbp), %r14
movq %r14, %rdi
callq 0x2280
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpb $0x2c, -0x1(%rax,%rcx)
je 0x8c17
leaq 0xfc90(%rip), %rsi      # 0x1889e
leaq -0x80(%rbp), %rdi
callq 0x2370
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rcx), %rcx
movq 0x10(%rcx), %rcx
xorl %r15d, %r15d
cmpl $0x3, 0x24(%rcx)
je 0x8d43
movq %rbx, %r13
movq $0x0, -0x30(%rbp)
pushq $0x4
popq %rbx
leaq 0xfc55(%rip), %r14      # 0x1889e
leaq -0x80(%rbp), %r15
leaq -0x60(%rbp), %r12
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
cmpq -0x78(%rbp), %rax
jae 0x8d38
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21e0
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x20b0
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %r15, %rdi
movq %rax, %rsi
pushq $0x1
popq %rdx
callq 0x20b0
movq 0x28(%r13), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x165db(%rip), %rdi     # 0x1f2b8
callq 0x155d4
movq (%rax), %rdi
movq %r12, %rsi
callq 0x1556a
cmpl $0x0, (%rax)
jne 0x9153
movq 0x28(%r13), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x165ac(%rip), %rdi     # 0x1f2b8
callq 0x155d4
movq (%rax), %rdi
movq %r12, %rsi
callq 0x1556a
movl %ebx, (%rax)
movq %r12, %rdi
callq 0x23c8
addl $0x4, %ebx
movq -0x30(%rbp), %rax
incl %eax
movq %rax, -0x30(%rbp)
jmp 0x8c51
movq %r13, %rbx
movq 0x28(%r13), %rax
movq -0x30(%rbp), %r15
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rsi
leaq -0x80(%rbp), %rdi
callq 0x2130
movq -0x80(%rbp), %rax
movq -0x78(%rbp), %rcx
cmpb $0x2c, -0x1(%rax,%rcx)
je 0x8d77
leaq 0xfb30(%rip), %rsi      # 0x1889e
leaq -0x80(%rbp), %rdi
callq 0x2370
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rcx
movq 0x28(%rcx), %rcx
movq 0x8(%rcx), %rcx
xorl %r12d, %r12d
cmpl $0x1, 0x24(%rcx)
jne 0x90a1
movq %r15, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq 0xfaf7(%rip), %r14      # 0x1889e
leaq -0x80(%rbp), %r15
leaq 0xfaf5(%rip), %r12      # 0x188a7
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
cmpq -0x78(%rbp), %rax
jae 0x9095
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x23b0
cmpq %rax, %r13
jae 0x8e22
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %rax, %r13
movq %r15, %rdi
leaq 0xfb4e(%rip), %rsi      # 0x18960
xorl %edx, %edx
callq 0x23b0
cmpq %rax, %r13
jb 0x8fc0
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x23b0
movq %rax, %r13
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
cmpq %rax, %r13
jae 0x8db2
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x23b0
movq %rax, %r13
movq %r15, %rdi
leaq 0xfafe(%rip), %rsi      # 0x18960
xorl %edx, %edx
callq 0x23b0
cmpq %rax, %r13
jae 0x8db2
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x23b0
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21e0
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x23b0
leaq 0x1(%rax), %r13
movq %r15, %rdi
leaq 0xf9fe(%rip), %rsi      # 0x188a9
xorl %edx, %edx
callq 0x23b0
leaq -0xa0(%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x21e0
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x20b0
leaq -0x60(%rbp), %r13
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %r15, %rdi
movq %rax, %rsi
pushq $0x1
popq %rdx
callq 0x20b0
movq -0xa0(%rbp), %rdi
callq 0x22e0
movl %eax, -0x3c(%rbp)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x16393(%rip), %rdi     # 0x1f2b8
callq 0x155d4
movq (%rax), %rdi
movq %r13, %rsi
callq 0x1556a
cmpl $0x0, (%rax)
jne 0x91f3
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x16364(%rip), %rdi     # 0x1f2b8
callq 0x155d4
movq (%rax), %rdi
movq %r13, %rsi
callq 0x1556a
movq -0x30(%rbp), %rcx
addl -0x3c(%rbp), %ecx
movq %rcx, -0x30(%rbp)
leal (,%rcx,4), %ecx
movl %ecx, (%rax)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1638a(%rip), %rdi     # 0x1f318
callq 0x155d4
movq (%rax), %rdi
movq %r13, %rsi
callq 0x1556a
movq -0x38(%rbp), %rcx
addl -0x3c(%rbp), %ecx
movq %rcx, -0x38(%rbp)
movl $0x1, (%rax)
leaq -0xa0(%rbp), %rdi
callq 0x23c8
jmp 0x9088
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
leaq -0x60(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21e0
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x20b0
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x23b0
movq %r15, %rdi
movq %rax, %rsi
pushq $0x1
popq %rdx
callq 0x20b0
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1628c(%rip), %rdi     # 0x1f2b8
callq 0x155d4
movq (%rax), %rdi
movq %r13, %rsi
callq 0x1556a
cmpl $0x0, (%rax)
jne 0x91be
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1625d(%rip), %rdi     # 0x1f2b8
callq 0x155d4
movq (%rax), %rdi
movq %r13, %rsi
callq 0x1556a
movq -0x38(%rbp), %rcx
incl %ecx
movq %rcx, -0x38(%rbp)
movq -0x30(%rbp), %rcx
incl %ecx
movq %rcx, -0x30(%rbp)
leal (,%rcx,4), %ecx
movl %ecx, (%rax)
movq %r13, %rdi
callq 0x23c8
jmp 0x8db2
movq 0x28(%rbx), %rax
movq -0x30(%rbp), %r15
movq -0x38(%rbp), %r12
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x16205(%rip), %rdi     # 0x1f2b8
callq 0x155d4
movq (%rax), %r14
leaq 0xfbf6(%rip), %rsi      # 0x18cb8
leaq -0x60(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x70d8
leaq -0x60(%rbp), %rsi
movq %r14, %rdi
callq 0x15500
shll $0x2, %r15d
movl %r15d, (%rax)
leaq -0x60(%rbp), %rdi
callq 0x23c8
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x161b4(%rip), %rdi     # 0x1f2b8
callq 0x155d4
movq (%rax), %rbx
leaq 0xfba4(%rip), %rsi      # 0x18cb7
leaq -0x60(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x70d8
leaq -0x60(%rbp), %rsi
movq %rbx, %rdi
callq 0x15500
movl %r12d, (%rax)
leaq -0x60(%rbp), %rdi
callq 0x23c8
leaq -0x80(%rbp), %rdi
callq 0x23c8
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16136(%rip), %rax     # 0x1f290
movq (%rax), %rdi
movq 0x15e44(%rip), %rax     # 0x1efa8
movq (%rax), %rdx
leaq 0xf97b(%rip), %rsi      # 0x18ae9
callq 0x2210
movq 0x15e56(%rip), %rdi     # 0x1efd0
leaq 0xfadf(%rip), %rsi      # 0x18c60
callq 0x21a0
movq 0x15e4b(%rip), %rbx     # 0x1efd8
movq (%rbx), %rcx
leaq 0xfad0(%rip), %rdi      # 0x18c67
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x2390
movq (%rbx), %rdi
movq -0x60(%rbp), %rdx
leaq 0xfac7(%rip), %rsi      # 0x18c77
xorl %eax, %eax
callq 0x2290
xorl %edi, %edi
callq 0x2240
leaq 0x160cb(%rip), %rax     # 0x1f290
movq (%rax), %rdi
movq 0x15dd9(%rip), %rax     # 0x1efa8
movq (%rax), %rdx
leaq 0xf910(%rip), %rsi      # 0x18ae9
callq 0x2210
movq 0x15deb(%rip), %rdi     # 0x1efd0
leaq 0xfa74(%rip), %rsi      # 0x18c60
callq 0x21a0
jmp 0x9186
leaq 0x16096(%rip), %rax     # 0x1f290
movq (%rax), %rdi
movq 0x15da4(%rip), %rax     # 0x1efa8
movq (%rax), %rdx
leaq 0xf8db(%rip), %rsi      # 0x18ae9
callq 0x2210
movq 0x15db6(%rip), %rdi     # 0x1efd0
leaq 0xfa3f(%rip), %rsi      # 0x18c60
callq 0x21a0
jmp 0x9186
jmp 0x9241
jmp 0x925b
jmp 0x9256
jmp 0x925b
jmp 0x9256
jmp 0x9256
jmp 0x925b
jmp 0x9256
jmp 0x925b
jmp 0x9256
jmp 0x925b
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x23c8
jmp 0x925e
jmp 0x9256
jmp 0x925b
movq %rax, %rbx
jmp 0x9267
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x23c8
leaq -0x80(%rbp), %rdi
callq 0x23c8
movq %rbx, %rdi
callq 0x2340