// File: lhydave[P]SysYCompilerLab/back/no_alloc.cpp
// Function: no_alloc::gen_assign(std::shared_ptr<eeyore_AST::op_node> const&, std::shared_ptr<eeyore_AST::op_node> const&)
void gen_assign(
	const shared_ptr<op_node> &lval, const shared_ptr<op_node> &rval)
{
	if (lval->exp_type == EXP_ARRAY) // store
	{
		gen_array(lval, 1, 2);
		string left = temp_prefix + to_string(1) + "[0]";
		auto right = alloc_temp_reg(rval, 2);
		tigger_dst << emit_exp_assign(left, right);
		return;
	}
	auto var = std::static_pointer_cast<var_node>(lval);
	string left = temp_prefix + to_string(1);
	gen_assign(left, rval);
	dealloc_temp_reg(lval, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x42390
cmpl $0x2, 0x8(%rax)
jne 0x3fc00
movq -0x8(%rbp), %rdi
movl $0x1, %esi
movl %esi, -0x11c(%rbp)
movl $0x2, %edx
callq 0x410f0
movl -0x11c(%rbp), %esi
leaq -0x70(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x13410
movq -0x118(%rbp), %rdx
leaq 0x3302d(%rip), %rsi     # 0x72b10
leaq -0x50(%rbp), %rdi
callq 0x42130
jmp 0x3faee
leaq 0xefe7(%rip), %rdx      # 0x4eadc
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x12d10
jmp 0x3fb04
leaq -0x50(%rbp), %rdi
callq 0x56c0
leaq -0x70(%rbp), %rdi
callq 0x56c0
movq -0x10(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
movl $0x2, %edx
callq 0x40a50
jmp 0x3fb2d
leaq -0xc0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x34ea0
jmp 0x3fb46
leaq 0x3296b(%rip), %rdi     # 0x724b8
leaq -0xc0(%rbp), %rsi
callq 0x52b0
jmp 0x3fb5b
leaq -0xc0(%rbp), %rdi
callq 0x56c0
leaq -0xa0(%rbp), %rdi
callq 0x56c0
leaq -0x30(%rbp), %rdi
callq 0x56c0
jmp 0x3fc85
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x3fba4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x56c0
leaq -0x70(%rbp), %rdi
callq 0x56c0
jmp 0x3fcda
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x3fbf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x3fbe6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x56c0
leaq -0xa0(%rbp), %rdi
callq 0x56c0
leaq -0x30(%rbp), %rdi
callq 0x56c0
jmp 0x3fcda
movq -0x8(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x42460
leaq -0x110(%rbp), %rdi
movl $0x1, %esi
callq 0x13410
jmp 0x3fc23
leaq 0x32ee6(%rip), %rsi     # 0x72b10
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rdx
callq 0x42130
jmp 0x3fc3f
leaq -0x110(%rbp), %rdi
callq 0x56c0
movq -0x10(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x404d0
jmp 0x3fc5d
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x415f0
jmp 0x3fc6d
leaq -0xf0(%rbp), %rdi
callq 0x56c0
leaq -0xd0(%rbp), %rdi
callq 0x2b0a0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x3fcce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x56c0
jmp 0x3fcce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x56c0
leaq -0xd0(%rbp), %rdi
callq 0x2b0a0
movq -0x78(%rbp), %rdi
callq 0x5610
nopw %cs:(%rax,%rax)