// File: /workspace/github_cpp_makefile_star2_O3/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 0x6a76
movl %eax, %ebx
leaq 0x58(%rsp), %r12
testb %al, %al
je 0xd699
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 0x3bac
leaq 0x118(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0xf(%rsp), %rcx
movq %r14, %rdi
callq 0xfeaa
movl %eax, %ebp
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0xd1d8
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x2200
testb %bpl, %bpl
je 0xd25c
movl 0x50(%rsp), %eax
cmpl $0x11e, %eax            # imm = 0x11E
jne 0xd2db
leaq 0xe8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x3bac
leaq 0xd417(%rip), %rsi      # 0x1a630
leaq 0xd8(%rsp), %rdi
callq 0x2380
leaq 0xd8(%rsp), %rsi
movq %r15, %rdi
callq 0x5694
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd2ed
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xd2ed
leaq 0xc8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x3bac
leaq 0xd3d6(%rip), %rsi      # 0x1a65f
leaq 0xb8(%rsp), %rdi
callq 0x2380
leaq 0xb8(%rsp), %rsi
movq %r15, %rdi
callq 0x5694
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd2c3
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 0xd2ed
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 0x5c08
testb %al, %al
je 0xd525
cmpl $0x0, 0x54(%rsp)
jne 0xd37a
cmpl $0x11e, 0x50(%rsp)      # imm = 0x11E
je 0xd37a
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x3bac
leaq 0xd345(%rip), %rsi      # 0x1a685
leaq 0x98(%rsp), %rdi
callq 0x2380
leaq 0x98(%rsp), %rsi
movq %r15, %rdi
callq 0x5694
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0xd37a
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x1c(%rsp), %rsi
leaq 0x4c(%rsp), %rdx
movq %r15, %rdi
callq 0x858a
testb %al, %al
je 0xd6e6
cmpl $0x1, 0x4c(%rsp)
jg 0xd3a9
movl $0xfffffef3, %eax       # imm = 0xFFFFFEF3
addl 0x1c(%rsp), %eax
cmpl $-0x4, %eax
ja 0xd3fd
leaq 0x108(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xd2da(%rip), %rsi      # 0x1a696
leaq 0xd2fe(%rip), %rdx      # 0x1a6c1
leaq 0xf8(%rsp), %rdi
callq 0x3c42
leaq 0xf8(%rsp), %rsi
movq %r15, %rdi
callq 0x5694
movq 0xf8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd3fd
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
movq %r15, %rdi
movl $0x136, %esi            # imm = 0x136
callq 0x5c08
testb %al, %al
je 0xd640
movq 0x98(%r15), %r14
movq 0x50(%rsp), %rax
leaq 0x1c8(%rsp), %rbp
movq %rax, -0x8(%rbp)
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
callq 0xdfee
leaq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
callq 0x3bac
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 0x167d0
movq 0x1e0(%rsp), %rdi
cmpq %r12, %rdi
je 0xd4af
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbp, %rdi
callq 0xdda4
cmpb $0x0, 0x7c(%r15)
leaq 0x58(%rsp), %r12
jne 0xd694
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 0x13912
addq $0x20, %rsp
leaq 0x238(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
leaq 0x58(%rsp), %r12
jne 0xd689
jmp 0xd694
movq 0x98(%r15), %r14
movq 0x50(%rsp), %rax
leaq 0x180(%rsp), %rbp
movq %rax, -0x8(%rbp)
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
callq 0xdfee
leaq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
callq 0x3bac
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 0x167d0
movq 0x198(%rsp), %rdi
cmpq %r12, %rdi
leaq 0x38(%rsp), %r14
je 0xd5bc
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbp, %rdi
callq 0xdda4
cmpb $0x0, 0x7c(%r15)
leaq 0x58(%rsp), %r12
jne 0xd699
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 0x13912
addq $0x20, %rsp
leaq 0x218(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0x38(%rsp), %r14
leaq 0x58(%rsp), %r12
je 0xd699
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xd699
leaq 0x148(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xd06f(%rip), %rsi      # 0x1a6c2
leaq 0xd08e(%rip), %rdx      # 0x1a6e8
leaq 0x138(%rsp), %rdi
callq 0x3c42
leaq 0x138(%rsp), %rsi
movq %r15, %rdi
callq 0x5694
leaq 0x58(%rsp), %r12
movq 0x138(%rsp), %rdi
cmpq %r14, %rdi
je 0xd694
movq (%r14), %rsi
incq %rsi
callq 0x2200
leaq 0x38(%rsp), %r14
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0xd6b3
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2200
movq %r12, %rdi
callq 0xdda4
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0xd6d2
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 0xcff0(%rip), %rsi      # 0x1a6e9
leaq 0xd00e(%rip), %rdx      # 0x1a70e
leaq 0x158(%rsp), %rdi
callq 0x3c42
leaq 0x158(%rsp), %rsi
movq %r15, %rdi
callq 0x4a02
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
jmp 0xd7e8
movq %rax, %rbx
movq 0x138(%rsp), %rdi
cmpq %r14, %rdi
je 0xd841
movq 0x148(%rsp), %rsi
jmp 0xd830
jmp 0xd7ef
jmp 0xd83e
movq %rax, %rbx
movq 0x158(%rsp), %rdi
cmpq %r14, %rdi
je 0xd841
movq 0x168(%rsp), %rsi
jmp 0xd830
jmp 0xd83e
jmp 0xd780
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0xd841
movq 0xa8(%rsp), %rsi
jmp 0xd830
jmp 0xd7a3
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd841
movq 0xe8(%rsp), %rsi
jmp 0xd830
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd841
movq 0x108(%rsp), %rsi
jmp 0xd830
jmp 0xd83e
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0xdd7a
jmp 0xd841
movq %rax, %rbx
movq %rbp, %rdi
callq 0xdda4
jmp 0xd841
jmp 0xd7fe
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0xd841
movq 0xc8(%rsp), %rsi
jmp 0xd830
movq %rax, %rbx
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0xd841
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xd841
jmp 0xd83e
jmp 0xd83e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xdd7a
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xd867
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2330
nop