// File: zhengwangsun[P]pas2c/grammar.cpp
// Function: GetFollowGroup(int, bool*)
void GetFollowGroup(int X,bool Follow[])// X 为非终结符的值
{
	//对文法的开始符号S,置$于FOLLW(S)中
	//若A->aBβ是产生式,则求FIRST( β)
	//若ε∈FIRST( β)，则把FIRST( β)中的非ε元素和FOLLOW(A)中的所有元素加入到FOLLOW(B)中
	//若ε不属于FIRST( β)，则把FIRST( β)中的所有元素加入到FOLLOW(B)中
	int i,j,k,m,n;
	int A;
	if(X==0)                 //文法开始符号置 $ 于其FOLLOW集中 
	{
		g[X].FOLLOW[0]=$;
		Follow[X]=true;
	}
	else
	{
		for(i=0;i<GenerationNum;i++)
		{
			for(j=0;g[i].right[j]!=-1;j++)
			{
				if(g[i].right[j]==X)       //找到一个形如 A->aXβ的生成式 
				{
					GetFirst(i,j);         //求FIRST( β)
					for(k=0;First[k]!=-1&&First[k]!=106&&k<FIRSTnum;k++)
						;
					if(First[k]==-1)       // ε不属于FIRST( β)
					{
						//将FIRST( β)中的所有元素无重复的加入到FOLLOW(X)中 
						for(k=0;k<GenerationNum;k++)
						{
							if(g[k].left==X)
							{
								for(m=0;First[m]!=-1;m++)
								{
									for(n=0;g[k].FOLLOW[n]!=-1&&g[k].FOLLOW[n]!=First[m]&&n<FOLLOWnum;n++)
										;
									if(g[k].FOLLOW[n]==-1)
										g[k].FOLLOW[n]=First[m];
								}
							}
						}
					}
					else                   // ε属于FIRST( β)
					{
						//将FIRST( β)中的所有非 ε元素无重复的加入到FOLLOW(X)中
						for(k=0;k<GenerationNum;k++)
						{
							if(g[k].left==X)
							{
								for(m=0;First[m]!=-1;m++)
								{
									if(First[m]!=106)
									{
										for(n=0;g[k].FOLLOW[n]!=-1&&g[k].FOLLOW[n]!=First[m]&&n<FOLLOWnum;n++)
											;
										if(g[k].FOLLOW[n]==-1)
											g[k].FOLLOW[n]=First[m];
									}
								}
							}
						}
						//判断 A 的FOLLOW集是否已求 
						A=g[i].left;
						if(A!=X)
						{
							if(Follow[A]==false)
							{
								GetFollowGroup(A,Follow);
								Follow[A]=true;
							}
							else// A 的FOLLOW集已求 
							{
								//将FOLLOW(A)中的所有元素无重复的加入到FOLLOW(X)中
								for(k=0;k<GenerationNum;k++)
								{
									if(g[k].left==X)
									{
										for(m=0;g[i].FOLLOW[m]!=-1;m++)
										{
											int flag=1;
											for(n=0;n<FOLLOWnum;n++)
											{
												if(g[k].FOLLOW[n]==g[i].FOLLOW[m])
													flag=0;
											}
											if(flag==1)
											{
												for(n=0;n<FOLLOWnum&&g[k].FOLLOW[n]!=-1;n++)
													;
												g[k].FOLLOW[n]=g[i].FOLLOW[m];
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x1b435
movslq -0x4(%rbp), %rcx
leaq 0xa5530(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movl $0x8d, 0x80(%rax)
movq -0x10(%rbp), %rax
movslq -0x4(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0x1b9b8
movl $0x0, -0x14(%rbp)
cmpl $0x4c, -0x14(%rbp)
jge 0x1b9b6
movl $0x0, -0x18(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0xa54e8(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
cmpl $-0x1, 0x8(%rax,%rcx,4)
je 0x1b9a6
movslq -0x14(%rbp), %rcx
leaq 0xa54c4(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
movl 0x8(%rax,%rcx,4), %eax
cmpl -0x4(%rbp), %eax
jne 0x1b996
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x1b000
movl $0x0, -0x1c(%rbp)
movslq -0x1c(%rbp), %rdx
xorl %eax, %eax
leaq 0xa924a(%rip), %rcx     # 0xc4700
cmpl $-0x1, (%rcx,%rdx,4)
movb %al, -0x2d(%rbp)
je 0x1b4df
movslq -0x1c(%rbp), %rdx
xorl %eax, %eax
leaq 0xa9234(%rip), %rcx     # 0xc4700
cmpl $0x6a, (%rcx,%rdx,4)
movb %al, -0x2d(%rbp)
je 0x1b4df
cmpl $0x14, -0x1c(%rbp)
setl %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
testb $0x1, %al
jne 0x1b4e8
jmp 0x1b4f5
jmp 0x1b4ea
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1b4a9
movslq -0x1c(%rbp), %rcx
leaq 0xa9200(%rip), %rax     # 0xc4700
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1b654
movl $0x0, -0x1c(%rbp)
cmpl $0x4c, -0x1c(%rbp)
jge 0x1b64f
movslq -0x1c(%rbp), %rcx
leaq 0xa541a(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpl -0x4(%rbp), %eax
jne 0x1b63f
movl $0x0, -0x20(%rbp)
movslq -0x20(%rbp), %rcx
leaq 0xa91b2(%rip), %rax     # 0xc4700
cmpl $-0x1, (%rax,%rcx,4)
je 0x1b63d
movl $0x0, -0x24(%rbp)
movslq -0x1c(%rbp), %rax
leaq 0xa53d6(%rip), %rcx     # 0xc0940
imulq $0xd0, %rax, %rax
addq %rax, %rcx
movslq -0x24(%rbp), %rdx
xorl %eax, %eax
cmpl $-0x1, 0x80(%rcx,%rdx,4)
movb %al, -0x2e(%rbp)
je 0x1b5c6
movslq -0x1c(%rbp), %rcx
leaq 0xa53ae(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl 0x80(%rax,%rcx,4), %ecx
movslq -0x20(%rbp), %rsi
xorl %eax, %eax
leaq 0xa914c(%rip), %rdx     # 0xc4700
cmpl (%rdx,%rsi,4), %ecx
movb %al, -0x2e(%rbp)
je 0x1b5c6
cmpl $0x14, -0x24(%rbp)
setl %al
movb %al, -0x2e(%rbp)
movb -0x2e(%rbp), %al
testb $0x1, %al
jne 0x1b5cf
jmp 0x1b5dc
jmp 0x1b5d1
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1b55f
movslq -0x1c(%rbp), %rcx
leaq 0xa5359(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
cmpl $-0x1, 0x80(%rax,%rcx,4)
jne 0x1b62d
movslq -0x20(%rbp), %rcx
leaq 0xa90f6(%rip), %rax     # 0xc4700
movl (%rax,%rcx,4), %edx
movslq -0x1c(%rbp), %rcx
leaq 0xa5328(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl %edx, 0x80(%rax,%rcx,4)
jmp 0x1b62f
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1b543
jmp 0x1b63f
jmp 0x1b641
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1b511
jmp 0x1b994
movl $0x0, -0x1c(%rbp)
cmpl $0x4c, -0x1c(%rbp)
jge 0x1b7b0
movslq -0x1c(%rbp), %rcx
leaq 0xa52d0(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpl -0x4(%rbp), %eax
jne 0x1b7a0
movl $0x0, -0x20(%rbp)
movslq -0x20(%rbp), %rcx
leaq 0xa9068(%rip), %rax     # 0xc4700
cmpl $-0x1, (%rax,%rcx,4)
je 0x1b79e
movslq -0x20(%rbp), %rcx
leaq 0xa9053(%rip), %rax     # 0xc4700
cmpl $0x6a, (%rax,%rcx,4)
je 0x1b78e
movl $0x0, -0x24(%rbp)
movslq -0x1c(%rbp), %rax
leaq 0xa5277(%rip), %rcx     # 0xc0940
imulq $0xd0, %rax, %rax
addq %rax, %rcx
movslq -0x24(%rbp), %rdx
xorl %eax, %eax
cmpl $-0x1, 0x80(%rcx,%rdx,4)
movb %al, -0x2f(%rbp)
je 0x1b725
movslq -0x1c(%rbp), %rcx
leaq 0xa524f(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl 0x80(%rax,%rcx,4), %ecx
movslq -0x20(%rbp), %rsi
xorl %eax, %eax
leaq 0xa8fed(%rip), %rdx     # 0xc4700
cmpl (%rdx,%rsi,4), %ecx
movb %al, -0x2f(%rbp)
je 0x1b725
cmpl $0x14, -0x24(%rbp)
setl %al
movb %al, -0x2f(%rbp)
movb -0x2f(%rbp), %al
testb $0x1, %al
jne 0x1b72e
jmp 0x1b73b
jmp 0x1b730
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1b6be
movslq -0x1c(%rbp), %rcx
leaq 0xa51fa(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
cmpl $-0x1, 0x80(%rax,%rcx,4)
jne 0x1b78c
movslq -0x20(%rbp), %rcx
leaq 0xa8f97(%rip), %rax     # 0xc4700
movl (%rax,%rcx,4), %edx
movslq -0x1c(%rbp), %rcx
leaq 0xa51c9(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl %edx, 0x80(%rax,%rcx,4)
jmp 0x1b78e
jmp 0x1b790
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1b68d
jmp 0x1b7a0
jmp 0x1b7a2
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1b65b
movslq -0x14(%rbp), %rcx
leaq 0xa5185(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x4(%rbp), %eax
je 0x1b992
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb (%rax,%rcx), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1b809
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x1b3f0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0x1b990
movl $0x0, -0x1c(%rbp)
cmpl $0x4c, -0x1c(%rbp)
jge 0x1b98e
movslq -0x1c(%rbp), %rcx
leaq 0xa511b(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpl -0x4(%rbp), %eax
jne 0x1b97e
movl $0x0, -0x20(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0xa50f3(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
cmpl $-0x1, 0x80(%rax,%rcx,4)
je 0x1b97c
movl $0x1, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x14, -0x24(%rbp)
jge 0x1b8d3
movslq -0x1c(%rbp), %rcx
leaq 0xa50b8(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl 0x80(%rax,%rcx,4), %eax
movslq -0x14(%rbp), %rdx
leaq 0xa5098(%rip), %rcx     # 0xc0940
imulq $0xd0, %rdx, %rdx
addq %rdx, %rcx
movslq -0x20(%rbp), %rdx
cmpl 0x80(%rcx,%rdx,4), %eax
jne 0x1b8c6
movl $0x0, -0x2c(%rbp)
jmp 0x1b8c8
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1b877
cmpl $0x1, -0x2c(%rbp)
jne 0x1b96c
movl $0x0, -0x24(%rbp)
xorl %eax, %eax
cmpl $0x14, -0x24(%rbp)
movb %al, -0x30(%rbp)
jge 0x1b916
movslq -0x1c(%rbp), %rcx
leaq 0xa5046(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
cmpl $-0x1, 0x80(%rax,%rcx,4)
setne %al
movb %al, -0x30(%rbp)
movb -0x30(%rbp), %al
testb $0x1, %al
jne 0x1b91f
jmp 0x1b92c
jmp 0x1b921
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1b8e4
movslq -0x14(%rbp), %rcx
leaq 0xa5009(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movl 0x80(%rax,%rcx,4), %edx
movslq -0x1c(%rbp), %rcx
leaq 0xa4fe9(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl %edx, 0x80(%rax,%rcx,4)
jmp 0x1b96e
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1b842
jmp 0x1b97e
jmp 0x1b980
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1b810
jmp 0x1b990
jmp 0x1b992
jmp 0x1b994
jmp 0x1b996
jmp 0x1b998
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1b44d
jmp 0x1b9a8
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1b43c
jmp 0x1b9b8
addq $0x30, %rsp
popq %rbp
retq
nop