// File: /workspace/github_c_makefile_star2_O3/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 0x1b45e(%rip), %rdi     # 0x282b0
callq 0x1e4be
cmpq $0x0, (%rax)
jne 0xcea8
movl $0x30, %edi
callq 0x21d0
movq %rax, %r14
addq $0x8, %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%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 0x1b410(%rip), %rdi     # 0x282b0
callq 0x1e4be
movq %r14, (%rax)
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1b452(%rip), %rdi     # 0x28310
callq 0x1e4be
cmpq $0x0, (%rax)
jne 0xcf14
movl $0x30, %edi
callq 0x21d0
movq %rax, %r14
addq $0x8, %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%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 0x1b404(%rip), %rdi     # 0x28310
callq 0x1e4be
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 0xb00c
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpb $0x2c, -0x1(%rax,%rcx)
je 0xcf60
leaq 0x14947(%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 0xd0de
leaq 0x14917(%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 0xd0de
xorl %ebx, %ebx
movl $0x4, %r13d
leaq 0x148d4(%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 0x1b265(%rip), %rdi     # 0x282b0
callq 0x1e4be
movq (%rax), %rdi
movq %r12, %rsi
callq 0x1e43e
cmpl $0x0, (%rax)
jne 0xd5fb
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1b232(%rip), %rdi     # 0x282b0
callq 0x1e4be
movq (%rax), %rdi
movq %r12, %rsi
callq 0x1e43e
movl %r13d, (%rax)
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xd0aa
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 0xcfce
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 0xd11a
leaq 0x1478d(%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 0xd503
leaq 0x14763(%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 0xd503
movq $0x0, -0x58(%rbp)
leaq 0x14722(%rip), %r14     # 0x2189e
leaq 0x14724(%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 0xd2d9
movl $0x1, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movq %rax, %r13
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x14789(%rip), %rsi     # 0x21960
xorl %edx, %edx
callq 0x2340
cmpq %rax, %r13
jae 0xd2d9
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 0x1b04b(%rip), %rdi     # 0x282b0
callq 0x1e4be
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e43e
cmpl $0x0, (%rax)
jne 0xd637
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1b017(%rip), %rdi     # 0x282b0
callq 0x1e4be
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e43e
incl %ebx
leal (,%rbx,4), %ecx
movl %ecx, (%rax)
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xd2ce
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x58(%rbp), %rax
incl %eax
jmp 0xd4cf
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 0xd4d3
movl $0x1, %ecx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2340
movq %rax, %r13
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x14633(%rip), %rsi     # 0x21960
xorl %edx, %edx
callq 0x2340
cmpq %rax, %r13
jae 0xd4d3
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 0x14524(%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 0x1aea5(%rip), %rdi     # 0x282b0
callq 0x1e4be
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e43e
cmpl $0x0, (%rax)
jne 0xd673
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1ae71(%rip), %rdi     # 0x282b0
callq 0x1e4be
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e43e
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 0x1ae9a(%rip), %rdi     # 0x28310
callq 0x1e4be
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1e43e
movl $0x1, (%rax)
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xd4af
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xd4c8
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 0xd183
jmp 0xd50b
movq $0x0, -0x58(%rbp)
movq -0x50(%rbp), %r12
movq 0x28(%r12), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1ad8a(%rip), %rdi     # 0x282b0
callq 0x1e4be
movq (%rax), %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1477b(%rip), %rsi     # 0x21cb8
leaq 0x14775(%rip), %rdx     # 0x21cb9
leaq -0x48(%rbp), %rdi
callq 0xb0aa
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1e3be
shll $0x2, %ebx
movl %ebx, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0xd573
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movq 0x28(%r12), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
leaq 0x1ad26(%rip), %rdi     # 0x282b0
callq 0x1e4be
movq (%rax), %rbx
leaq -0x48(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x14717(%rip), %rsi     # 0x21cb7
leaq 0x14712(%rip), %rdx     # 0x21cb9
callq 0xb0aa
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x1e3be
movq -0x58(%rbp), %rcx
movl %ecx, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0xd5d3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0xd5ec
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 0x1ac86(%rip), %rax     # 0x28288
movq (%rax), %rdi
movq 0x1a99c(%rip), %rax     # 0x27fa8
movq (%rax), %rdx
leaq 0x144d3(%rip), %rsi     # 0x21ae9
callq 0x2220
movq 0x1a9ae(%rip), %rdi     # 0x27fd0
leaq 0x14637(%rip), %rsi     # 0x21c60
callq 0x21b0
leaq -0x48(%rbp), %rdi
callq 0x2609
leaq 0x1ac4a(%rip), %rax     # 0x28288
movq (%rax), %rdi
movq 0x1a960(%rip), %rax     # 0x27fa8
movq (%rax), %rdx
leaq 0x14497(%rip), %rsi     # 0x21ae9
callq 0x2220
movq 0x1a972(%rip), %rdi     # 0x27fd0
leaq 0x145fb(%rip), %rsi     # 0x21c60
callq 0x21b0
leaq -0x48(%rbp), %rdi
callq 0x268b
leaq 0x1ac0e(%rip), %rax     # 0x28288
movq (%rax), %rdi
movq 0x1a924(%rip), %rax     # 0x27fa8
movq (%rax), %rdx
leaq 0x1445b(%rip), %rsi     # 0x21ae9
callq 0x2220
movq 0x1a936(%rip), %rdi     # 0x27fd0
leaq 0x145bf(%rip), %rsi     # 0x21c60
callq 0x21b0
leaq -0x48(%rbp), %rdi
callq 0x264a
jmp 0xd6d3
jmp 0xd6b5
jmp 0xd6d3
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
jne 0xd711
jmp 0xd71d
jmp 0xd6d3
jmp 0xd6d8
jmp 0xd701
jmp 0xd701
jmp 0xd6d3
jmp 0xd6d3
jmp 0xd6d3
jmp 0xd701
movq %rax, %rbx
jmp 0xd71d
movq %rax, %rbx
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xd704
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21e0
jmp 0xd704
jmp 0xd701
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xd71d
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21e0
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0xd736
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x21e0
movq %rbx, %rdi
callq 0x2360