// File: /workspace/github_cpp_makefile_star2_O1/AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::Name(int&, int&)
bool Parser::Name(int &type, int &size){
	string id;
	scopeValue nameValue;
	bool isGlobal;
	if( Identifier(id) ){
		bool symbolExists = Scopes->checkSymbol(id, nameValue, isGlobal);
		if(symbolExists){
			if(nameValue.type == TYPE_PROCEDURE){
				ReportError(id + " is a procedure in this scope, not a variable.");
			}
			else{
				size = nameValue.size;
				type = nameValue.type;
			}
		}
		else{
			ReportError(id + " has not been declared in this scope.");
			size = 0;
			type = T_UNKNOWN;
		}

		if( CheckToken(T_LBRACKET) ){
			if(nameValue.size == 0 && nameValue.type != TYPE_PROCEDURE) ReportError(id + " is not an array");
			int type2, size2;
			if( Expression(type2, size2) ){
				if( (size2 > 1) || ( (type2 != TYPE_INTEGER) && (type2 != TYPE_FLOAT) && (type2 != TYPE_BOOL) ) )
					ReportError("Array index must be a scalar numeric value.");
				size = 0;
				if( CheckToken(T_RBRACKET) ){
					// Save the variable <name> values in the generator to be used for arguments
					generator->setArgument( nameValue, isGlobal, 0, true );
					
					// MM to REG for specific array element in IN/INOUT argument
					if( !outArg ) generator->mm2reg(type, size, nameValue.FPoffset, isGlobal, -1, true, type2);
					
					return true;
				}
				else ReportError("Expected ']' after expression in name.");
			}
			else ReportFatalError("Expected expression between brackets.");
		}
		else{
			// Save the variable <name> values in the generator to be used for arguments
			generator->setArgument( nameValue, isGlobal);
			
			// MM to REG for scalars / full arrays that are IN/INOUT arguments
			 if( !outArg ) generator->mm2reg(type, size, nameValue.FPoffset, isGlobal);				
			return true;

		}
	}
	else return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdx, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r15
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
xorl %eax, %eax
movq %rax, -0x8(%r14)
movb %al, (%r14)
leaq 0x80(%rsp), %r13
movq %rax, -0x18(%r13)
xorps %xmm0, %xmm0
movups %xmm0, -0x28(%r13)
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0x28(%rsp), %rsi
callq 0x6a86
movl %eax, %ebx
leaq 0x58(%rsp), %r12
testb %al, %al
je 0xd799
movq 0x90(%r15), %r14
leaq 0x128(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x118(%rsp), %rdi
callq 0x3ba4
leaq 0x118(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0xf(%rsp), %rcx
movq %r14, %rdi
callq 0xff4c
movl %eax, %ebp
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0xd2d8
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x2200
testb %bpl, %bpl
je 0xd35c
movl 0x50(%rsp), %eax
cmpl $0x11e, %eax            # imm = 0x11E
jne 0xd3db
leaq 0xe8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x3ba4
leaq 0xd317(%rip), %rsi      # 0x1a630
leaq 0xd8(%rsp), %rdi
callq 0x2380
leaq 0xd8(%rsp), %rsi
movq %r15, %rdi
callq 0x5696
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd3ed
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xd3ed
leaq 0xc8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x3ba4
leaq 0xd2d6(%rip), %rsi      # 0x1a65f
leaq 0xb8(%rsp), %rdi
callq 0x2380
leaq 0xb8(%rsp), %rsi
movq %r15, %rdi
callq 0x5696
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd3c3
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
movq 0x20(%rsp), %rax
movl $0x15e, (%rax)          # imm = 0x15E
jmp 0xd3ed
movl 0x54(%rsp), %ecx
movq 0x10(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x20(%rsp), %rcx
movl %eax, (%rcx)
movq %r15, %rdi
movl $0x135, %esi            # imm = 0x135
callq 0x5c0a
testb %al, %al
je 0xd625
cmpl $0x0, 0x54(%rsp)
jne 0xd47a
cmpl $0x11e, 0x50(%rsp)      # imm = 0x11E
je 0xd47a
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x3ba4
leaq 0xd245(%rip), %rsi      # 0x1a685
leaq 0x98(%rsp), %rdi
callq 0x2380
leaq 0x98(%rsp), %rsi
movq %r15, %rdi
callq 0x5696
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0xd47a
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x1c(%rsp), %rsi
leaq 0x4c(%rsp), %rdx
movq %r15, %rdi
callq 0x8632
testb %al, %al
je 0xd7e6
cmpl $0x1, 0x4c(%rsp)
jg 0xd4a9
movl $0xfffffef3, %eax       # imm = 0xFFFFFEF3
addl 0x1c(%rsp), %eax
cmpl $-0x4, %eax
ja 0xd4fd
leaq 0x108(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xd1da(%rip), %rsi      # 0x1a696
leaq 0xd1fe(%rip), %rdx      # 0x1a6c1
leaq 0xf8(%rsp), %rdi
callq 0x3c34
leaq 0xf8(%rsp), %rsi
movq %r15, %rdi
callq 0x5696
movq 0xf8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd4fd
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
movq %r15, %rdi
movl $0x136, %esi            # imm = 0x136
callq 0x5c0a
testb %al, %al
je 0xd740
movq 0x98(%r15), %r14
movq 0x50(%rsp), %rax
leaq 0x1c8(%rsp), %rbp
movq %rax, -0x8(%rbp)
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
callq 0xe0e0
leaq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
callq 0x3ba4
movq 0x90(%rsp), %rax
leaq 0x1c0(%rsp), %rsi
movq %rax, 0x40(%rsi)
movzbl 0xf(%rsp), %edx
movq %r14, %rdi
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x168ae
movq 0x1e0(%rsp), %rdi
cmpq %r12, %rdi
je 0xd5af
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbp, %rdi
callq 0xdea4
cmpb $0x0, 0x7c(%r15)
leaq 0x58(%rsp), %r12
jne 0xd794
movq 0x98(%r15), %rsi
movq 0x20(%rsp), %rax
movl (%rax), %edx
movq 0x10(%rsp), %rax
movl (%rax), %ecx
movl 0x94(%rsp), %r8d
movzbl 0xf(%rsp), %r9d
movl 0x1c(%rsp), %eax
leaq 0x228(%rsp), %rdi
pushq $0x0
pushq %rax
pushq $0x1
pushq $-0x1
callq 0x139f8
addq $0x20, %rsp
leaq 0x238(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
leaq 0x58(%rsp), %r12
jne 0xd789
jmp 0xd794
movq 0x98(%r15), %r14
movq 0x50(%rsp), %rax
leaq 0x180(%rsp), %rbp
movq %rax, -0x8(%rbp)
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
callq 0xe0e0
leaq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
callq 0x3ba4
movq 0x90(%rsp), %rax
leaq 0x178(%rsp), %rsi
movq %rax, 0x40(%rsi)
movzbl 0xf(%rsp), %edx
movq %r14, %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
callq 0x168ae
movq 0x198(%rsp), %rdi
cmpq %r12, %rdi
leaq 0x38(%rsp), %r14
je 0xd6bc
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbp, %rdi
callq 0xdea4
cmpb $0x0, 0x7c(%r15)
leaq 0x58(%rsp), %r12
jne 0xd799
movq 0x98(%r15), %rsi
movq 0x20(%rsp), %rax
movl (%rax), %edx
movq 0x10(%rsp), %rax
movl (%rax), %ecx
movl 0x94(%rsp), %r8d
movzbl 0xf(%rsp), %r9d
xorl %eax, %eax
leaq 0x208(%rsp), %rdi
pushq %rax
pushq $0x10a                  # imm = 0x10A
pushq %rax
pushq $-0x1
callq 0x139f8
addq $0x20, %rsp
leaq 0x218(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0x38(%rsp), %r14
leaq 0x58(%rsp), %r12
je 0xd799
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xd799
leaq 0x148(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xcf6f(%rip), %rsi      # 0x1a6c2
leaq 0xcf8e(%rip), %rdx      # 0x1a6e8
leaq 0x138(%rsp), %rdi
callq 0x3c34
leaq 0x138(%rsp), %rsi
movq %r15, %rdi
callq 0x5696
leaq 0x58(%rsp), %r12
movq 0x138(%rsp), %rdi
cmpq %r14, %rdi
je 0xd794
movq (%r14), %rsi
incq %rsi
callq 0x2200
leaq 0x38(%rsp), %r14
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0xd7b3
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2200
movq %r12, %rdi
callq 0xdea4
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0xd7d2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2200
movl %ebx, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x168(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xcef0(%rip), %rsi      # 0x1a6e9
leaq 0xcf0e(%rip), %rdx      # 0x1a70e
leaq 0x158(%rsp), %rdi
callq 0x3c34
leaq 0x158(%rsp), %rsi
movq %r15, %rdi
callq 0x49ee
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
jmp 0xd8e8
movq %rax, %rbx
movq 0x138(%rsp), %rdi
cmpq %r14, %rdi
je 0xd941
movq 0x148(%rsp), %rsi
jmp 0xd930
jmp 0xd8ef
jmp 0xd93e
movq %rax, %rbx
movq 0x158(%rsp), %rdi
cmpq %r14, %rdi
je 0xd941
movq 0x168(%rsp), %rsi
jmp 0xd930
jmp 0xd93e
jmp 0xd880
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0xd941
movq 0xa8(%rsp), %rsi
jmp 0xd930
jmp 0xd8a3
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd941
movq 0xe8(%rsp), %rsi
jmp 0xd930
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd941
movq 0x108(%rsp), %rsi
jmp 0xd930
jmp 0xd93e
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0xde7a
jmp 0xd941
movq %rax, %rbx
movq %rbp, %rdi
callq 0xdea4
jmp 0xd941
jmp 0xd8fe
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd941
movq 0xc8(%rsp), %rsi
jmp 0xd930
movq %rax, %rbx
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0xd941
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xd941
jmp 0xd93e
jmp 0xd93e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xde7a
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xd967
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2330
nop