// File: /workspace/github_cpp_makefile_star2_O1/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, %ebp
movslq %edi, %rax
imulq $0xa8, %rax, %rax
leaq 0xae2fe(%rip), %r15     # 0xba0c8
leaq (%r15,%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 0x768e
leaq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x80(%rbx), %rsi
movq 0x88(%rbx), %rdx
addq %rsi, %rdx
callq 0x768e
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)
movl (%rbx), %eax
testl %eax, %eax
jle 0xbf77
movslq 0x4(%rbx), %rcx
imulq $0xa8, %rcx, %rcx
cmpl $0x18, 0x5c(%r15,%rcx)
jne 0xbee7
movq 0x8(%r14), %rdx
cmpq 0xa7a79(%rip), %rdx     # 0xb3910
jne 0xbeb9
testq %rdx, %rdx
je 0xbfc8
movq 0xa7a5f(%rip), %rsi     # 0xb3908
movq (%r14), %rdi
callq 0x2240
testl %eax, %eax
je 0xbfc8
movl 0x4(%rbx), %edi
callq 0xc508
movslq 0xa86e8(%rip), %rax     # 0xb45b0
shlq $0x5, %rax
leaq 0xa7a5d(%rip), %rdi     # 0xb3930
addq %rax, %rdi
leaq 0x839a(%rip), %rsi      # 0x14277
callq 0x23d0
jmp 0xbfff
testl %eax, %eax
jle 0xbf77
movslq 0x4(%rbx), %rax
imulq $0xa8, %rax, %rax
cmpl $0x1a, 0x5c(%r15,%rax)
jne 0xbf77
movl 0x4(%rbx), %ebx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x768e
leaq 0x8(%rsp), %rsi
movl %ebx, %edi
callq 0xc761
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0xbf45
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2230
movslq 0xa8664(%rip), %rax     # 0xb45b0
leal 0x1(%rax), %ecx
movl %ecx, 0xa865b(%rip)     # 0xb45b0
shlq $0x5, %rax
leaq 0xa79d0(%rip), %rdi     # 0xb3930
addq %rax, %rdi
xorl %r15d, %r15d
leaq 0x8b07(%rip), %rsi      # 0x14a74
callq 0x23d0
jmp 0xc0fb
movq 0xe052(%rip), %rbx      # 0x19fd0
leaq 0x8956(%rip), %rsi      # 0x148db
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 0xe020(%rip), %rdi      # 0x19fd0
callq 0x2030
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2150
jmp 0xc0fb
movl 0x4(%rbx), %edi
callq 0xc508
movslq 0xa85d9(%rip), %rax     # 0xb45b0
shlq $0x5, %rax
leaq 0xa794e(%rip), %rcx     # 0xb3930
leaq (%rcx,%rax), %rdi
movq 0x8(%rax,%rcx), %rdx
leaq 0x8845(%rip), %rcx      # 0x14837
movl $0x7, %r8d
xorl %esi, %esi
callq 0x2330
movl 0xc(%rbx), %edi
movl $0x1, %esi
callq 0xc280
movl %eax, %r15d
movslq 0xa859a(%rip), %rax     # 0xb45b0
leal 0x1(%rax), %ecx
movl %ecx, 0xa8591(%rip)     # 0xb45b0
shlq $0x5, %rax
leaq 0xa7906(%rip), %rdi     # 0xb3930
addq %rax, %rdi
leaq 0x8a40(%rip), %rsi      # 0x14a74
callq 0x23d0
cmpl $0x4, %ebp
je 0xc093
cmpl $0x5, %ebp
je 0xc194
cmpl %ebp, %r15d
jle 0xc0fb
movl 0xa4(%rbx), %eax
movl %eax, 0xa8558(%rip)     # 0xb45b4
movq 0xdf6d(%rip), %rdi      # 0x19fd0
leaq 0x8840(%rip), %rsi      # 0x148aa
movl $0x30, %edx
callq 0x2280
movl 0xa853a(%rip), %esi     # 0xb45b4
movq 0xdf4f(%rip), %rdi      # 0x19fd0
callq 0x2390
movq %rax, %rdi
callq 0x20f0
jmp 0xc212
movq 0xa783e(%rip), %rbp     # 0xb38d8
movq 0xa783f(%rip), %r12     # 0xb38e0
xorl %eax, %eax
cmpq %r12, %rbp
je 0xc0ea
movq 0x8(%r14), %r13
movq 0x38(%rbp), %rdx
cmpq %r13, %rdx
jne 0xc0ca
testq %rdx, %rdx
je 0xc0df
movq (%r14), %rsi
movq 0x30(%rbp), %rdi
callq 0x2240
testl %eax, %eax
je 0xc0df
addq $0x60, %rbp
cmpq %r12, %rbp
jne 0xc0ac
leaq 0x98(%rsp), %r13
xorl %eax, %eax
jmp 0xc0ea
movl 0x58(%rbp), %eax
leaq 0x98(%rsp), %r13
cmpl %r15d, %eax
leaq 0xb8(%rsp), %r12
jl 0xc1d4
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0xc120
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0xc145
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0xa8(%rsp), %rdi
cmpq %r12, %rdi
je 0xc162
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0xc17f
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, 0xa8414(%rip)     # 0xb45b4
movq 0xde29(%rip), %rdi      # 0x19fd0
leaq 0x86c6(%rip), %rsi      # 0x14874
movl $0x35, %edx
callq 0x2280
movl 0xa83f6(%rip), %esi     # 0xb45b4
movq 0xde0b(%rip), %rdi      # 0x19fd0
callq 0x2390
movq %rax, %rdi
callq 0x20f0
jmp 0xc212
movl 0xa4(%rbx), %eax
movl %eax, 0xa83d4(%rip)     # 0xb45b4
movq 0xdde9(%rip), %rdi      # 0x19fd0
leaq 0x8651(%rip), %rsi      # 0x1483f
movl $0x34, %edx
callq 0x2280
movl 0xa83b6(%rip), %esi     # 0xb45b4
movq 0xddcb(%rip), %rdi      # 0x19fd0
callq 0x2390
movq %rax, %rdi
callq 0x20f0
movl $0x1, %edi
callq 0x2290
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0xc261
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2230
jmp 0xc261
jmp 0xc25e
jmp 0xc25e
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0xc278
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2230
jmp 0xc278
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0xf7a8
leaq 0x28(%rsp), %rdi
callq 0xf7a8
movq %rbx, %rdi
callq 0x23a0