// File: zhengwangsun[P]pas2c/grammar.cpp
// Function: GetFirst(int, int)
void GetFirst(int num,int start)       //求编号为num的生成式右部第start位置起之后字符串的FIRST集,并将结果存入数组First中
{
	int i,j,k,m,flag;
	for(i=0;i<FIRSTnum;i++)
		First[i]=-1;
	if(g[num].right[start+1]==-1)      //start之后字符串为空
		First[0]=106;                  //将 ε加入到First中
	else
	{
		i=start+1;
		flag=1;
		while(flag==1&&g[num].right[i]!=-1)
		{
			if(g[num].right[i]>=100)   //是终结符 
			{
				flag=0;
				for(j=0;First[j]!=-1&&First[j]!=g[num].right[i]&&j<FIRSTnum;j++)
					;
				if(First[j]==-1)       //无重复的将此终结符加入到First中
					First[j]=g[num].right[i];
			}
			else                       //是非终结符 
			{                          //求 g[num].right[i]的FIRST集	
				for(j=0;j<GenerationNum;j++)
				{
					if(g[j].left==g[num].right[i])
					{
						for(k=0;g[j].FIRST[k]!=-1;k++)
						{              //无重复的将此非终结符的FIRST集元素加入到First中 
							for(m=0;First[m]!=-1&&First[m]!=g[j].FIRST[k]&&m<FIRSTnum;m++)
								;
							if(First[m]==-1)
								First[m]=g[j].FIRST[k];
						}
					}
				}
				for(j=0;First[j]!=-1&&First[j]!=106&&j<FIRSTnum;j++)
					;
				if(First[j]==-1)       //非终结符g[num].right[i]的FIRST集不含ε
					flag=0;
				else                   //非终结符g[num].right[i]的FIRST集含有ε
				{   
					if(g[num].right[i+1]==-1)//非终结符g[num].right[i]是最后一个元素
						flag=0;
					else               //非终结符g[num].right[i]不是最后一个元素
					{                  //将 ε从First中删除
						for(j=0;First[j]!=106;j++)
							;
						for(k=j;First[k]!=-1;k++)
							First[k]=First[k+1];
						
						i++;           //继续处理下一个元素 
					}	
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x14, -0xc(%rbp)
jge 0x1b034
movslq -0xc(%rbp), %rcx
leaq 0xa96de(%rip), %rax     # 0xc4700
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1b011
movslq -0x4(%rbp), %rcx
leaq 0xa5901(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movl -0x8(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpl $-0x1, 0x8(%rax,%rcx,4)
jne 0x1b068
movl $0x6a, 0xa969d(%rip)    # 0xc4700
jmp 0x1b3ec
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl $0x1, -0x1c(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x1c(%rbp)
movb %al, -0x1d(%rbp)
jne 0x1b0a7
movslq -0x4(%rbp), %rcx
leaq 0xa58b2(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
cmpl $-0x1, 0x8(%rax,%rcx,4)
setne %al
movb %al, -0x1d(%rbp)
movb -0x1d(%rbp), %al
testb $0x1, %al
jne 0x1b0b3
jmp 0x1b3ea
movslq -0x4(%rbp), %rcx
leaq 0xa5882(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
cmpl $0x64, 0x8(%rax,%rcx,4)
jl 0x1b18e
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x10(%rbp)
movslq -0x10(%rbp), %rdx
xorl %eax, %eax
leaq 0xa960e(%rip), %rcx     # 0xc4700
cmpl $-0x1, (%rcx,%rdx,4)
movb %al, -0x1e(%rbp)
je 0x1b137
movslq -0x10(%rbp), %rcx
leaq 0xa95fa(%rip), %rax     # 0xc4700
movl (%rax,%rcx,4), %ecx
movslq -0x4(%rbp), %rax
leaq 0xa582c(%rip), %rdx     # 0xc0940
imulq $0xd0, %rax, %rax
addq %rax, %rdx
movslq -0xc(%rbp), %rsi
xorl %eax, %eax
cmpl 0x8(%rdx,%rsi,4), %ecx
movb %al, -0x1e(%rbp)
je 0x1b137
cmpl $0x14, -0x10(%rbp)
setl %al
movb %al, -0x1e(%rbp)
movb -0x1e(%rbp), %al
testb $0x1, %al
jne 0x1b140
jmp 0x1b14d
jmp 0x1b142
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1b0e5
movslq -0x10(%rbp), %rcx
leaq 0xa95a8(%rip), %rax     # 0xc4700
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1b189
movslq -0x4(%rbp), %rcx
leaq 0xa57d7(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl 0x8(%rax,%rcx,4), %edx
movslq -0x10(%rbp), %rcx
leaq 0xa957a(%rip), %rax     # 0xc4700
movl %edx, (%rax,%rcx,4)
jmp 0x1b3e5
movl $0x0, -0x10(%rbp)
cmpl $0x4c, -0x10(%rbp)
jge 0x1b2d2
movslq -0x10(%rbp), %rcx
leaq 0xa5796(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movslq -0x4(%rbp), %rdx
leaq 0xa577e(%rip), %rcx     # 0xc0940
imulq $0xd0, %rdx, %rdx
addq %rdx, %rcx
movslq -0xc(%rbp), %rdx
cmpl 0x8(%rcx,%rdx,4), %eax
jne 0x1b2c2
movl $0x0, -0x14(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0xa5754(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
cmpl $-0x1, 0x30(%rax,%rcx,4)
je 0x1b2c0
movl $0x0, -0x18(%rbp)
movslq -0x18(%rbp), %rdx
xorl %eax, %eax
leaq 0xa94e7(%rip), %rcx     # 0xc4700
cmpl $-0x1, (%rcx,%rdx,4)
movb %al, -0x1f(%rbp)
je 0x1b25e
movslq -0x18(%rbp), %rcx
leaq 0xa94d3(%rip), %rax     # 0xc4700
movl (%rax,%rcx,4), %ecx
movslq -0x10(%rbp), %rax
leaq 0xa5705(%rip), %rdx     # 0xc0940
imulq $0xd0, %rax, %rax
addq %rax, %rdx
movslq -0x14(%rbp), %rsi
xorl %eax, %eax
cmpl 0x30(%rdx,%rsi,4), %ecx
movb %al, -0x1f(%rbp)
je 0x1b25e
cmpl $0x14, -0x18(%rbp)
setl %al
movb %al, -0x1f(%rbp)
movb -0x1f(%rbp), %al
testb $0x1, %al
jne 0x1b267
jmp 0x1b274
jmp 0x1b269
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1b20c
movslq -0x18(%rbp), %rcx
leaq 0xa9481(%rip), %rax     # 0xc4700
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1b2b0
movslq -0x10(%rbp), %rcx
leaq 0xa56b0(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movl 0x30(%rax,%rcx,4), %edx
movslq -0x18(%rbp), %rcx
leaq 0xa9453(%rip), %rax     # 0xc4700
movl %edx, (%rax,%rcx,4)
jmp 0x1b2b2
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1b1e1
jmp 0x1b2c2
jmp 0x1b2c4
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1b195
movl $0x0, -0x10(%rbp)
movslq -0x10(%rbp), %rdx
xorl %eax, %eax
leaq 0xa941a(%rip), %rcx     # 0xc4700
cmpl $-0x1, (%rcx,%rdx,4)
movb %al, -0x20(%rbp)
je 0x1b30f
movslq -0x10(%rbp), %rdx
xorl %eax, %eax
leaq 0xa9404(%rip), %rcx     # 0xc4700
cmpl $0x6a, (%rcx,%rdx,4)
movb %al, -0x20(%rbp)
je 0x1b30f
cmpl $0x14, -0x10(%rbp)
setl %al
movb %al, -0x20(%rbp)
movb -0x20(%rbp), %al
testb $0x1, %al
jne 0x1b318
jmp 0x1b325
jmp 0x1b31a
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1b2d9
movslq -0x10(%rbp), %rcx
leaq 0xa93d0(%rip), %rax     # 0xc4700
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1b342
movl $0x0, -0x1c(%rbp)
jmp 0x1b3e3
movslq -0x4(%rbp), %rcx
leaq 0xa55f3(%rip), %rax     # 0xc0940
imulq $0xd0, %rcx, %rcx
addq %rcx, %rax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpl $-0x1, 0x8(%rax,%rcx,4)
jne 0x1b370
movl $0x0, -0x1c(%rbp)
jmp 0x1b3e1
movl $0x0, -0x10(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0xa937e(%rip), %rax     # 0xc4700
cmpl $0x6a, (%rax,%rcx,4)
je 0x1b395
jmp 0x1b38a
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1b377
movl -0x10(%rbp), %eax
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0xa935a(%rip), %rax     # 0xc4700
cmpl $-0x1, (%rax,%rcx,4)
je 0x1b3d8
movl -0x14(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0xa9344(%rip), %rax     # 0xc4700
movl (%rax,%rcx,4), %edx
movslq -0x14(%rbp), %rcx
leaq 0xa9336(%rip), %rax     # 0xc4700
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1b39b
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1b3e3
jmp 0x1b3e5
jmp 0x1b078
jmp 0x1b3ec
popq %rbp
retq
nop