// File: /workspace/github_c_makefile_star2_O2/zyearn[P]SmallC/codegen.cpp
// Function: genDec(treeNode*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void genDec(treeNode* node, int type, string scope)
{
    switch(type)
    {
        case 1://´ËÇé¿öÃ»ÓÐ¸³Öµ£¬²»¿¼ÂÇ
        break;
        case 2:
        {   
            if(scope == "_G")
                cout << "_G_" << globalNumber << ":" << endl;
            //¶Ô±äÁ¿¸³Öµ
            if ( node->child[0]->type==1)
            {
                genInit(node->child[2],node->child[2]->type,scope);
                if((*FT[scope])[node->child[0]->child[0]->data] != 0 && scope != "_G")
                    cout << "sw $t0, " << 4 + (*FT[scope])["#"] - (*FT[scope])[node->child[0]->child[0]->data] << "($s0)" << endl;
                else if((*FT["_G"])[node->child[0]->child[0]->data] != 0 )  
                    cout << "sw $t0, " << (*FT["_G"])["#"] - (*FT["_G"])[node->child[0]->child[0]->data] << "($s2)" << endl;
                else
                {
                    freopen(outputFile.c_str(), "w", stdout);
                    cout << "Error.";
                    fprintf(stderr, "\nCompile fail!\n");
                    fprintf(stderr, "error occurs, %s is not defined\n",  (node->child[0]->child[0]->data).c_str() );
                    exit(0);
                }
            }
            //¶ÔÊý×é¸³Öµ
            else if(node->child[0]->type==2)
            {
                if(node->child[2]->childnum != 3)
                {
                    freopen(outputFile.c_str(), "w", stdout);
                    cout << "Error.";
                    fprintf(stderr, "\nCompile fail!\n");
                    fprintf(stderr, "error occurs, %s wrong array initialization\n",(node->child[0]->child[0]->child[0]->data).c_str() );
                    exit(0);
                }
                //cout << "sw $t0, " << 4 + (*FT[scope])["#"] - (*FT[scope])[node->child[0]->data] << "($s0)" << endl;
                string num = node->child[0]->child[2]->data;
                int n = atoi(num.c_str());
                int size = 1;
                treeNode *tmp = node->child[2]->child[1];
                while(tmp->childnum == 3)
                {
                    size++;
                    tmp = tmp->child[2];
                }
                if(size > n)
                {
                    freopen(outputFile.c_str(), "w", stdout);
                    cout << "Error.";
                    fprintf(stderr, "\nCompile fail!\n");
                    fprintf(stderr, "error occurs, %s argument is too large\n",( node->child[0]->child[0]->child[0]->data ).c_str() );
                    exit(0);
                }
                tmp = node->child[2]->child[1];
                for(int i=0; i<size; i++)
                {
                    genExp(tmp->child[0],tmp->child[0]->type, scope);
                    //if(i == 0)
                    //  cout << tmp->child[0]->child[0]->data << endl;
                    if(tmp->childnum == 3)
                        tmp = tmp->child[2];
                    if(scope != "_G")
                        cout << "sw $t0, " << 4 + (*FT[scope])["#"]-(*FT[scope])[node->child[0]->child[0]->child[0]->data]+i*4 << "($s0)" << endl;
                    else
                        cout << "sw $t0, " << (*FT[scope])["#"]-(*FT[scope])[node->child[0]->child[0]->child[0]->data]+i*4 << "($s2)" << endl;
                }
            }
            if(scope == "_G")
                cout << "j _G_" << ++globalNumber << endl;
            break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, -0x30(%rbp)
cmpl $0x2, %esi
jne 0x9df3
movq %rdx, %rbx
leaq 0xf02b(%rip), %rsi      # 0x1888c
movq %rdx, %rdi
callq 0x156b3
testb %al, %al
je 0x98a8
movq 0x1575c(%rip), %rdi     # 0x1efd0
leaq 0xf652(%rip), %rsi      # 0x18ecd
callq 0x21a0
leaq 0x15979(%rip), %rcx     # 0x1f200
movl (%rcx), %esi
movq %rax, %rdi
callq 0x2320
leaq 0xf459(%rip), %rsi      # 0x18cf1
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x2120
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rcx
movl 0x24(%rcx), %edx
cmpl $0x2, %edx
je 0x99ea
cmpl $0x1, %edx
jne 0x9db0
movq 0x10(%rax), %r14
movl 0x24(%r14), %r15d
leaq -0xe8(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2280
movq %r14, %rdi
movl %r15d, %esi
movq %r12, %rdx
callq 0x15349
leaq -0xe8(%rbp), %rdi
callq 0x23c8
leaq 0x159b5(%rip), %rdi     # 0x1f2b8
movq %rbx, %rsi
callq 0x155d4
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
callq 0x1556a
cmpl $0x0, (%rax)
je 0x9c66
leaq 0xef57(%rip), %rsi      # 0x1888c
movq %rbx, %rdi
callq 0x1563d
testb %al, %al
je 0x9c66
movq 0x15684(%rip), %rdi     # 0x1efd0
leaq 0xf51a(%rip), %rsi      # 0x18e6d
callq 0x21a0
movq %rax, %r14
leaq 0x15956(%rip), %rdi     # 0x1f2b8
movq %rbx, %rsi
callq 0x155d4
movq (%rax), %r15
leaq 0xf344(%rip), %rsi      # 0x18cb8
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x70d8
leaq -0x68(%rbp), %rsi
movq %r15, %rdi
callq 0x15500
movl (%rax), %r15d
leaq 0x1591e(%rip), %rdi     # 0x1f2b8
movq %rbx, %rsi
callq 0x155d4
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
callq 0x1556a
addl $0x4, %r15d
subl (%rax), %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x2320
leaq 0xf84c(%rip), %rsi      # 0x19221
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x2120
jmp 0x9da7
movq 0x10(%rax), %rax
cmpl $0x3, 0x20(%rax)
jne 0x9e05
movq 0x28(%rcx), %rax
movq 0x10(%rax), %rsi
leaq -0x68(%rbp), %r14
movq %r14, %rdi
callq 0x2280
movq (%r14), %rdi
callq 0x22e0
movq -0x30(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq 0x10(%rcx), %rcx
movq 0x28(%rcx), %rcx
addq $0x8, %rcx
pushq $0x1
popq %r15
movq %rcx, %rdx
movq (%rdx), %rdx
cmpl $0x3, 0x20(%rdx)
jne 0x9a45
incl %r15d
movq 0x28(%rdx), %rdx
addq $0x10, %rdx
jmp 0x9a2f
movq %rbx, -0x38(%rbp)
cmpl %eax, %r15d
jg 0x9e7f
movq (%rcx), %rcx
pushq $0x4
popq %rax
movq %rax, -0x48(%rbp)
leaq -0xc8(%rbp), %rdi
subl $0x1, %r15d
jb 0x9c54
movq %rcx, %rbx
movq 0x28(%rcx), %rax
movq (%rax), %r14
movl 0x24(%r14), %r13d
movq -0x38(%rbp), %rsi
callq 0x2280
movq %r14, %rdi
movl %r13d, %esi
leaq -0xc8(%rbp), %r14
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xb2d0
movq %r14, %rdi
callq 0x23c8
cmpl $0x3, 0x20(%rbx)
jne 0x9ab1
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rbx
movq -0x38(%rbp), %rdi
leaq 0xedd0(%rip), %rsi      # 0x1888c
callq 0x1563d
testb %al, %al
je 0x9b7c
movq 0x15500(%rip), %rdi     # 0x1efd0
leaq 0xf396(%rip), %rsi      # 0x18e6d
callq 0x21a0
movq %rax, %r14
leaq 0x157d2(%rip), %rdi     # 0x1f2b8
movq -0x38(%rbp), %rsi
callq 0x155d4
movq (%rax), %r13
leaq -0x88(%rbp), %r12
movq %r12, %rdi
leaq 0xf1b5(%rip), %rsi      # 0x18cb8
leaq -0xa8(%rbp), %rdx
callq 0x70d8
movq %r13, %rdi
movq %r12, %rsi
callq 0x15500
movl (%rax), %r13d
leaq 0x15794(%rip), %rdi     # 0x1f2b8
movq -0x38(%rbp), %rsi
callq 0x155d4
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
callq 0x1556a
subl (%rax), %r13d
addl -0x48(%rbp), %r13d
movq %r14, %rdi
movl %r13d, %esi
callq 0x2320
movq %rax, %rdi
leaq 0xf6b7(%rip), %rsi      # 0x19221
callq 0x21a0
movq %rax, %rdi
callq 0x2120
jmp 0x9c2e
movq 0x1544d(%rip), %rdi     # 0x1efd0
leaq 0xf2e3(%rip), %rsi      # 0x18e6d
callq 0x21a0
movq %rax, %r14
leaq 0x1571f(%rip), %rdi     # 0x1f2b8
movq -0x38(%rbp), %rsi
callq 0x155d4
movq (%rax), %r13
leaq -0x88(%rbp), %r12
movq %r12, %rdi
leaq 0xf102(%rip), %rsi      # 0x18cb8
leaq -0xa8(%rbp), %rdx
callq 0x70d8
movq %r13, %rdi
movq %r12, %rsi
callq 0x15500
movl (%rax), %r13d
leaq 0x156e1(%rip), %rdi     # 0x1f2b8
movq -0x38(%rbp), %rsi
callq 0x155d4
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
callq 0x1556a
subl (%rax), %r13d
movq -0x48(%rbp), %rax
leal (%rax,%r13), %esi
addl $-0x4, %esi
movq %r14, %rdi
callq 0x2320
movq %rax, %rdi
leaq 0xf1a8(%rip), %rsi      # 0x18dc9
callq 0x21a0
movq %rax, %rdi
callq 0x2120
leaq -0x88(%rbp), %rdi
callq 0x23c8
movq -0x48(%rbp), %rax
addl $0x4, %eax
movq %rax, -0x48(%rbp)
leaq -0xc8(%rbp), %rdi
movq %rbx, %rcx
jmp 0x9a63
leaq -0x68(%rbp), %rdi
callq 0x23c8
movq -0x38(%rbp), %rbx
jmp 0x9db0
leaq 0xec1f(%rip), %rsi      # 0x1888c
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x70d8
movq %rbx, %r14
leaq 0x15631(%rip), %rdi     # 0x1f2b8
leaq -0x68(%rbp), %rsi
callq 0x718c
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
callq 0x1556a
movl (%rax), %ebx
leaq -0x68(%rbp), %rdi
callq 0x23c8
testl %ebx, %ebx
je 0x9ef6
movq 0x1530c(%rip), %rdi     # 0x1efd0
leaq 0xf1a2(%rip), %rsi      # 0x18e6d
callq 0x21a0
movq %rax, %r15
leaq 0xebb2(%rip), %rsi      # 0x1888c
leaq -0x68(%rbp), %rdi
leaq -0x3b(%rbp), %rdx
callq 0x70d8
leaq 0x155ca(%rip), %rdi     # 0x1f2b8
leaq -0x68(%rbp), %rsi
callq 0x718c
movq %r14, %rbx
movq (%rax), %r14
leaq 0xefb4(%rip), %rsi      # 0x18cb8
leaq -0x88(%rbp), %rdi
leaq -0x3a(%rbp), %rdx
callq 0x70d8
leaq -0x88(%rbp), %rsi
movq %r14, %rdi
callq 0x15500
movl (%rax), %r14d
leaq 0xeb5f(%rip), %rsi      # 0x1888c
leaq -0xa8(%rbp), %rdi
leaq -0x39(%rbp), %rdx
callq 0x70d8
leaq 0x15574(%rip), %rdi     # 0x1f2b8
leaq -0xa8(%rbp), %rsi
callq 0x718c
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rsi
callq 0x1556a
subl (%rax), %r14d
movq %r15, %rdi
movl %r14d, %esi
callq 0x2320
leaq 0xf04a(%rip), %rsi      # 0x18dc9
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x2120
leaq -0xa8(%rbp), %rdi
callq 0x23c8
leaq -0x88(%rbp), %rdi
callq 0x23c8
leaq -0x68(%rbp), %rdi
callq 0x23c8
leaq 0xead5(%rip), %rsi      # 0x1888c
movq %rbx, %rdi
callq 0x156b3
testb %al, %al
je 0x9df3
movq 0x15206(%rip), %rdi     # 0x1efd0
leaq 0xf0fa(%rip), %rsi      # 0x18ecb
callq 0x21a0
leaq 0x15423(%rip), %rcx     # 0x1f200
movl (%rcx), %esi
incl %esi
movl %esi, (%rcx)
movq %rax, %rdi
callq 0x2320
movq %rax, %rdi
callq 0x2120
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15484(%rip), %rax     # 0x1f290
movq (%rax), %rdi
movq 0x15192(%rip), %rax     # 0x1efa8
movq (%rax), %rdx
leaq 0xecc9(%rip), %rsi      # 0x18ae9
callq 0x2210
movq 0x151a4(%rip), %rdi     # 0x1efd0
leaq 0xee2d(%rip), %rsi      # 0x18c60
callq 0x21a0
movq 0x15199(%rip), %rbx     # 0x1efd8
movq (%rbx), %rcx
leaq 0xee1e(%rip), %rdi      # 0x18c67
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x2390
movq (%rbx), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq (%rax), %rdx
leaq 0xeffc(%rip), %rsi      # 0x18e76
jmp 0x9f64
leaq 0x1540a(%rip), %rax     # 0x1f290
movq (%rax), %rdi
movq 0x15118(%rip), %rax     # 0x1efa8
movq (%rax), %rdx
leaq 0xec4f(%rip), %rsi      # 0x18ae9
callq 0x2210
movq 0x1512a(%rip), %rdi     # 0x1efd0
leaq 0xedb3(%rip), %rsi      # 0x18c60
callq 0x21a0
movq 0x1511f(%rip), %rbx     # 0x1efd8
movq (%rbx), %rcx
leaq 0xeda4(%rip), %rdi      # 0x18c67
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x2390
movq (%rbx), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq (%rax), %rdx
leaq 0xefaf(%rip), %rsi      # 0x18ea3
jmp 0x9f64
leaq 0x15393(%rip), %rax     # 0x1f290
movq (%rax), %rdi
movq 0x150a1(%rip), %rax     # 0x1efa8
movq (%rax), %rdx
leaq 0xebd8(%rip), %rsi      # 0x18ae9
callq 0x2210
movq 0x150b3(%rip), %rdi     # 0x1efd0
leaq 0xed3c(%rip), %rsi      # 0x18c60
callq 0x21a0
movq 0x150a8(%rip), %rbx     # 0x1efd8
movq (%rbx), %rcx
leaq 0xed2d(%rip), %rdi      # 0x18c67
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x2390
movq (%rbx), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq (%rax), %rdx
leaq 0xed32(%rip), %rsi      # 0x18c96
xorl %eax, %eax
callq 0x2290
xorl %edi, %edi
callq 0x2240
jmp 0x9f7e
jmp 0x9fb8
jmp 0x9fb8
jmp 0x9fc9
jmp 0x9fc9
jmp 0x9f7e
movq %rax, %rbx
jmp 0x9fd5
jmp 0x9fc9
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0x9fd0
jmp 0x9fc9
jmp 0x9fc9
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x23c8
jmp 0x9fbb
jmp 0x9fc9
jmp 0x9fc9
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0x9fc2
jmp 0x9fb8
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x23c8
jmp 0x9fcc
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x23c8
movq %rbx, %rdi
callq 0x2340