// File: /workspace/github_cpp_makefile_star2_O3/zhengwangsun[P]pas2c/semantics.cpp
// Function: factor1(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int factor1(int k, string idValue)
{
	TreeNode tNode= tree.node[k];
	TreeNode childNode;
	childNode=tree.node[tNode.child[0]];
    if(lookahead(k) == 102)//102是(
    {
        int flag = 0;
    	code[currentLine].append("(");
        int temp = expression_list(tree.node[k].child[1],3," ");
        code[currentLine].append(")");
        
        for(vector<subTableItem>::iterator it = subTable.begin(); it != subTable.end();it++)
        {
            if (it->name == idValue)
            {
                if (procArgument.size() != it->argument.size())
                {
                    cout<<"argument num wrong where factor1!"<<endl;
                    exit(1);
                }
                else
                {
                    int i = 0;//计数作用
                    for(vector<Tuple>::iterator it1 = it->argument.begin(); it1 != it->argument.end();it1++)
                    {
                        if (it1->type != procArgument[i])
                        {
                            cout<<"the no."<<i+1<<" argument type wrong where factor1!"<<endl;
                            exit(1);
                        }
                        i++;
                    }
                    procArgument.clear();//每用一次procA，就清空一次
                    flag = 1;
                }
            }
            if (flag == 0)
            {
                cout<<"this func/proc is not defined where factor'!"<<endl;
                exit(1);
            }
            
        }
        if (temp != -1)//expr_list里面正确
        {
            return 10;//10代表factor’推出了( expr_list )
        }
        else
        {
            cout<<"( expr_list ) type wrong where factor'!"<<endl;
            return -1;
        }
        return temp;
    }
    else if (lookahead(k) == 110)//110是[
    {
    	code[currentLine].append("[");
        int temp = expression(tree.node[k].child[1],1);
    	code[currentLine].append("]");
        if (temp == 1)
        {
            return 11;//11代表factor’推出了[expression]
        }
        else
        {
            cout<<"[expression] type wrong where factor'!"<<endl;
            return -1;
        }
        return temp;
    }
    else if (lookahead(k) == 106)//106是e
    {
        return 0;
    }
    else
    {
        cout<<"factor' error!"<<endl;
        return -1;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, 0x10(%rsp)
movslq %edi, %rax
imulq $0xa8, %rax, %rax
leaq 0xaad96(%rip), %rbx     # 0xb90c8
leaq (%rbx,%rax), %r14
addq $0x8, %r14
leaq 0x38(%rsp), %rax
movl $0xb, %ecx
movq %rax, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movb 0x58(%r14), %cl
movb %cl, 0x58(%rax)
leaq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x60(%r14), %rsi
movq 0x68(%r14), %rdx
addq %rsi, %rdx
callq 0x7666
leaq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x80(%r14), %rsi
movq 0x88(%r14), %rdx
addq %rsi, %rdx
callq 0x7666
movq 0xa0(%r14), %rax
movq %rax, 0xd8(%rsp)
leaq 0x140(%rsp), %rax
leaq 0x150(%rsp), %rdx
movq %rdx, -0x10(%rdx)
xorl %ecx, %ecx
movq %rcx, -0x8(%rdx)
movb %cl, (%rdx)
leaq 0x170(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq %rcx, -0x8(%rdx)
movb %cl, (%rdx)
movslq 0x3c(%rsp), %rcx
imulq $0xa8, %rcx, %r8
leaq (%rbx,%r8), %r15
addq $0x8, %r15
leaq 0xe0(%rsp), %rdx
movl $0xb, %ecx
movq %rdx, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movb 0x58(%r15), %cl
movb %cl, 0x58(%rdx)
leaq (%rbx,%r8), %rsi
addq $0x68, %rsi
movq %rax, %rdi
callq 0x2110
leaq 0x160(%rsp), %rdi
leaq 0x80(%r15), %rsi
callq 0x2110
movq 0xa0(%r15), %rax
movq %rax, 0x180(%rsp)
cmpl $0x0, (%r14)
jle 0xe64a
movslq 0x4(%r14), %rax
imulq $0xa8, %rax, %rax
movl 0x5c(%rbx,%rax), %eax
cmpl $0x6e, %eax
je 0xe6a1
cmpl $0x6a, %eax
je 0xe69a
cmpl $0x66, %eax
jne 0xe64a
movslq 0xa5131(%rip), %rdi     # 0xb35b0
shlq $0x5, %rdi
leaq 0xa44a6(%rip), %r15     # 0xb2930
addq %r15, %rdi
leaq 0x5ebf(%rip), %rsi      # 0x14353
callq 0x23d0
movl 0x8(%r14), %ebp
leaq 0x28(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x50e4(%rip), %rsi      # 0x13591
leaq 0x50de(%rip), %rdx      # 0x13592
leaq 0x18(%rsp), %rdi
callq 0x76fc
movl %ebp, %edi
movl $0x3, %esi
callq 0xc19b
movl %eax, %ebx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0xe4e3
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
movslq 0xa50c6(%rip), %rax     # 0xb35b0
shlq $0x5, %rax
addq %rax, %r15
leaq 0x6021(%rip), %rsi      # 0x14519
movq %r15, %rdi
callq 0x23d0
movl %ebx, 0xc(%rsp)
movq 0xa43cd(%rip), %rbp     # 0xb28d8
movq 0xa43ce(%rip), %r12     # 0xb28e0
cmpq %r12, %rbp
je 0xe5da
movq 0xa43d6(%rip), %rbx     # 0xb28f8
movq 0x10(%rsp), %rax
movq 0x8(%rax), %r14
movb $0x1, %r15b
movq 0xa43bb(%rip), %r13     # 0xb28f0
cmpq %r14, 0x38(%rbp)
jne 0xe558
testq %r14, %r14
je 0xe563
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x30(%rbp), %rdi
movq %r14, %rdx
callq 0x2240
testl %eax, %eax
je 0xe563
testb $0x1, %r15b
je 0xe5ca
jmp 0xe827
movq %rbx, %rdx
subq %r13, %rdx
sarq $0x2, %rdx
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %rcx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x4, %rsi
movabsq $-0x3333333333333333, %rdi # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdi, %rsi
cmpq %rsi, %rdx
jne 0xe84d
cmpq %rcx, %rax
je 0xe5b8
xorl %r15d, %r15d
movl 0x20(%rax), %edx
cmpl (%r13,%r15,4), %edx
jne 0xe7dc
incq %r15
addq $0x50, %rax
cmpq %rcx, %rax
jne 0xe59e
cmpq %r13, %rbx
movq %r13, %rbx
je 0xe5ca
movq %r13, 0xa4331(%rip)     # 0xb28f8
movq %r13, %rbx
addq $0x60, %rbp
xorl %r15d, %r15d
cmpq %r12, %rbp
jne 0xe535
movl $0xa, %ebx
cmpl $-0x1, 0xc(%rsp)
leaq 0xa8(%rsp), %r12
leaq 0xc8(%rsp), %r13
jne 0xe744
movq 0xa9cf(%rip), %rbx      # 0x18fd0
leaq 0x5619(%rip), %rsi      # 0x13c21
movl $0x27, %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 0xa99d(%rip), %rdi      # 0x18fd0
callq 0x2030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2150
jmp 0xe744
movq 0xa97f(%rip), %rbx      # 0x18fd0
leaq 0x5618(%rip), %rsi      # 0x13c70
movl $0xe, %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 0xa94d(%rip), %rdi      # 0x18fd0
callq 0x2030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2150
jmp 0xe744
xorl %ebx, %ebx
jmp 0xe744
movslq 0xa4f08(%rip), %rdi     # 0xb35b0
shlq $0x5, %rdi
leaq 0xa427d(%rip), %rbx     # 0xb2930
addq %rbx, %rdi
leaq 0x4bb3(%rip), %rsi      # 0x13270
callq 0x23d0
movl 0x8(%r14), %edi
movl $0x1, %esi
callq 0xc02d
movl %eax, %ebp
movslq 0xa4ed7(%rip), %rax     # 0xb35b0
shlq $0x5, %rax
addq %rax, %rbx
leaq 0x4b8b(%rip), %rsi      # 0x13272
movq %rbx, %rdi
callq 0x23d0
movl $0xb, %ebx
cmpl $0x1, %ebp
je 0xe744
movq 0xa8d0(%rip), %rbx      # 0x18fd0
leaq 0x5542(%rip), %rsi      # 0x13c49
movl $0x26, %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 0xa89e(%rip), %rdi      # 0x18fd0
callq 0x2030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2150
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0xe769
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xe78e
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0xe7ab
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0xe7c8
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2230
movl %ebx, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa7ed(%rip), %rdi      # 0x18fd0
leaq 0x53de(%rip), %rsi      # 0x13bc8
movl $0x7, %edx
callq 0x2280
incl %r15d
movq 0xa7d2(%rip), %rdi      # 0x18fd0
movl %r15d, %esi
callq 0x2390
movq %rax, %rbx
leaq 0x53c0(%rip), %rsi      # 0x13bd0
movl $0x23, %edx
movq %rax, %rdi
callq 0x2280
movq %rbx, %rdi
callq 0x20f0
jmp 0xe871
movq 0xa7a2(%rip), %rdi      # 0x18fd0
leaq 0x53bf(%rip), %rsi      # 0x13bf4
movl $0x2c, %edx
callq 0x2280
movq 0xa78a(%rip), %rdi      # 0x18fd0
callq 0x20f0
jmp 0xe871
movq 0xa77c(%rip), %rdi      # 0x18fd0
leaq 0x534b(%rip), %rsi      # 0x13ba6
movl $0x21, %edx
callq 0x2280
movq 0xa764(%rip), %rdi      # 0x18fd0
callq 0x20f0
movl $0x1, %edi
callq 0x2290
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0xe8c8
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
jmp 0xe8c8
jmp 0xe8c5
jmp 0xe8c5
jmp 0xe8c5
jmp 0xe8c5
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0xe8df
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2230
jmp 0xe8df
jmp 0xe8c5
jmp 0xe8c5
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0xf396
leaq 0x38(%rsp), %rdi
callq 0xf396
movq %rbx, %rdi
callq 0x23a0