// File: /workspace/github_cpp_makefile_star2_O1/Caproner[P]Naive_Compiler/Grammar/Grammar.cpp
// Function: Grammar::Handle_Analysis(int)
bool Grammar::Handle_Analysis(int pos)
{
	while(!(this->Status_Stack.empty()))
		this->Status_Stack.pop();
	while(!(this->Symbol_Stack.empty()))
	{
		TreeNode *p=this->Symbol_Stack.top();
		this->Symbol_Stack.pop();
		this->Delete(p);
	}
	
	Word_List &WL=this->Handle_List[pos];
	WL.List.push_back(Word(14,0));
	this->Status_Stack.push(0);
	
	int cur=0;
	
	bool ret=true;
	
	#ifdef TEST
	int Count=1;
	#endif
	
	while(true)
	{
		#ifdef TEST
		printf("%d: ",Count++);
		#endif
		if(cur==WL.List.size())
		{
			ret=false;
			break;
		}
		char &C=this->Number_to_Symbol[WL.List[cur].Number];
		int &S=this->Status_Stack.top();
		if(this->ACTION.find(std::make_pair(C,S))==this->ACTION.end())
		{
			ret=false;
			break;
		}
		int Status_Code=this->ACTION[std::make_pair(C,S)];
		#ifdef TEST
		printf("Find ACTION[%c,%d] = %d, ",C,S,Status_Code);
		#endif
		if(Status_Code==0)
		{
			#ifdef TEST
			printf("Accept!\n");
			#endif
			break;
		}
		else if(Status_Code>0)
		{
			#ifdef TEST
			printf("Push_Back %d\n",Status_Code);
			#endif
			this->Status_Stack.push(Status_Code);
			TreeNode *p=new TreeNode;
			p->Next.clear();
			p->Parent=NULL;
			p->Node_Word=WL.List[cur];
			this->Symbol_Stack.push(p);
			cur++;
		}
		else
		{
			Status_Code=-Status_Code;
			char U_Symbol=this->Grammars[Status_Code][0];
			#ifdef TEST
			printf("Reduce: %s, ",this->Grammars[Status_Code].c_str());
			#endif
			int len=this->Grammars[Status_Code].length();
			TreeNode *p=new TreeNode;
			p->Next.clear();
			p->Parent=NULL;
			p->Node_Word=Word(13,0);
			for(int i=0;i<len-2;i++)
			{
				if(this->Symbol_Stack.empty())
				{
					ret=false;
					break;
				}
				TreeNode *q=this->Symbol_Stack.top();
				this->Symbol_Stack.pop();
				p->Next.push_back(q);
				q->Parent=p;
				this->Status_Stack.pop();
			}
			if(!ret)break;
			std::reverse(p->Next.begin(),p->Next.end());
			if(this->GOTO.find(std::make_pair(U_Symbol,this->Status_Stack.top()))==this->GOTO.end())
			{
				ret=false;
				break;
			}
			#ifdef TEST
			printf("Push_Back GOTO[%c,%d]=%d\n",U_Symbol,this->Status_Stack.top(),this->GOTO[std::make_pair(U_Symbol,this->Status_Stack.top())]);
			#endif
			this->Status_Stack.push(this->GOTO[std::make_pair(U_Symbol,this->Status_Stack.top())]);
			this->Symbol_Stack.push(p);
		}
	}
	if(ret)
	{
		this->Grammar_Forest.forest.push_back(this->Symbol_Stack.top());
		this->Symbol_Stack.pop();
	}
	else
	{
		while(!(this->Symbol_Stack.empty()))
		{
			TreeNode *p=this->Symbol_Stack.top();
			this->Symbol_Stack.pop();
			this->Delete(p);
		}
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0xa8(%rdi), %r14
movq 0xd8(%rdi), %rax
cmpq 0xb8(%rdi), %rax
je 0x411c
movq %r14, %rdi
callq 0x4e08
movq 0xd8(%rbx), %rax
cmpq 0xb8(%rbx), %rax
jne 0x4104
movq %r14, 0x40(%rsp)
leaq 0xf8(%rbx), %r14
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
je 0x417c
movl $0x200, %r13d           # imm = 0x200
cmpq 0x130(%rbx), %rax
jne 0x4155
movq 0x140(%rbx), %rax
movq -0x8(%rax), %rax
addq %r13, %rax
movq -0x8(%rax), %r12
movq %r14, %rdi
callq 0x4e54
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4070
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
jne 0x413e
movslq %ebp, %rax
movq (%rbx), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %r15
movl $0xe, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x41b4
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%r15)
jmp 0x41c1
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
callq 0x4ea0
movq 0x40(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0x0, (%rsi)
callq 0x4f80
leaq 0x148(%rbx), %rax
movq %rax, 0x60(%rsp)
leaq 0x48(%rbx), %rbp
leaq 0x50(%rbx), %rax
movq %rax, 0x58(%rsp)
leaq 0x78(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x80(%rbx), %rax
movq %rax, 0x50(%rsp)
movb $0x1, %al
movl %eax, 0x4(%rsp)
movl $0x0, 0x30(%rsp)
movq %r14, 0x28(%rsp)
movq %r15, 0x38(%rsp)
movq %rbp, 0x8(%rsp)
movslq 0x30(%rsp), %r13
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
sarq $0x4, %rax
cmpq %r13, %rax
je 0x464a
shlq $0x4, %r13
addq %r13, %rsi
movq 0x60(%rsp), %rdi
callq 0x4bac
movq %rax, %r14
movq 0xd8(%rbx), %r15
cmpq 0xe0(%rbx), %r15
jne 0x4274
movq 0xf0(%rbx), %rax
movq -0x8(%rax), %r15
movl $0x200, %eax            # imm = 0x200
addq %rax, %r15
movzbl (%r14), %eax
movl -0x4(%r15), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%rsp)
movq %rbp, %rdi
movq %rbp, %r12
leaq 0x18(%rsp), %rbp
movq %rbp, %rsi
callq 0x53de
cmpq 0x58(%rsp), %rax
je 0x4308
movzbl (%r14), %eax
movl -0x4(%r15), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x4c10
movslq (%rax), %rax
movl %eax, 0x34(%rsp)
testq %rax, %rax
je 0x4324
testl %eax, %eax
movq 0x40(%rsp), %r12
jle 0x4335
movq 0xd8(%rbx), %rcx
movq 0xe8(%rbx), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
movq 0x38(%rsp), %r15
je 0x4440
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0xd8(%rbx)
jmp 0x444d
xorl %eax, %eax
movl $0x0, 0x4(%rsp)
movq 0x38(%rsp), %r15
movq 0x28(%rsp), %r14
movq %r12, %rbp
jmp 0x45f2
xorl %eax, %eax
movq 0x38(%rsp), %r15
movq 0x28(%rsp), %r14
jmp 0x45ed
movl %eax, %ecx
negl %ecx
movl %ecx, 0x34(%rsp)
movq 0x30(%rbx), %rcx
shlq $0x5, %rax
movq %rcx, %rdx
subq %rax, %rdx
movq (%rdx), %rdx
movzbl (%rdx), %ebp
negq %rax
movl 0x8(%rcx,%rax), %r13d
movl $0x30, %edi
callq 0x2190
movl $0x0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movups %xmm0, 0x18(%rax)
movq %rax, 0x18(%rsp)
movq 0x10(%rax), %rcx
cmpq %rcx, 0x18(%rax)
movq 0x38(%rsp), %r15
je 0x438c
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x28(%rax)
movl $0xd, (%rax)
movq %rcx, 0x8(%rax)
cmpl $0x3, %r13d
movq 0x28(%rsp), %r14
jl 0x44da
addl $-0x2, %r13d
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
je 0x44d2
cmpq 0x130(%rbx), %rax
jne 0x43df
movq 0x140(%rbx), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq -0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x4e54
movq 0x18(%rsp), %rdi
movq 0x18(%rdi), %rsi
cmpq 0x20(%rdi), %rsi
je 0x440e
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rdi)
jmp 0x441c
addq $0x10, %rdi
leaq 0x10(%rsp), %rdx
callq 0x59ca
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, 0x28(%rcx)
movq %r12, %rdi
callq 0x4e08
decl %r13d
jne 0x43af
jmp 0x44da
movq %r12, %rdi
leaq 0x34(%rsp), %rsi
callq 0x56ee
movq 0x28(%rsp), %r14
movl $0x30, %edi
callq 0x2190
movl $0x0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movups %xmm0, 0x18(%rax)
movq %rax, 0x18(%rsp)
movq 0x10(%rax), %rcx
cmpq %rcx, 0x18(%rax)
je 0x4480
movq %rcx, 0x18(%rax)
movq $0x0, 0x28(%rax)
movq (%r15), %rcx
movups (%rcx,%r13), %xmm0
movups %xmm0, (%rax)
movq 0x128(%rbx), %rcx
movq 0x138(%rbx), %rdx
addq $-0x8, %rdx
cmpq %rdx, %rcx
je 0x44b7
movq %rax, (%rcx)
addq $0x8, 0x128(%rbx)
jmp 0x44c2
movq %r14, %rdi
movq %rbp, %rsi
callq 0x57b6
movq 0x8(%rsp), %rbp
incl 0x30(%rsp)
movb $0x1, %al
jmp 0x45f2
movl $0x0, 0x4(%rsp)
testb $0x1, 0x4(%rsp)
je 0x45df
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rax
movq 0x18(%rcx), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x8, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x452e
addq $0x8, %rax
movq -0x8(%rax), %rdx
movq (%rcx), %rsi
movq %rsi, -0x8(%rax)
movq %rdx, (%rcx)
addq $-0x8, %rcx
leaq 0x8(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x4510
movq 0xd8(%rbx), %rax
cmpq 0xe0(%rbx), %rax
jne 0x4551
movq 0xf0(%rbx), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movl -0x4(%rax), %eax
shlq $0x20, %rax
orq %rbp, %rax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x53de
cmpq 0x50(%rsp), %rax
je 0x45e3
movq 0xd8(%rbx), %rax
cmpq 0xe0(%rbx), %rax
jne 0x4599
movq 0xf0(%rbx), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movl -0x4(%rax), %eax
shlq $0x20, %rax
orq %rbp, %rax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x4c10
movq 0xd8(%rbx), %rcx
movq 0xe8(%rbx), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x45fc
movl (%rax), %eax
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0xd8(%rbx)
jmp 0x4607
xorl %eax, %eax
jmp 0x45ed
xorl %eax, %eax
movl $0x0, 0x4(%rsp)
movq 0x8(%rsp), %rbp
testb %al, %al
jne 0x4221
jmp 0x4652
movq %r12, %rdi
movq %rax, %rsi
callq 0x56ee
leaq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rbp
movq 0x128(%rbx), %rax
movq 0x138(%rbx), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x463d
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x128(%rbx)
jmp 0x44cb
movq %r14, %rdi
callq 0x57b6
jmp 0x44cb
movl $0x0, 0x4(%rsp)
testb $0x1, 0x4(%rsp)
je 0x4694
movq 0x128(%rbx), %rdx
cmpq 0x130(%rbx), %rdx
jne 0x4679
movq 0x140(%rbx), %rax
movl $0x200, %edx            # imm = 0x200
addq -0x8(%rax), %rdx
addq $-0x8, %rdx
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x46ea
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x20(%rbx)
jmp 0x46f6
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
je 0x46fe
movl $0x200, %r12d           # imm = 0x200
cmpq 0x130(%rbx), %rax
jne 0x46c1
movq 0x140(%rbx), %rax
movq -0x8(%rax), %rax
addq %r12, %rax
movq -0x8(%rax), %r15
movq %r14, %rdi
callq 0x4e54
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4070
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
jne 0x46aa
jmp 0x46fe
addq $0x18, %rbx
movq %rbx, %rdi
callq 0x59ca
movq %r14, %rdi
callq 0x4e54
movl 0x4(%rsp), %eax
andb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop