// File: /workspace/github_cpp_makefile_star2_O3/zhengwangsun[P]pas2c/semantics.cpp
// Function: statement1(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int statement1(int k, int idType, string idValue)
{
	TreeNode tNode= tree.node[k];
	TreeNode childNode;
    
    if(lookahead(k) == 24)//24是variable'
    {
    	if(idValue == currentTable)
    	{
    		variable1(tree.node[k].child[0]);
        	code[currentLine]="return "; //assignop
            
    	}
        else
		{
        	variable1(tree.node[k].child[0]);
        	code[currentLine].append("="); //assignop
        }
        
        int flag1 = expression(tree.node[k].child[2],1);
        
        code[currentLine++].append(";\n");  
        if (idType == 4)//前面的id是函数（4）
        {
            //获取函数返回值类型，不允许嵌套，所以只在主符号表里面搜索
            int funRetureType = 0;
            for (vector<subTableItem>::iterator it = subTable.begin(); it != subTable.end();it++)
            {
                if (it->name == idValue)
                {
                    funRetureType = it->returnType;
                    break;
                }
            }
            if (funRetureType < flag1) {
                errorLine = tree.node[k].row;
                cout<<"function return type wrong where statement1 in line "<<errorLine<<endl;
                exit(1);
                return -1;
            }
            else
                return flag1;
        }
        else if (idType == 5)//statement'前面的id类型是过程
        {
            errorLine = tree.node[k].row;
            cout<<"there is no return in proce where statement1 in line "<<errorLine<<endl;
            exit(1);
            return -1;
        }
        else if (idType < flag1)//id是普通变量，但类型小于expression
        {
            errorLine = tree.node[k].row;
            cout<<"id assignop type wrong where statement1 in line "<<errorLine<<endl;
            exit(1);
            return -1;
        }
            
        else
            return flag1;
    }
    else if(lookahead(k) == 26)//26是procedure_call_statement’
    {
        procedure_call_statement1(tree.node[k].child[0], idValue);
        code[currentLine++].append(";\n");
        return 0;
    }
    else
    {
        cout<<"statement' error!"<<endl;
        return -1;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdx, %r14
movl %esi, 0x4(%rsp)
movslq %edi, %rax
imulq $0xa8, %rax, %rax
leaq 0xad537(%rip), %r12     # 0xb90c8
leaq (%r12,%rax), %rbx
addq $0x8, %rbx
leaq 0x28(%rsp), %rax
movl $0xb, %ecx
movq %rax, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movb 0x58(%rbx), %cl
movb %cl, 0x58(%rax)
leaq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
addq %rsi, %rdx
callq 0x7666
leaq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq 0x80(%rbx), %rsi
movq 0x88(%rbx), %rdx
addq %rsi, %rdx
callq 0x7666
movq 0xa0(%rbx), %rax
movq %rax, 0xc8(%rsp)
leaq 0x140(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x160(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
cmpl $0x0, (%rbx)
jle 0xbcb3
movslq 0x4(%rbx), %r15
imulq $0xa8, %r15, %rax
movl 0x5c(%r12,%rax), %eax
cmpl $0x1a, %eax
je 0xbd04
cmpl $0x18, %eax
jne 0xbcb3
movq 0x8(%r14), %rdx
cmpq 0xa6cad(%rip), %rdx     # 0xb2910
jne 0xbc85
testq %rdx, %rdx
je 0xbd78
movq 0xa6c93(%rip), %rsi     # 0xb2908
movq (%r14), %rdi
callq 0x2240
testl %eax, %eax
je 0xbd78
movl %r15d, %edi
callq 0xc2b2
movslq 0xa791c(%rip), %rax     # 0xb35b0
shlq $0x5, %rax
leaq 0xa6c91(%rip), %rdi     # 0xb2930
addq %rax, %rdi
leaq 0x75ce(%rip), %rsi      # 0x13277
callq 0x23d0
jmp 0xbdaf
movq 0xd316(%rip), %rbx      # 0x18fd0
leaq 0x7c4a(%rip), %rsi      # 0x1390b
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2280
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq 0xd2e4(%rip), %rdi      # 0x18fd0
callq 0x2030
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2150
jmp 0xbea8
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x7666
leaq 0x8(%rsp), %rsi
movl %r15d, %edi
callq 0xc4f8
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xbd46
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2230
movslq 0xa7863(%rip), %rax     # 0xb35b0
leal 0x1(%rax), %ecx
movl %ecx, 0xa785a(%rip)     # 0xb35b0
shlq $0x5, %rax
leaq 0xa6bcf(%rip), %rdi     # 0xb2930
addq %rax, %rdi
xorl %r15d, %r15d
leaq 0x7d36(%rip), %rsi      # 0x13aa4
callq 0x23d0
jmp 0xbea8
movl %r15d, %edi
callq 0xc2b2
movslq 0xa7829(%rip), %rax     # 0xb35b0
shlq $0x5, %rax
leaq 0xa6b9e(%rip), %rcx     # 0xb2930
leaq (%rcx,%rax), %rdi
movq 0x8(%rax,%rcx), %rdx
leaq 0x7ac5(%rip), %rcx      # 0x13867
movl $0x7, %r8d
xorl %esi, %esi
callq 0x2330
movl 0xc(%rbx), %edi
movl $0x1, %esi
callq 0xc02d
movl %eax, %r15d
movslq 0xa77ea(%rip), %rax     # 0xb35b0
leal 0x1(%rax), %ecx
movl %ecx, 0xa77e1(%rip)     # 0xb35b0
shlq $0x5, %rax
leaq 0xa6b56(%rip), %rdi     # 0xb2930
addq %rax, %rdi
leaq 0x7cc0(%rip), %rsi      # 0x13aa4
callq 0x23d0
movl 0x4(%rsp), %eax
cmpl $0x4, %eax
je 0xbe47
cmpl $0x5, %eax
je 0xbf41
cmpl %eax, %r15d
jle 0xbea8
movl 0xa4(%rbx), %eax
movl %eax, 0xa77a4(%rip)     # 0xb35b4
movq 0xd1b9(%rip), %rdi      # 0x18fd0
leaq 0x7abc(%rip), %rsi      # 0x138da
movl $0x30, %edx
callq 0x2280
movl 0xa7786(%rip), %esi     # 0xb35b4
movq 0xd19b(%rip), %rdi      # 0x18fd0
callq 0x2390
movq %rax, %rdi
callq 0x20f0
jmp 0xbfbf
movq 0xa6a8a(%rip), %r13     # 0xb28d8
movq 0xa6a8b(%rip), %rbp     # 0xb28e0
xorl %eax, %eax
cmpq %rbp, %r13
je 0xbe8f
movq 0x8(%r14), %r12
cmpq %r12, 0x38(%r13)
jne 0xbe7e
testq %r12, %r12
je 0xbe8b
movq (%r14), %rsi
movq 0x30(%r13), %rdi
movq %r12, %rdx
callq 0x2240
testl %eax, %eax
je 0xbe8b
addq $0x60, %r13
cmpq %rbp, %r13
jne 0xbe60
xorl %eax, %eax
jmp 0xbe8f
movl 0x58(%r13), %eax
cmpl %r15d, %eax
leaq 0x98(%rsp), %r13
leaq 0xb8(%rsp), %rbp
jl 0xbf81
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0xbecd
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0xbef2
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0xa8(%rsp), %rdi
cmpq %rbp, %rdi
je 0xbf0f
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0xbf2c
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2230
movl %r15d, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xa4(%rbx), %eax
movl %eax, 0xa7667(%rip)     # 0xb35b4
movq 0xd07c(%rip), %rdi      # 0x18fd0
leaq 0x7949(%rip), %rsi      # 0x138a4
movl $0x35, %edx
callq 0x2280
movl 0xa7649(%rip), %esi     # 0xb35b4
movq 0xd05e(%rip), %rdi      # 0x18fd0
callq 0x2390
movq %rax, %rdi
callq 0x20f0
jmp 0xbfbf
movl 0xa4(%rbx), %eax
movl %eax, 0xa7627(%rip)     # 0xb35b4
movq 0xd03c(%rip), %rdi      # 0x18fd0
leaq 0x78d4(%rip), %rsi      # 0x1386f
movl $0x34, %edx
callq 0x2280
movl 0xa7609(%rip), %esi     # 0xb35b4
movq 0xd01e(%rip), %rdi      # 0x18fd0
callq 0x2390
movq %rax, %rdi
callq 0x20f0
movl $0x1, %edi
callq 0x2290
jmp 0xc00b
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xc00e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2230
jmp 0xc00e
jmp 0xc00b
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0xc025
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2230
jmp 0xc025
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0xf396
leaq 0x28(%rsp), %rdi
callq 0xf396
movq %rbx, %rdi
callq 0x23a0