// File: /workspace/github_cpp_makefile_star2_O2/AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::Assignment(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool Parser::Assignment(string &id){
	int type, size, dType, dSize;
	bool found;
	scopeValue destinationValue;
	bool isGlobal;
	bool indirect;
	int indirect_type;
	
	//Determine destination if this is a valid assignment statement
	if( !Destination(id, dType, dSize, destinationValue, found, isGlobal, indirect, indirect_type) ) return false;
	
	//get assignment expression
	if( CheckToken(T_ASSIGNMENT) ){
		Expression(type, size);

		if(found){
			if(size != dSize && (size > 1) && (dSize <= 1)) ReportError("Bad assignment, size of expression must match destination's size.");
			if( (type != dType) && ( (!isNumber(dType)) || (!isNumber(type)) ) ) ReportError("Bad assignment, type of expression must match destination");
		}
		// Move expression result from register(s) to MM using one of the various addressing modes.
		generator->reg2mm( type, dType, size, dSize, destinationValue.FPoffset, isGlobal, indirect, indirect_type );
		return true;
	}
	else{
		ReportLineError("Bad line. Expected ':=' after destination in assignment statement", false);
		return true;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rax
movups %xmm0, -0x28(%rax)
andq $0x0, -0x18(%rax)
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
subq $0x8, %rsp
leaq 0x20(%rsp), %rax
leaq 0x11(%rsp), %r10
leaq 0x12(%rsp), %r11
leaq 0x14(%rsp), %rdx
leaq 0x24(%rsp), %rcx
leaq 0x88(%rsp), %r8
leaq 0x13(%rsp), %r9
pushq %rax
pushq %r10
pushq %r11
callq 0x7a70
addq $0x20, %rsp
movl %eax, %ebx
testb %al, %al
je 0x79c6
movq %r14, %rdi
movl $0x13a, %esi            # imm = 0x13A
callq 0x49b0
testb %al, %al
je 0x793c
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x64cc
movl 0x1c(%rsp), %ebp
cmpb $0x0, 0xb(%rsp)
je 0x7968
cmpl $0x1, %ebp
jg 0x7925
movl 0x10(%rsp), %eax
cmpl $0x2, %eax
jl 0x7925
cmpl %ebp, %eax
je 0x7925
leaq 0xa1df(%rip), %rsi      # 0x11ade
leaq 0x60(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x36b8
leaq 0x60(%rsp), %rsi
movq %r14, %rdi
callq 0x47e0
leaq 0x60(%rsp), %rdi
callq 0x20f0
movl 0x14(%rsp), %eax
movl 0xc(%rsp), %r15d
cmpl %r15d, %eax
jne 0x79e3
movl %eax, %r15d
jmp 0x796d
leaq 0xa217(%rip), %rsi      # 0x11b5a
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x36b8
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x444c
leaq 0x20(%rsp), %rdi
jmp 0x79c1
movl 0xc(%rsp), %r15d
movq 0x98(%r14), %rsi
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %r8d
movl 0xc4(%rsp), %eax
movzbl 0xa(%rsp), %r10d
movzbl 0x9(%rsp), %r11d
movl 0x18(%rsp), %r14d
subq $0x8, %rsp
leaq 0xd0(%rsp), %rdi
movl %r15d, %ecx
movl %ebp, %r9d
pushq $0x0
pushq %r14
pushq %r11
pushq %r10
pushq %rax
callq 0xe322
addq $0x30, %rsp
leaq 0xc8(%rsp), %rdi
callq 0x20f0
leaq 0x80(%rsp), %rdi
callq 0x9836
movl %ebx, %eax
addq $0xe8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %r15d, %ecx
andl $-0x2, %ecx
movl $0x10a, %edx            # imm = 0x10A
xorl %edx, %ecx
andl $-0x2, %eax
xorl %edx, %eax
orl %ecx, %eax
je 0x796d
leaq 0xa11c(%rip), %rsi      # 0x11b20
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x36b8
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x47e0
leaq 0x40(%rsp), %rdi
callq 0x20f0
jmp 0x796d
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x7a4f
jmp 0x7a58
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x7a4f
jmp 0x7a58
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x20f0
jmp 0x7a5b
jmp 0x7a58
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x9836
movq %rbx, %rdi
callq 0x2310