// File: /workspace/github_cpp_makefile_star2_O3/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), %r15
movq 0xd8(%rdi), %rax
cmpq 0xb8(%rdi), %rax
je 0x4160
movq %r15, %rdi
callq 0x4d9a
movq 0xd8(%rbx), %rax
cmpq 0xb8(%rbx), %rax
jne 0x4148
leaq 0xf8(%rbx), %r14
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
je 0x41bb
movl $0x200, %r13d           # imm = 0x200
cmpq 0x130(%rbx), %rax
jne 0x4194
movq 0x140(%rbx), %rax
movq -0x8(%rax), %rax
addq %r13, %rax
movq -0x8(%rax), %r12
movq %r14, %rdi
callq 0x4de6
movq %rbx, %rdi
movq %r12, %rsi
callq 0x40c0
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
jne 0x417d
movslq %ebp, %rax
movq (%rbx), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %r12
movl $0xe, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x41f6
movups 0x10(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%r12)
jmp 0x4203
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
callq 0x4e32
leaq 0x10(%rsp), %rsi
movl $0x0, (%rsi)
movq %r15, %rdi
callq 0x4f12
movq (%r12), %rsi
movq %r12, 0x40(%rsp)
cmpq %rsi, 0x8(%r12)
je 0x4605
leaq 0x148(%rbx), %rax
movq %rax, 0x60(%rsp)
leaq 0x48(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x50(%rbx), %rax
movq %rax, 0x58(%rsp)
leaq 0x78(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x80(%rbx), %rax
movq %rax, 0x50(%rsp)
xorl %ebp, %ebp
movl $0x0, 0xc(%rsp)
shlq $0x4, %rbp
addq %rbp, %rsi
movq 0x60(%rsp), %rdi
callq 0x4b3e
movq %rax, %r13
movq 0xd8(%rbx), %r12
cmpq 0xe0(%rbx), %r12
jne 0x429e
movq 0xf0(%rbx), %rax
movq -0x8(%rax), %r12
movl $0x200, %eax            # imm = 0x200
addq %rax, %r12
movzbl (%r13), %eax
movl -0x4(%r12), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x536e
cmpq 0x58(%rsp), %rax
je 0x4605
movzbl (%r13), %eax
movl -0x4(%r12), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x4ba4
movl (%rax), %r13d
movl %r13d, 0x2c(%rsp)
testl %r13d, %r13d
je 0x465d
jle 0x4334
movq 0xd8(%rbx), %rax
movq 0xe8(%rbx), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x451f
movl %r13d, (%rax)
addq $0x4, %rax
movq %rax, 0xd8(%rbx)
jmp 0x452c
movl %r13d, %eax
negl %eax
movl %eax, 0x2c(%rsp)
movq 0x30(%rbx), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rdx
movzbl (%rdx), %edx
movq %rdx, 0x38(%rsp)
movl 0x8(%rcx,%rax), %ebp
movl $0x30, %edi
callq 0x2190
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %rax, 0x10(%rsp)
movq %rcx, 0x28(%rax)
movl $0xd, (%rax)
movq %rcx, 0x8(%rax)
cmpl $0x3, %ebp
movl $0x200, %r12d           # imm = 0x200
jl 0x4460
addl $-0x2, %ebp
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
je 0x4600
cmpq 0x130(%rbx), %rax
jne 0x43bc
movq 0x140(%rbx), %rax
movq -0x8(%rax), %rax
addq %r12, %rax
movq -0x8(%rax), %rax
movq %rax, 0x20(%rsp)
movq %r14, %rdi
callq 0x4de6
movq 0x10(%rsp), %rdi
movq 0x18(%rdi), %rsi
cmpq 0x20(%rdi), %rsi
je 0x43eb
movq 0x20(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rdi)
jmp 0x43fe
addq $0x10, %rdi
leaq 0x20(%rsp), %rdx
callq 0x5932
movq 0x20(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x28(%rax)
movq %r15, %rdi
callq 0x4d9a
decl %ebp
jne 0x4391
movq 0x10(%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 0x4460
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 0x4442
movq 0xd8(%rbx), %rax
cmpq 0xe0(%rbx), %rax
jne 0x447e
movq 0xf0(%rbx), %rax
movq -0x8(%rax), %rax
addq %r12, %rax
movl -0x4(%rax), %eax
shlq $0x20, %rax
addq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x536e
cmpq 0x50(%rsp), %rax
je 0x4600
movq 0xd8(%rbx), %rax
cmpq 0xe0(%rbx), %rax
jne 0x44c7
movq 0xf0(%rbx), %rax
movq -0x8(%rax), %rax
addq %r12, %rax
movl -0x4(%rax), %eax
shlq $0x20, %rax
addq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4ba4
movq 0xd8(%rbx), %rcx
movq 0xe8(%rbx), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
movq 0x40(%rsp), %r12
movl 0xc(%rsp), %ebp
je 0x459d
movl (%rax), %eax
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0xd8(%rbx)
jmp 0x45a8
movq %r15, %rdi
leaq 0x2c(%rsp), %rsi
callq 0x5656
movl $0x30, %edi
callq 0x2190
movl $0x0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movups %xmm0, 0x18(%rax)
movq %rax, 0x10(%rsp)
movq $0x0, 0x28(%rax)
movq 0x40(%rsp), %r12
movq (%r12), %rcx
movups (%rcx,%rbp), %xmm0
movups %xmm0, (%rax)
movq 0x128(%rbx), %rcx
movq 0x138(%rbx), %rdx
addq $-0x8, %rdx
cmpq %rdx, %rcx
je 0x4588
movq %rax, (%rcx)
addq $0x8, 0x128(%rbx)
jmp 0x4595
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x571e
movl 0xc(%rsp), %ebp
incl %ebp
jmp 0x45de
movq %r15, %rdi
movq %rax, %rsi
callq 0x5656
movq 0x128(%rbx), %rax
movq 0x138(%rbx), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x45d1
movq 0x10(%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x128(%rbx)
jmp 0x45de
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x571e
movl %ebp, 0xc(%rsp)
movslq %ebp, %rbp
movq (%r12), %rsi
movq 0x8(%r12), %rax
subq %rsi, %rax
sarq $0x4, %rax
cmpq %rbp, %rax
jne 0x4267
jmp 0x4605
testl %r13d, %r13d
je 0x465d
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
je 0x4659
movl $0x200, %r12d           # imm = 0x200
cmpq 0x130(%rbx), %rax
jne 0x4632
movq 0x140(%rbx), %rax
movq -0x8(%rax), %rax
addq %r12, %rax
movq -0x8(%rax), %r15
movq %r14, %rdi
callq 0x4de6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x40c0
movq 0x128(%rbx), %rax
cmpq 0x108(%rbx), %rax
jne 0x461b
xorl %eax, %eax
jmp 0x46ae
movq 0x128(%rbx), %rdx
cmpq 0x130(%rbx), %rdx
jne 0x467d
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 0x4698
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x20(%rbx)
jmp 0x46a4
addq $0x18, %rbx
movq %rbx, %rdi
callq 0x5932
movq %r14, %rdi
callq 0x4de6
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop