// File: /workspace/github_cpp_makefile_star2_O2/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 $0x178, %rsp            # imm = 0x178
movq %rsi, %rbx
movl %edi, %r14d
movslq %edi, %rax
imulq $0xa8, %rax, %rax
leaq 0xaa459(%rip), %r13     # 0xb4098
leaq (%rax,%r13), %r15
addq $0x8, %r15
leaq 0xd0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xa562
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ebp, %ebp
movb %bpl, (%rax)
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %bpl, (%rax)
movslq 0x4(%r12), %rax
imulq $0xa8, %rax, %rax
leaq (%rax,%r13), %rsi
addq $0x8, %rsi
leaq 0x28(%rsp), %rdi
callq 0xa5ba
movl %r14d, %edi
callq 0x603d
leaq 0xa3c4f(%rip), %r14     # 0xad900
cmpl $0x6e, %eax
je 0x9dd3
cmpl $0x6a, %eax
je 0x9e82
cmpl $0x66, %eax
jne 0x9e21
movslq 0xa48ad(%rip), %rdi     # 0xae580
shlq $0x5, %rdi
addq %r14, %rdi
leaq 0x56b5(%rip), %rsi      # 0xf396
callq 0x2350
movl 0x8(%r15), %ebp
leaq 0x48d0(%rip), %rsi      # 0xe5c1
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x4268
pushq $0x3
popq %rsi
movl %ebp, %edi
callq 0x8a61
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x2388
movslq 0xa4863(%rip), %rax     # 0xae580
shlq $0x5, %rax
addq %rax, %r14
leaq 0x5831(%rip), %rsi      # 0xf55c
movq %r14, %rdi
callq 0x2350
movb $0x1, %r14b
movq 0xa3b6b(%rip), %r15     # 0xad8a8
pushq $0x50
popq %r12
cmpq 0xa3b68(%rip), %r15     # 0xad8b0
je 0x9e3e
leaq 0x30(%r15), %rdi
movq %rbx, %rsi
callq 0x5f9f
testb %al, %al
je 0x9db0
movq 0xa3b63(%rip), %rsi     # 0xad8c8
movq 0xa3b54(%rip), %rcx     # 0xad8c0
movq %rsi, %r9
subq %rcx, %r9
sarq $0x2, %r9
movq 0x18(%r15), %rdi
movq 0x20(%r15), %r8
movq %r8, %rax
subq %rdi, %rax
cqto
idivq %r12
cmpq %rax, %r9
jne 0x9f0a
xorl %r14d, %r14d
cmpq %r8, %rdi
je 0x9dbb
movl 0x20(%rdi), %eax
cmpl (%rcx,%r14,4), %eax
jne 0x9ead
incq %r14
addq $0x50, %rdi
jmp 0x9d95
testb $0x1, %r14b
je 0x9dc7
jmp 0x9eed
cmpq %rcx, %rsi
je 0x9dc7
movq %rcx, 0xa3b01(%rip)     # 0xad8c8
addq $0x60, %r15
xorl %r14d, %r14d
jmp 0x9d41
movslq 0xa47a6(%rip), %rdi     # 0xae580
shlq $0x5, %rdi
addq %r14, %rdi
leaq 0x44e0(%rip), %rsi      # 0xe2c8
callq 0x2350
movl 0x8(%r15), %edi
pushq $0x1
popq %rsi
callq 0x8946
movl %eax, %ebx
movslq 0xa477e(%rip), %rax     # 0xae580
shlq $0x5, %rax
addq %rax, %r14
leaq 0x44ba(%rip), %rsi      # 0xe2ca
movq %r14, %rdi
callq 0x2350
cmpl $0x1, %ebx
jne 0x9e47
pushq $0xb
jmp 0x9e81
movq 0xa1a8(%rip), %rdi      # 0x13fd0
leaq 0x4e71(%rip), %rsi      # 0xeca0
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
jmp 0x9e7f
cmpl $-0x1, %ebp
je 0x9e64
pushq $0xa
jmp 0x9e81
movq 0xa182(%rip), %rdi      # 0x13fd0
leaq 0x4e24(%rip), %rsi      # 0xec79
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
jmp 0x9e7f
movq 0xa165(%rip), %rdi      # 0x13fd0
leaq 0x4ddf(%rip), %rsi      # 0xec51
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
pushq $-0x1
popq %rbp
leaq 0x28(%rsp), %rdi
callq 0xa600
leaq 0xd0(%rsp), %rdi
callq 0xa600
movl %ebp, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa11c(%rip), %rdi      # 0x13fd0
leaq 0x4d3d(%rip), %rsi      # 0xebf8
callq 0x21d0
incl %r14d
movq %rax, %rdi
movl %r14d, %esi
callq 0x2320
leaq 0x4d2b(%rip), %rsi      # 0xec00
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
pushq $0x1
popq %rdi
callq 0x2220
movq 0xa0dc(%rip), %rdi      # 0x13fd0
leaq 0x4d29(%rip), %rsi      # 0xec24
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
jmp 0x9ee5
movq 0xa0bf(%rip), %rdi      # 0x13fd0
leaq 0x4cbe(%rip), %rsi      # 0xebd6
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
jmp 0x9ee5
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2388
jmp 0x9f45
jmp 0x9f42
jmp 0x9f42
jmp 0x9f42
jmp 0x9f42
jmp 0x9f42
jmp 0x9f42
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xa600
leaq 0xd0(%rsp), %rdi
callq 0xa600
movq %rbx, %rdi
callq 0x2330