// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %r14
xorl %eax, %eax
leaq 0xb0(%rsp), %r15
movq %rax, -0x18(%r15)
xorps %xmm0, %xmm0
movups %xmm0, -0x28(%r15)
movq %r15, -0x10(%r15)
movq %rax, -0x8(%r15)
movb $0x0, (%r15)
subq $0x8, %rsp
leaq 0x24(%rsp), %rax
leaq 0x11(%rsp), %r10
leaq 0x12(%rsp), %r11
leaq 0x18(%rsp), %rdx
leaq 0x14(%rsp), %rcx
leaq 0x88(%rsp), %r8
leaq 0x13(%rsp), %r9
pushq %rax
pushq %r10
pushq %r11
callq 0xa830
addq $0x20, %rsp
movl %eax, %ebx
testb %al, %al
je 0xa793
movq %r14, %rdi
movl $0x13a, %esi            # imm = 0x13A
callq 0x5c0a
testb %al, %al
je 0xa74c
leaq 0x18(%rsp), %rsi
leaq 0x14(%rsp), %rdx
movq %r14, %rdi
callq 0x8632
cmpb $0x1, 0xb(%rsp)
jne 0xa6ee
movl 0xc(%rsp), %eax
cmpl $0x1, %eax
jg 0xa689
movl 0x14(%rsp), %ecx
cmpl $0x2, %ecx
jl 0xa689
cmpl %eax, %ecx
je 0xa689
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xf48a(%rip), %rsi      # 0x19ade
leaq 0xf4c4(%rip), %rdx      # 0x19b1f
leaq 0x40(%rsp), %rdi
callq 0x3c34
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x5696
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0xa689
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2200
movl 0x18(%rsp), %eax
movl 0x10(%rsp), %ecx
cmpl %ecx, %eax
je 0xa6ee
andl $-0x2, %ecx
movl $0x10a, %edx            # imm = 0x10A
xorl %edx, %ecx
andl $-0x2, %eax
xorl %edx, %eax
orl %ecx, %eax
je 0xa6ee
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xf467(%rip), %rsi      # 0x19b20
leaq 0xf499(%rip), %rdx      # 0x19b59
leaq 0x20(%rsp), %rdi
callq 0x3c34
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x5696
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0xa6ee
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x98(%r14), %rsi
movl 0x18(%rsp), %edx
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %r8d
movl 0xc(%rsp), %r9d
movl 0xc4(%rsp), %eax
movzbl 0xa(%rsp), %r10d
movzbl 0x9(%rsp), %r11d
movl 0x1c(%rsp), %r14d
subq $0x8, %rsp
leaq 0xd0(%rsp), %rdi
pushq $0x0
pushq %r14
pushq %r11
pushq %r10
pushq %rax
callq 0x14bfc
addq $0x30, %rsp
leaq 0xd8(%rsp), %r12
movq -0x10(%r12), %rdi
jmp 0xa782
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xf3fd(%rip), %rsi      # 0x19b5a
leaq 0xf437(%rip), %rdx      # 0x19b9b
leaq 0x60(%rsp), %rdi
callq 0x3c34
leaq 0x60(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x4e82
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0xa793
movq (%r12), %rsi
incq %rsi
callq 0x2200
leaq 0x88(%rsp), %r14
movq 0x18(%r14), %rdi
cmpq %r15, %rdi
je 0xa7b4
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x2200
movq %r14, %rdi
callq 0xdea4
movl %ebx, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0xa81a
movq 0x30(%rsp), %rsi
jmp 0xa80b
jmp 0xa817
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0xa81a
movq 0x50(%rsp), %rsi
jmp 0xa80b
jmp 0xa817
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0xa81a
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xa81a
jmp 0xa817
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xde7a
movq %rbx, %rdi
callq 0x2330
nop