// File: /workspace/github_cpp_makefile_star2_O1/matteorr[P]EarleyParser/EarleyParser.cpp
// Function: EarleyParser::completer(State*, int)
void EarleyParser::completer( State* stateCompleted, int positionInputString )
{
	cout << "[DEBUG]: complete [" << stateCompleted->getNonTerminal() << "][" << stateCompleted->getProductionProgress() << "][" << stateCompleted->getInputStringProgress() << "]" << endl;
	//string nonTerminal = stateCompleted->getNonTerminal();
	//int inputStringProgress = stateCompleted->getInputStringProgress();
	//cout << "test input string progress: " << inputStringProgress << endl << endl;
	//vector<State>::iterator itTest = this->earleyParserChart[ stateCompleted->getInputStringProgress() ].begin();
	//cout << "test iterator: " << itTest->getNonTerminal() << endl << endl;

	if( stateCompleted->getInputStringProgress() >= this->earleyParserChart.size() ){
		cout << "[ERROR]: COMPLETER OVERFLOW" << endl;
		exit(1);
	}
	for( vector<State*>::iterator it = this->earleyParserChart[ stateCompleted->getInputStringProgress() ].begin();
			it != this->earleyParserChart[ stateCompleted->getInputStringProgress() ].end(); it++ )
	{
		if( (*it)->getProductionPointer()->getProductionContent().size() <= (*it)->getProductionProgress() ) continue;
		if( stateCompleted->getNonTerminal() == (*it)->getProductionPointer()->getProductionContent().at( (*it)->getProductionProgress() ) )
		{
			//cout << "before constructor in complete" << endl;
			State* stateToInsert = new State( (*it)->getNonTerminal(), (*it)->getProductionPointer(), stateCompleted, (*it)->getInputStringProgress(), (*it)->getProductionProgress() + 1 );
			this->earleyParserChart[ positionInputString ].push_back( stateToInsert );
			//cout << "after push back in complete" << endl;
		}
		//cout << "destructor called in complete" << endl;
	}

	//cout << "[DEBUG]: completed [" << stateCompleted.getNonTerminal() << "]" << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edx, %r15d
movq %rsi, %r13
movq %rdi, %rbx
movq 0x9053(%rip), %r14      # 0xdfd8
leaq 0x551d(%rip), %rsi      # 0xa4a9
movl $0x13, %edx
movq %r14, %rdi
callq 0x2220
leaq -0x48(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x945a
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r12
leaq 0x51c1(%rip), %rsi      # 0xa184
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movq %r13, %rdi
callq 0x94bc
movq %r12, %rdi
movl %eax, %esi
callq 0x22d0
movq %rax, %r12
leaq 0x5198(%rip), %rsi      # 0xa184
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movq %r13, %rdi
callq 0x9450
movq %r12, %rdi
movl %eax, %esi
callq 0x22d0
movq %rax, %r12
leaq 0x5028(%rip), %rsi      # 0xa03d
movl $0x1, %edx
movq %rax, %rdi
callq 0x2220
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x505c
callq 0x21a0
movq %r13, %rdi
callq 0x9450
cltq
movq 0x88(%rbx), %rcx
subq 0x80(%rbx), %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rax, %rdx
jbe 0x52ad
movq %r13, %rdi
callq 0x9450
cltq
movq 0x80(%rbx), %rcx
leaq (%rax,%rax,2), %rax
movq %rbx, %r14
movq (%rcx,%rax,8), %rbx
movq %r13, %rdi
callq 0x9450
cltq
movq %r14, -0x50(%rbp)
movq 0x80(%r14), %rcx
leaq (%rax,%rax,2), %rax
cmpq 0x8(%rcx,%rax,8), %rbx
je 0x5290
movslq %r15d, %rax
leaq -0x48(%rbp), %r15
leaq (%rax,%rax,2), %rax
movq %rax, -0x58(%rbp)
movq (%rbx), %rdi
callq 0x9488
movq %r15, %rdi
movq %rax, %rsi
callq 0x92e6
movq -0x48(%rbp), %r12
movq -0x40(%rbp), %r14
movq (%rbx), %rdi
callq 0x94bc
subq %r12, %r14
sarq $0x5, %r14
movslq %eax, %r12
movq %r15, %rdi
callq 0x60da
cmpq %r12, %r14
jbe 0x5268
movq %r15, %rdi
movq %r13, %rsi
callq 0x945a
movq (%rbx), %rdi
callq 0x9488
leaq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x92e6
movq (%rbx), %rdi
callq 0x94bc
movslq %eax, %rsi
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rsi, %rdx
jbe 0x529f
shlq $0x5, %rsi
movq -0x40(%rbp), %rdx
cmpq 0x8(%rax,%rsi), %rdx
jne 0x5189
testq %rdx, %rdx
je 0x518e
addq %rsi, %rax
movq (%rax), %rsi
movq -0x48(%rbp), %rdi
callq 0x21f0
testl %eax, %eax
sete %r14b
jmp 0x5191
xorl %r14d, %r14d
jmp 0x5191
movb $0x1, %r14b
leaq -0x70(%rbp), %rdi
callq 0x60da
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x51ac
callq 0x21a0
testb %r14b, %r14b
je 0x5268
movq %r13, %r15
movl $0x58, %edi
callq 0x21e0
movq %rax, %r13
movq (%rbx), %rsi
leaq -0x90(%rbp), %rdi
callq 0x945a
movq (%rbx), %rdi
callq 0x9488
movq %rax, %r12
movq (%rbx), %rdi
callq 0x9450
movl %eax, %r14d
movq (%rbx), %rdi
callq 0x94bc
incl %eax
movq %r13, %rdi
leaq -0x90(%rbp), %rsi
movq %r12, %rdx
movq %r15, %rcx
movl %r14d, %r8d
movl %eax, %r9d
callq 0x9318
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x5224
callq 0x21a0
movq %r13, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x58(%rbp), %rcx
leaq (%rax,%rcx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x5256
movq %r13, (%rsi)
addq $0x8, 0x8(%rdi)
movq %r15, %r13
leaq -0x48(%rbp), %r15
jmp 0x5268
leaq -0x48(%rbp), %r14
movq %r14, %rdx
callq 0x744e
movq %r15, %r13
movq %r14, %r15
addq $0x8, %rbx
movq %r13, %rdi
callq 0x9450
cltq
movq -0x50(%rbp), %rcx
movq 0x80(%rcx), %rcx
leaq (%rax,%rax,2), %rax
cmpq 0x8(%rcx,%rax,8), %rbx
jne 0x50de
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x536f(%rip), %rdi      # 0xa615
xorl %eax, %eax
callq 0x2280
movq 0x8d24(%rip), %rdi      # 0xdfd8
leaq 0x5202(%rip), %rsi      # 0xa4bd
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movl $0x1, %edi
callq 0x2230
movq %rax, %rbx
jmp 0x530c
jmp 0x52d9
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x60da
jmp 0x5322
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
jmp 0x532a
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x530c
callq 0x21a0
movq %r13, %rdi
jmp 0x532f
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60da
jmp 0x5334
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5334
callq 0x21a0
movq %rbx, %rdi
callq 0x22f0