// File: matteorr[P]EarleyParser/EarleyParser.cpp
// Function: EarleyParser::createChart(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int EarleyParser::createChart( string mainNonTerminal )
{
	list<Production>* mainProduction;

	mainProduction = this->getProduction( mainNonTerminal );
	if( mainProduction == NULL ) return -1;

	/*
	 * providing seed of parsing algorithm
	 * main production of phrase in the context grammar
	 */
	//this->earleyParserChart = new vector<State>[ this->inputVector.size() + 1 ];
	this->earleyParserChart.resize( this->inputVector.size() + 1 );

	cout << "[DEBUG]: size of list (number of productions with " << mainNonTerminal << " as non terminal) = " << mainProduction->size() << endl;

	for( list<Production>::iterator it = mainProduction->begin(); it != mainProduction->end(); it++ )
	{
		for( unsigned int j = 0; j < it->getProductionContent().size(); j++ )
		{
			cout << "[DEBUG]: element of list " << it->getProductionContent().at(j) << endl;
		}

		State *initialState = new State( mainNonTerminal, &(*it), NULL, 0, 0 );
		this->earleyParserChart[0].push_back( initialState );
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rsi, -0xf0(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x20f0
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0x46e0
movq %rax, -0xd8(%rbp)
jmp 0x47a1
movq -0xd8(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2140
cmpq $0x0, -0x20(%rbp)
jne 0x47e2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4ab3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2140
jmp 0x4abf
movq -0xe8(%rbp), %rdi
movq %rdi, %rax
addq $0x80, %rax
movq %rax, -0x100(%rbp)
addq $0x98, %rdi
callq 0x6c90
movq -0x100(%rbp), %rdi
movq %rax, %rsi
addq $0x1, %rsi
callq 0x78b0
movq 0x177b9(%rip), %rdi     # 0x1bfd8
leaq 0xe9ff(%rip), %rsi      # 0x13225
callq 0x21c0
movq -0xf0(%rbp), %rsi
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
leaq 0xea14(%rip), %rsi      # 0x13258
callq 0x21c0
movq %rax, -0xf8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x7940
movq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0x2080
movq %rax, %rdi
movq 0x17756(%rip), %rsi     # 0x1bfc8
callq 0x21f0
movq -0x20(%rbp), %rdi
callq 0x7470
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
callq 0x74d0
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x74a0
testb $0x1, %al
jne 0x48a7
jmp 0x4aac
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq %rax, -0x108(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x7500
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x114b0
leaq -0x80(%rbp), %rdi
callq 0x6c90
movq %rax, -0x110(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x6f60
movq -0x110(%rbp), %rcx
movq -0x108(%rbp), %rax
cmpq %rcx, %rax
jae 0x49b8
movq 0x176d4(%rip), %rdi     # 0x1bfd8
leaq 0xe962(%rip), %rsi      # 0x1326d
callq 0x21c0
movq %rax, -0x128(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x7500
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x114b0
movq -0x120(%rbp), %rdi
movl -0x64(%rbp), %eax
movl %eax, %esi
callq 0x7090
movq %rax, -0x118(%rbp)
jmp 0x4950
movq -0x118(%rbp), %rsi
movq -0x128(%rbp), %rdi
callq 0x21a0
movq %rax, -0x130(%rbp)
jmp 0x496c
movq -0x130(%rbp), %rdi
movq 0x1764e(%rip), %rsi     # 0x1bfc8
callq 0x21f0
jmp 0x4981
leaq -0x98(%rbp), %rdi
callq 0x6f60
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x48ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x6f60
jmp 0x4abf
movl $0x58, %edi
callq 0x21d0
movq -0xf0(%rbp), %rsi
movq %rax, -0x138(%rbp)
movb $0x1, -0xc1(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x20f0
jmp 0x49e5
leaq -0x58(%rbp), %rdi
callq 0x7970
movq -0x138(%rbp), %rdi
movq %rax, %rdx
xorl %r9d, %r9d
movl %r9d, %ecx
leaq -0xc0(%rbp), %rsi
movl %r9d, %r8d
callq 0x11520
jmp 0x4a0f
movb $0x0, -0xc1(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x2140
movq -0x138(%rbp), %rax
movq -0xe8(%rbp), %rdi
movq %rax, -0xa0(%rbp)
addq $0x80, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7990
movq %rax, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x79b0
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x7520
movq %rax, -0xd0(%rbp)
jmp 0x4884
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x4a93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x2140
testb $0x1, -0xc1(%rbp)
jne 0x4a9e
jmp 0x4aaa
movq -0x138(%rbp), %rdi
callq 0x21b0
jmp 0x4abf
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2340
nopl (%rax,%rax)