// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %r14
xorl %eax, %eax
leaq 0xb0(%rsp), %r12
movq %rax, -0x18(%r12)
xorps %xmm0, %xmm0
movups %xmm0, -0x28(%r12)
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb $0x0, (%r12)
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 0xa7a8
addq $0x20, %rsp
movl %eax, %ebx
testb %al, %al
je 0xa6a1
movq %r14, %rdi
movl $0x13a, %esi            # imm = 0x13A
callq 0x5c08
testb %al, %al
je 0xa5fd
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x858a
movl 0x1c(%rsp), %ebp
cmpb $0x0, 0xb(%rsp)
je 0xa634
cmpl $0x1, %ebp
jg 0xa5e6
movl 0x10(%rsp), %eax
cmpl $0x2, %eax
jl 0xa5e6
cmpl %ebp, %eax
je 0xa5e6
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xf52d(%rip), %rsi      # 0x19ade
leaq 0xf567(%rip), %rdx      # 0x19b1f
leaq 0x40(%rsp), %rdi
callq 0x3c42
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x5694
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0xa5e6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2200
movl 0x14(%rsp), %eax
movl 0xc(%rsp), %r15d
cmpl %r15d, %eax
jne 0xa6de
movl %eax, %r15d
jmp 0xa639
leaq 0x70(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xf54d(%rip), %rsi      # 0x19b5a
leaq 0xf587(%rip), %rdx      # 0x19b9b
leaq 0x60(%rsp), %rdi
callq 0x3c42
leaq 0x60(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x4e96
movq 0x60(%rsp), %rdi
jmp 0xa691
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 0x14b12
addq $0x30, %rsp
leaq 0xd8(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0xa6a1
movq (%r15), %rsi
incq %rsi
callq 0x2200
leaq 0x88(%rsp), %r14
movq 0x18(%r14), %rdi
cmpq %r12, %rdi
je 0xa6c2
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x2200
movq %r14, %rdi
callq 0xdda4
movl %ebx, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
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 0xa639
leaq 0x30(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xf418(%rip), %rsi      # 0x19b20
leaq 0xf44a(%rip), %rdx      # 0x19b59
leaq 0x20(%rsp), %rdi
callq 0x3c42
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x5694
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0xa639
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xa639
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0xa793
movq 0x30(%rsp), %rsi
jmp 0xa784
jmp 0xa790
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0xa793
movq 0x50(%rsp), %rsi
jmp 0xa784
jmp 0xa790
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0xa793
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xa793
jmp 0xa790
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xdd7a
movq %rbx, %rdi
callq 0x2330