// File: /workspace/github_cpp_makefile_star2_O3/matteorr[P]EarleyParser/EarleyParser.cpp
// Function: EarleyParser::scanner(State*, int)
void EarleyParser::scanner( State* stateToScan, int positionInputString )
{
	Production* productionInStateToScan = stateToScan->getProductionPointer();

	if( positionInputString >= this->inputVector.size() ){
		cout << "[DEBUG]: scanner fail, input string end reached" << endl;
		return;
	}

	if( this->inputVector.at( positionInputString ) == productionInStateToScan->getProductionContent().at( stateToScan->getProductionProgress() ) )
	{
		/*
		 * the symbol to be scanned in the production is the same of the input string
		 * a new state must be created in the next position of the chart
		 *
		 * must check for equal states in the chart and avoid insertion in case
		 */
		cout << "[DEBUG]: scan [" << this->inputVector.at( positionInputString ) << "][" << stateToScan->getProductionProgress() << "][" << stateToScan->getInputStringProgress() << "]" << endl;

		State* stateToInsert = new State( stateToScan->getNonTerminal(), stateToScan->getProductionPointer(), stateToScan, stateToScan->getInputStringProgress(), stateToScan->getProductionProgress() + 1 );
		cout << "[DEBUG]: scanner is inserting state in chart position " << positionInputString + 1 << endl;
		this->earleyParserChart[ positionInputString + 1 ].push_back( stateToInsert );
	}else{
		/*
		 * do nothing
		 * symbol to be scanned does not match with symbol in the input string
		 */

		cout << "[DEBUG]: scan mismatch - input[" << this->inputVector.at( positionInputString ) << "] production[" << productionInStateToScan->getProductionContent().at( stateToScan->getProductionProgress() ) << "]" << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r12
movq %rsi, %rdi
callq 0x947c
movq %rax, %r13
movl %ebx, -0x44(%rbp)
movslq %ebx, %r14
movq 0x98(%r12), %rbx
movq %r12, -0x50(%rbp)
movq 0xa0(%r12), %rax
subq %rbx, %rax
sarq $0x5, %rax
cmpq %r14, %rax
jbe 0x4bb3
leaq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x92d6
movq %r15, %rdi
callq 0x94b0
movslq %eax, %rsi
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rsi, %rdx
jbe 0x4eeb
movq %r14, %r12
shlq $0x5, %r12
addq %r12, %rbx
shlq $0x5, %rsi
movq 0x8(%rbx), %rdx
cmpq 0x8(%rax,%rsi), %rdx
jne 0x4c03
testq %rdx, %rdx
je 0x4d05
addq %rsi, %rax
movq (%rax), %rsi
movq (%rbx), %rdi
callq 0x21f0
movl %eax, %ebx
leaq -0x40(%rbp), %rdi
callq 0x60b2
testl %ebx, %ebx
jne 0x4c0c
jmp 0x4d0e
movq 0x941e(%rip), %rbx      # 0xdfd8
leaq 0x5843(%rip), %rsi      # 0xa404
movl $0x2f, %edx
movq %rbx, %rdi
callq 0x2220
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2150
leaq -0x40(%rbp), %rdi
callq 0x60b2
movq 0x93c5(%rip), %rdi      # 0xdfd8
leaq 0x5861(%rip), %rsi      # 0xa47b
movl $0x1f, %edx
callq 0x2220
movq -0x50(%rbp), %rcx
movq 0x98(%rcx), %rax
movq 0xa0(%rcx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %r14, %rdx
jbe 0x4ef9
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
movq 0x9382(%rip), %rdi      # 0xdfd8
callq 0x2220
movq %rax, %rbx
leaq 0x5836(%rip), %rsi      # 0xa49b
movl $0xd, %edx
movq %rax, %rdi
callq 0x2220
leaq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x92d6
movq %r15, %rdi
callq 0x94b0
movslq %eax, %rsi
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rdx
subq %rcx, %rdx
sarq $0x5, %rdx
cmpq %rsi, %rdx
jbe 0x4f0a
shlq $0x5, %rsi
movq (%rcx,%rsi), %rax
movq 0x8(%rcx,%rsi), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2220
movq %rax, %rbx
leaq 0x537a(%rip), %rsi      # 0xa03d
movl $0x1, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
leaq -0x40(%rbp), %rdi
callq 0x60b2
jmp 0x4edc
leaq -0x40(%rbp), %rdi
callq 0x60b2
movq 0x92c3(%rip), %rdi      # 0xdfd8
leaq 0x5718(%rip), %rsi      # 0xa434
movl $0xf, %edx
callq 0x2220
movq -0x50(%rbp), %rbx
movq 0x98(%rbx), %rax
movq 0xa0(%rbx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %r14, %rdx
jbe 0x4ef9
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
movq 0x9280(%rip), %rdi      # 0xdfd8
callq 0x2220
movq %rax, %r14
leaq 0x541d(%rip), %r12      # 0xa184
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2220
movq %r15, %rdi
callq 0x94b0
movq %r14, %rdi
movl %eax, %esi
callq 0x22d0
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2220
movq %r15, %rdi
callq 0x9444
movq %r14, %rdi
movl %eax, %esi
callq 0x22d0
movq %rax, %r14
leaq 0x5285(%rip), %rsi      # 0xa03d
movl $0x1, %edx
movq %rax, %rdi
callq 0x2220
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movl $0x58, %edi
callq 0x21e0
movq %rax, %r14
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x944e
movq %r15, %rdi
callq 0x947c
movq %rax, %r13
movq %r15, %rdi
callq 0x9444
movl %eax, %r12d
movq %r15, %rdi
callq 0x94b0
incl %eax
leaq -0x70(%rbp), %rsi
movq %r14, %rdi
movq %r13, %rdx
movq %r15, %rcx
movl %r12d, %r8d
movl %eax, %r9d
callq 0x9308
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4e4f
callq 0x21a0
movq %r14, -0x40(%rbp)
movq %r14, %r12
movq 0x917b(%rip), %r14      # 0xdfd8
leaq 0x55e0(%rip), %rsi      # 0xa444
movl $0x36, %edx
movq %r14, %rdi
callq 0x2220
movl -0x44(%rbp), %r15d
incl %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x22d0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movslq %r15d, %rax
movq 0x80(%rbx), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x4ed3
movq %r12, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x4edc
leaq -0x40(%rbp), %rdx
callq 0x7442
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5723(%rip), %rdi      # 0xa615
xorl %eax, %eax
callq 0x2280
leaq 0x5715(%rip), %rdi      # 0xa615
movq %r14, %rsi
xorl %eax, %eax
callq 0x2280
leaq 0x5704(%rip), %rdi      # 0xa615
xorl %eax, %eax
callq 0x2280
movq %rax, %rbx
jmp 0x4f32
movq %rax, %rbx
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4f32
callq 0x21a0
movq %r14, %rdi
callq 0x21a0
jmp 0x4f4a
jmp 0x4f3e
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x60b2
movq %rbx, %rdi
callq 0x22f0