// File: /workspace/github_cpp_makefile_star2_O1/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 0x9488
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 0x4bc3
leaq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x92e6
movq %r15, %rdi
callq 0x94bc
movslq %eax, %rsi
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rsi, %rdx
jbe 0x4efc
movq %r14, %r12
shlq $0x5, %r12
addq %r12, %rbx
shlq $0x5, %rsi
movq 0x8(%rbx), %rdx
cmpq 0x8(%rax,%rsi), %rdx
jne 0x4c13
testq %rdx, %rdx
je 0x4d15
addq %rsi, %rax
movq (%rax), %rsi
movq (%rbx), %rdi
callq 0x21f0
movl %eax, %ebx
leaq -0x40(%rbp), %rdi
callq 0x60da
testl %ebx, %ebx
jne 0x4c1c
jmp 0x4d1e
movq 0x940e(%rip), %rbx      # 0xdfd8
leaq 0x5833(%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 0x60da
movq 0x93b5(%rip), %rdi      # 0xdfd8
leaq 0x5851(%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 0x4f0a
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
movq 0x9372(%rip), %rdi      # 0xdfd8
callq 0x2220
movq %rax, %rbx
leaq 0x5826(%rip), %rsi      # 0xa49b
movl $0xd, %edx
movq %rax, %rdi
callq 0x2220
leaq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x92e6
movq %r15, %rdi
callq 0x94bc
movslq %eax, %rsi
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rdx
subq %rcx, %rdx
sarq $0x5, %rdx
cmpq %rsi, %rdx
jbe 0x4f1b
shlq $0x5, %rsi
movq (%rcx,%rsi), %rax
movq 0x8(%rcx,%rsi), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2220
movq %rax, %rbx
leaq 0x536a(%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 0x60da
jmp 0x4eed
leaq -0x40(%rbp), %rdi
callq 0x60da
movq 0x92b3(%rip), %rdi      # 0xdfd8
leaq 0x5708(%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 0x4f0a
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
movq 0x9270(%rip), %rdi      # 0xdfd8
callq 0x2220
movq %rax, %r14
leaq 0x540d(%rip), %r12      # 0xa184
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2220
movq %r15, %rdi
callq 0x94bc
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 0x9450
movq %r14, %rdi
movl %eax, %esi
callq 0x22d0
movq %rax, %r14
leaq 0x5275(%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 0x945a
movq %r15, %rdi
callq 0x9488
movq %rax, %r13
movq %r15, %rdi
callq 0x9450
movl %eax, %r12d
movq %r15, %rdi
callq 0x94bc
incl %eax
leaq -0x70(%rbp), %rsi
movq %r14, %rdi
movq %r13, %rdx
movq %r15, %rcx
movl %r12d, %r8d
movl %eax, %r9d
callq 0x9318
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4e5f
callq 0x21a0
movq %r14, -0x40(%rbp)
movq 0x916e(%rip), %r14      # 0xdfd8
leaq 0x55d3(%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 0x4ee4
movq -0x40(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x4eed
leaq -0x40(%rbp), %rdx
callq 0x744e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5712(%rip), %rdi      # 0xa615
xorl %eax, %eax
callq 0x2280
leaq 0x5704(%rip), %rdi      # 0xa615
movq %r14, %rsi
xorl %eax, %eax
callq 0x2280
leaq 0x56f3(%rip), %rdi      # 0xa615
xorl %eax, %eax
callq 0x2280
movq %rax, %rbx
jmp 0x4f43
movq %rax, %rbx
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4f43
callq 0x21a0
movq %r14, %rdi
callq 0x21a0
jmp 0x4f5b
jmp 0x4f4f
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x60da
movq %rbx, %rdi
callq 0x22f0
nop