// File: AshOlogn[P]ash-language-interpreter/src/executor.cpp
// Function: executeNewAssignmentStatement(NewAssignmentStatementNode*)
void executeNewAssignmentStatement(NewAssignmentStatementNode* node) {
  
  //get stuff out of the node first
  SymbolTable* symbolTable = node->symbolTable;
  std::string variable = node->variable;
  ParseDataType type = node->type;
	ParseDataType subType = node->subType;
  
  //add variable to table
  if(node->value != NULL) {

    ParseData d = node->value->evaluate();
				
		if(type == ARRAY_T) {

			//if array, change array value's subtype to fit variable's subtype
			Array* arr = (Array*) d.value.allocated;
			arr->subtype = subType;
			symbolTable->declare(variable, d);

		} else {
			//consider implicit casting
    	symbolTable->declare(variable, castHelper(d, type));
		}

  } else {
    
    ParseData d;
    d.type = symbolTable->get(variable).type;
    symbolTable->declare(variable, castHelper(d, type));
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rsi
addq $0x18, %rsi
leaq -0x30(%rbp), %rdi
callq 0x40f0
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x2eef2
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movq %rdx, -0x160(%rbp)
movl %eax, -0x154(%rbp)
jmp 0x2ed8e
movq -0x160(%rbp), %rax
movl -0x154(%rbp), %ecx
movl %ecx, -0x48(%rbp)
movq %rax, -0x40(%rbp)
cmpl $0xc, -0x34(%rbp)
jne 0x2ee3a
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x38(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x40f0
jmp 0x2edd7
movq -0x168(%rbp), %rdi
movups -0x48(%rbp), %xmm0
movaps %xmm0, -0x90(%rbp)
movl -0x90(%rbp), %edx
movq -0x88(%rbp), %rcx
leaq -0x80(%rbp), %rsi
callq 0x2bda0
jmp 0x2ee01
leaq -0x80(%rbp), %rdi
callq 0x4170
jmp 0x2eeed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2f042
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4170
jmp 0x2f042
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x40f0
jmp 0x2ee57
movups -0x48(%rbp), %xmm0
movaps %xmm0, -0xd0(%rbp)
movl -0x34(%rbp), %edx
movl -0xd0(%rbp), %edi
movq -0xc8(%rbp), %rsi
callq 0x29c10
movq %rdx, -0x180(%rbp)
movl %eax, -0x174(%rbp)
jmp 0x2ee86
movq -0x170(%rbp), %rdi
movq -0x180(%rbp), %rax
movl -0x174(%rbp), %ecx
movl %ecx, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
movl -0xc0(%rbp), %edx
movq -0xb8(%rbp), %rcx
leaq -0xb0(%rbp), %rsi
callq 0x2bda0
jmp 0x2eec2
leaq -0xb0(%rbp), %rdi
callq 0x4170
jmp 0x2eeed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x4170
jmp 0x2f042
jmp 0x2f030
movq -0x10(%rbp), %rax
movq %rax, -0x188(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x40f0
jmp 0x2ef0f
movq -0x188(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x2c020
movq %rdx, -0x198(%rbp)
movl %eax, -0x18c(%rbp)
jmp 0x2ef31
movq -0x198(%rbp), %rax
movl -0x18c(%rbp), %ecx
movl %ecx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
movl -0xf0(%rbp), %eax
movl %eax, -0xe0(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x4170
movq -0x10(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x40f0
jmp 0x2ef80
movups -0xe0(%rbp), %xmm0
movaps %xmm0, -0x150(%rbp)
movl -0x34(%rbp), %edx
movl -0x150(%rbp), %edi
movq -0x148(%rbp), %rsi
callq 0x29c10
movq %rdx, -0x1b0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x2efb2
movq -0x1a0(%rbp), %rdi
movq -0x1b0(%rbp), %rax
movl -0x1a4(%rbp), %ecx
movl %ecx, -0x140(%rbp)
movq %rax, -0x138(%rbp)
movl -0x140(%rbp), %edx
movq -0x138(%rbp), %rcx
leaq -0x130(%rbp), %rsi
callq 0x2bda0
jmp 0x2efee
leaq -0x130(%rbp), %rdi
callq 0x4170
jmp 0x2f030
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x4170
jmp 0x2f042
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x4170
jmp 0x2f042
leaq -0x30(%rbp), %rdi
callq 0x4170
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x4170
movq -0x50(%rbp), %rdi
callq 0x4420
nopw %cs:(%rax,%rax)