// File: /workspace/github_cpp_makefile_star2_O1/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 0xaba90(%rip), %rbp     # 0xba0c8
leaq (%rax,%rbp), %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 0x768e
leaq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x80(%r14), %rsi
movq 0x88(%r14), %rdx
addq %rsi, %rdx
callq 0x768e
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 (%r8,%rbp), %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 (%r8,%rbp), %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)
movl (%r14), %eax
testl %eax, %eax
jle 0xea24
movslq 0x4(%r14), %rcx
imulq $0xa8, %rcx, %rcx
cmpl $0x66, 0x5c(%rbp,%rcx)
jne 0xe945
movslq 0xa5e3e(%rip), %rdi     # 0xb45b0
shlq $0x5, %rdi
leaq 0xa51b3(%rip), %r15     # 0xb3930
addq %r15, %rdi
leaq 0x6bac(%rip), %rsi      # 0x15333
callq 0x23d0
movl 0x8(%r14), %ebp
leaq 0x28(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x5dc1(%rip), %rsi      # 0x14561
leaq 0x5dbb(%rip), %rdx      # 0x14562
leaq 0x18(%rsp), %rdi
callq 0x771e
movl %ebp, %edi
movl $0x3, %esi
callq 0xc3f7
movl %eax, %ebx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0xe7d6
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
movslq 0xa5dd3(%rip), %rax     # 0xb45b0
shlq $0x5, %rax
addq %rax, %r15
leaq 0x6d0e(%rip), %rsi      # 0x154f9
movq %r15, %rdi
callq 0x23d0
movl %ebx, 0xc(%rsp)
movq 0xa50da(%rip), %r15     # 0xb38d8
movq 0xa50db(%rip), %rbp     # 0xb38e0
cmpq %rbp, %r15
je 0xe8d5
movq 0xa50e3(%rip), %rbx     # 0xb38f8
movq 0x10(%rsp), %rax
movq 0x8(%rax), %r12
xorl %r14d, %r14d
movq 0xa50c8(%rip), %r13     # 0xb38f0
movq 0x38(%r15), %rdx
cmpq %r12, %rdx
jne 0xe8b9
testq %rdx, %rdx
je 0xe84f
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x30(%r15), %rdi
callq 0x2240
testl %eax, %eax
jne 0xe8b9
movq %rbx, %rdx
subq %r13, %rdx
sarq $0x2, %rdx
movq 0x18(%r15), %rax
movq 0x20(%r15), %rcx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x4, %rsi
movabsq $-0x3333333333333333, %rdi # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdi, %rsi
cmpq %rsi, %rdx
jne 0xeb78
cmpq %rcx, %rax
je 0xe8a4
xorl %r14d, %r14d
movl 0x20(%rax), %edx
cmpl (%r13,%r14,4), %edx
jne 0xeb07
incq %r14
addq $0x50, %rax
cmpq %rcx, %rax
jne 0xe88a
movl $0x1, %r14d
cmpq %r13, %rbx
je 0xe8b9
movq %r13, 0xa5042(%rip)     # 0xb38f8
movq %r13, %rbx
testl %r14d, %r14d
je 0xeb52
addq $0x60, %r15
movl $0x1, %r14d
cmpq %rbp, %r15
jne 0xe828
movl $0xa, %ebx
cmpl $-0x1, 0xc(%rsp)
leaq 0xa8(%rsp), %r12
leaq 0xc8(%rsp), %r13
jne 0xea6f
movq 0xb6d4(%rip), %rbx      # 0x19fd0
leaq 0x62ee(%rip), %rsi      # 0x14bf1
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 0xb6a2(%rip), %rdi      # 0x19fd0
callq 0x2030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2150
jmp 0xea6f
testl %eax, %eax
jle 0xea24
movslq 0x4(%r14), %rcx
imulq $0xa8, %rcx, %rcx
cmpl $0x6e, 0x5c(%rbp,%rcx)
jne 0xea0c
movslq 0xa5c46(%rip), %rdi     # 0xb45b0
shlq $0x5, %rdi
leaq 0xa4fbb(%rip), %rbx     # 0xb3930
addq %rbx, %rdi
leaq 0x58f1(%rip), %rsi      # 0x14270
callq 0x23d0
movl 0x8(%r14), %edi
movl $0x1, %esi
callq 0xc280
movl %eax, %ebp
movslq 0xa5c15(%rip), %rax     # 0xb45b0
shlq $0x5, %rax
addq %rax, %rbx
leaq 0x58c9(%rip), %rsi      # 0x14272
movq %rbx, %rdi
callq 0x23d0
movl $0xb, %ebx
cmpl $0x1, %ebp
je 0xea6f
movq 0xb60a(%rip), %rbx      # 0x19fd0
leaq 0x624c(%rip), %rsi      # 0x14c19
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 0xb5d8(%rip), %rdi      # 0x19fd0
callq 0x2030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2150
jmp 0xea6f
testl %eax, %eax
jle 0xea24
movslq 0x4(%r14), %rax
imulq $0xa8, %rax, %rax
xorl %ebx, %ebx
cmpl $0x6a, 0x5c(%rbp,%rax)
je 0xea6f
movq 0xb5a5(%rip), %rbx      # 0x19fd0
leaq 0x620e(%rip), %rsi      # 0x14c40
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 0xb573(%rip), %rdi      # 0x19fd0
callq 0x2030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2150
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0xea94
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xeab9
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0xead6
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0xeaf3
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 0xb4c2(%rip), %rdi      # 0x19fd0
leaq 0x6083(%rip), %rsi      # 0x14b98
movl $0x7, %edx
callq 0x2280
incl %r14d
movq 0xb4a7(%rip), %rdi      # 0x19fd0
movl %r14d, %esi
callq 0x2390
movq %rax, %rbx
leaq 0x6065(%rip), %rsi      # 0x14ba0
movl $0x23, %edx
movq %rax, %rdi
callq 0x2280
movq %rbx, %rdi
callq 0x20f0
jmp 0xeb9c
movq 0xb477(%rip), %rdi      # 0x19fd0
leaq 0x6064(%rip), %rsi      # 0x14bc4
movl $0x2c, %edx
callq 0x2280
movq 0xb45f(%rip), %rdi      # 0x19fd0
callq 0x20f0
jmp 0xeb9c
movq 0xb451(%rip), %rdi      # 0x19fd0
leaq 0x5ff0(%rip), %rsi      # 0x14b76
movl $0x21, %edx
callq 0x2280
movq 0xb439(%rip), %rdi      # 0x19fd0
callq 0x20f0
movl $0x1, %edi
callq 0x2290
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0xebf3
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
jmp 0xebf3
jmp 0xebf0
jmp 0xebf0
jmp 0xebf0
jmp 0xebf0
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0xec0a
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2230
jmp 0xec0a
jmp 0xebf0
jmp 0xebf0
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0xf7a8
leaq 0x38(%rsp), %rdi
callq 0xf7a8
movq %rbx, %rdi
callq 0x23a0