// File: /workspace/github_c_makefile_star2_O1/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 0x1b292(%rip), %rdi     # 0x282b0
callq 0x1e7b4
cmpq $0x0, (%rax)
jne 0xd079
movl $0x30, %edi
callq 0x21d0
movq %rax, %r14
addq $0x8, %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, (%r14)
movq %rax, 0x18(%r14)
movq %rax, 0x20(%r14)
movq $0x0, 0x28(%r14)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1b23f(%rip), %rdi     # 0x282b0
callq 0x1e7b4
movq %r14, (%rax)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1b281(%rip), %rdi     # 0x28310
callq 0x1e7b4
cmpq $0x0, (%rax)
jne 0xd0ea
movl $0x30, %edi
callq 0x21d0
movq %rax, %r14
addq $0x8, %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, (%r14)
movq %rax, 0x18(%r14)
movq %rax, 0x20(%r14)
movq $0x0, 0x28(%r14)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1b22e(%rip), %rdi     # 0x28310
callq 0x1e7b4
movq %r14, (%rax)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
leaq -0x68(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %r14
movq %r14, %rdi
callq 0xb1ca
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpb $0x2c, -0x1(%rax,%rcx)
je 0xd136
leaq 0x14771(%rip), %rsi     # 0x2189e
leaq -0x78(%rbp), %rdi
callq 0x2390
movq %rbx, -0x50(%rbp)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
xorl %ebx, %ebx
cmpl $0x3, 0x24(%rax)
je 0xd2b4
leaq 0x14741(%rip), %r14     # 0x2189e
xorl %ebx, %ebx
leaq -0x78(%rbp), %r15
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
cmpq 0x8(%r15), %rax
jae 0xd2b4
xorl %ebx, %ebx
movl $0x4, %r13d
leaq 0x146fe(%rip), %r14     # 0x2189e
leaq -0x48(%rbp), %r12
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21f0
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x20c0
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movl $0x1, %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x20c0
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1b08f(%rip), %rdi     # 0x282b0
callq 0x1e7b4
movq (%rax), %rdi
movq %r12, %rsi
callq 0x1e734
cmpl $0x0, (%rax)
jne 0xd7d1
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1b05c(%rip), %rdi     # 0x282b0
callq 0x1e7b4
movq (%rax), %rdi
movq %r12, %rsi
callq 0x1e734
movl %r13d, (%rax)
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xd280
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
addl $0x4, %r13d
incl %ebx
cmpq -0x70(%rbp), %rax
jb 0xd1a4
movq -0x50(%rbp), %r14
movq 0x28(%r14), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rsi
leaq -0x78(%rbp), %rdi
callq 0x2140
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rcx
cmpb $0x2c, -0x1(%rax,%rcx)
je 0xd2f0
leaq 0x145b7(%rip), %rsi     # 0x2189e
leaq -0x78(%rbp), %rdi
callq 0x2390
movq 0x28(%r14), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x1, 0x24(%rax)
jne 0xd6d9
leaq 0x1458d(%rip), %r14     # 0x2189e
leaq -0x78(%rbp), %r15
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
cmpq 0x8(%r15), %rax
jae 0xd6d9
movq $0x0, -0x58(%rbp)
leaq 0x1454c(%rip), %r14     # 0x2189e
leaq 0x1454e(%rip), %r12     # 0x218a7
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movq %rax, %r13
movl $0x1, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2340
cmpq %rax, %r13
jae 0xd4af
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movq %rax, %r13
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x145b3(%rip), %rsi     # 0x21960
xorl %edx, %edx
callq 0x2340
cmpq %rax, %r13
jae 0xd4af
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
leaq -0x48(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21f0
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x20c0
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movl $0x1, %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x20c0
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1ae75(%rip), %rdi     # 0x282b0
callq 0x1e7b4
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e734
cmpl $0x0, (%rax)
jne 0xd80d
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1ae41(%rip), %rdi     # 0x282b0
callq 0x1e7b4
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e734
incl %ebx
leal (,%rbx,4), %ecx
movl %ecx, (%rax)
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xd4a4
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x58(%rbp), %rax
incl %eax
jmp 0xd6a5
movl $0x1, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2340
movq %rax, %r13
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
cmpq %rax, %r13
jae 0xd6a9
movl $0x1, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2340
movq %rax, %r13
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x1445d(%rip), %rsi     # 0x21960
xorl %edx, %edx
callq 0x2340
cmpq %rax, %r13
jae 0xd6a9
movl $0x1, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2340
leaq -0x48(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21f0
movl $0x1, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2340
leaq 0x1(%rax), %r13
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x1434e(%rip), %rsi     # 0x218a9
xorl %edx, %edx
callq 0x2340
leaq -0x98(%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x21f0
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x20c0
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movl $0x1, %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x20c0
movq -0x98(%rbp), %rdi
callq 0x22f0
movl %eax, %r13d
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1accf(%rip), %rdi     # 0x282b0
callq 0x1e7b4
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e734
cmpl $0x0, (%rax)
jne 0xd849
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1ac9b(%rip), %rdi     # 0x282b0
callq 0x1e7b4
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e734
addl %r13d, %ebx
leal (,%rbx,4), %ecx
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1acc4(%rip), %rdi     # 0x28310
callq 0x1e7b4
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e734
movl $0x1, (%rax)
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xd685
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xd69e
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x58(%rbp), %rax
addl %r13d, %eax
movq %rax, -0x58(%rbp)
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
cmpq -0x70(%rbp), %rax
jb 0xd359
jmp 0xd6e1
movq $0x0, -0x58(%rbp)
movq -0x50(%rbp), %r12
movq 0x28(%r12), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1abb4(%rip), %rdi     # 0x282b0
callq 0x1e7b4
movq (%rax), %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x145a5(%rip), %rsi     # 0x21cb8
leaq 0x1459f(%rip), %rdx     # 0x21cb9
leaq -0x48(%rbp), %rdi
callq 0xb264
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1e6b4
shll $0x2, %ebx
movl %ebx, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0xd749
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movq 0x28(%r12), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1ab50(%rip), %rdi     # 0x282b0
callq 0x1e7b4
movq (%rax), %rbx
leaq -0x48(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x14541(%rip), %rsi     # 0x21cb7
leaq 0x1453c(%rip), %rdx     # 0x21cb9
callq 0xb264
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x1e6b4
movq -0x58(%rbp), %rcx
movl %ecx, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0xd7a9
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0xd7c2
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x21e0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1aab0(%rip), %rax     # 0x28288
movq (%rax), %rdi
movq 0x1a7c6(%rip), %rax     # 0x27fa8
movq (%rax), %rdx
leaq 0x142fd(%rip), %rsi     # 0x21ae9
callq 0x2220
movq 0x1a7d8(%rip), %rdi     # 0x27fd0
leaq 0x14461(%rip), %rsi     # 0x21c60
callq 0x21b0
leaq -0x48(%rbp), %rdi
callq 0x2609
leaq 0x1aa74(%rip), %rax     # 0x28288
movq (%rax), %rdi
movq 0x1a78a(%rip), %rax     # 0x27fa8
movq (%rax), %rdx
leaq 0x142c1(%rip), %rsi     # 0x21ae9
callq 0x2220
movq 0x1a79c(%rip), %rdi     # 0x27fd0
leaq 0x14425(%rip), %rsi     # 0x21c60
callq 0x21b0
leaq -0x48(%rbp), %rdi
callq 0x268b
leaq 0x1aa38(%rip), %rax     # 0x28288
movq (%rax), %rdi
movq 0x1a74e(%rip), %rax     # 0x27fa8
movq (%rax), %rdx
leaq 0x14285(%rip), %rsi     # 0x21ae9
callq 0x2220
movq 0x1a760(%rip), %rdi     # 0x27fd0
leaq 0x143e9(%rip), %rsi     # 0x21c60
callq 0x21b0
leaq -0x48(%rbp), %rdi
callq 0x264a
jmp 0xd8a9
jmp 0xd88b
jmp 0xd8a9
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
jne 0xd8e7
jmp 0xd8f3
jmp 0xd8a9
jmp 0xd8ae
jmp 0xd8d7
jmp 0xd8d7
jmp 0xd8a9
jmp 0xd8a9
jmp 0xd8a9
jmp 0xd8d7
movq %rax, %rbx
jmp 0xd8f3
movq %rax, %rbx
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xd8da
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21e0
jmp 0xd8da
jmp 0xd8d7
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xd8f3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0xd90c
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x21e0
movq %rbx, %rdi
callq 0x2360