// File: lhydave[P]SysYCompilerLab/back/no_alloc.cpp
// Function: no_alloc::gen_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::shared_ptr<eeyore_AST::op_node> const&)
void gen_assign(const string &lval, const shared_ptr<op_node> &rval)
{
	if (rval->exp_type == EXP_NUM) // number!
	{
		auto rnum = std::static_pointer_cast<num_node>(rval);
		tigger_dst << emit_exp_assign(lval, to_string(rnum->val));
		return;
	}
	if (rval->exp_type == EXP_VAR) // variable!
	{
		auto rreg = alloc_temp_reg(rval, 2);
		tigger_dst << emit_exp_assign(lval, rreg);
		return;
	}
	if (rval->exp_type == EXP_ARRAY) // array!
	{
		gen_array(rval, 2, 3);
		string right = temp_prefix + to_string(2) + "[0]";
		tigger_dst << emit_exp_assign(lval, right);
		return;
	}
	if (rval->exp_type == EXP_CALL) // call!
	{
		gen_call(std::static_pointer_cast<call_node>(rval), lval);
		return;
	}
	if (!rval->right) // unary operator
	{
		gen_unary(rval, 2);
		tigger_dst << emit_exp_assign(lval, temp_prefix + to_string(2));
		return;
	}
	// binary operator
	gen_binary(rval, 2, 3);
	tigger_dst << emit_exp_assign(lval, temp_prefix + to_string(2));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x42390
cmpl $0x4, 0x8(%rax)
jne 0x405bf
movq -0x10(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x423b0
movq -0x210(%rbp), %rdi
movq -0x8(%rbp), %rax
movq %rax, -0x208(%rbp)
callq 0x42400
movl 0x50(%rax), %esi
leaq -0x60(%rbp), %rdi
callq 0x13410
jmp 0x4052f
movq -0x208(%rbp), %rsi
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x34ea0
jmp 0x40545
leaq 0x31f6c(%rip), %rdi     # 0x724b8
leaq -0x40(%rbp), %rsi
callq 0x52b0
jmp 0x40557
leaq -0x40(%rbp), %rdi
callq 0x56c0
leaq -0x60(%rbp), %rdi
callq 0x56c0
leaq -0x20(%rbp), %rdi
callq 0x2afe0
jmp 0x409ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x405b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x405a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x56c0
leaq -0x60(%rbp), %rdi
callq 0x56c0
leaq -0x20(%rbp), %rdi
callq 0x2afe0
jmp 0x40a43
movq -0x10(%rbp), %rdi
callq 0x42390
cmpl $0x1, 0x8(%rax)
jne 0x40670
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdi
movq %rdi, -0x218(%rbp)
movl $0x2, %edx
callq 0x40a50
movq -0x218(%rbp), %rdx
movq -0x8(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x34ea0
jmp 0x40607
leaq 0x31eaa(%rip), %rdi     # 0x724b8
leaq -0xb0(%rbp), %rsi
callq 0x52b0
jmp 0x4061c
leaq -0xb0(%rbp), %rdi
callq 0x56c0
leaq -0x90(%rbp), %rdi
callq 0x56c0
jmp 0x409ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x4065f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x56c0
leaq -0x90(%rbp), %rdi
callq 0x56c0
jmp 0x40a43
movq -0x10(%rbp), %rdi
callq 0x42390
cmpl $0x2, 0x8(%rax)
jne 0x407be
movq -0x10(%rbp), %rdi
movl $0x2, %esi
movl %esi, -0x224(%rbp)
movl $0x3, %edx
callq 0x410f0
movl -0x224(%rbp), %esi
leaq -0x110(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x13410
movq -0x220(%rbp), %rdx
leaq 0x3244d(%rip), %rsi     # 0x72b10
leaq -0xf0(%rbp), %rdi
callq 0x42130
jmp 0x406d1
leaq 0xe404(%rip), %rdx      # 0x4eadc
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x12d10
jmp 0x406ed
leaq -0xf0(%rbp), %rdi
callq 0x56c0
leaq -0x110(%rbp), %rdi
callq 0x56c0
movq -0x8(%rbp), %rsi
leaq -0x130(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
callq 0x34ea0
jmp 0x4071e
leaq 0x31d93(%rip), %rdi     # 0x724b8
leaq -0x130(%rbp), %rsi
callq 0x52b0
jmp 0x40733
leaq -0x130(%rbp), %rdi
callq 0x56c0
leaq -0xd0(%rbp), %rdi
callq 0x56c0
jmp 0x409ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x40776
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x56c0
leaq -0x110(%rbp), %rdi
callq 0x56c0
jmp 0x40a43
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x407ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x56c0
leaq -0xd0(%rbp), %rdi
callq 0x56c0
jmp 0x40a43
movq -0x10(%rbp), %rdi
callq 0x42390
cmpl $0x5, 0x8(%rax)
jne 0x40824
movq -0x10(%rbp), %rsi
leaq -0x140(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x424b0
movq -0x230(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x40300
jmp 0x407f6
leaq -0x140(%rbp), %rdi
callq 0x2c7e0
jmp 0x409ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x2c7e0
jmp 0x40a43
movq -0x10(%rbp), %rdi
callq 0x42390
movq %rax, %rdi
addq $0x40, %rdi
callq 0x42370
testb $0x1, %al
jne 0x40940
movq -0x10(%rbp), %rdi
movl $0x2, %esi
movl %esi, -0x244(%rbp)
callq 0x41a00
movl -0x244(%rbp), %esi
movq -0x8(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x13410
movq -0x238(%rbp), %rdx
leaq 0x32289(%rip), %rsi     # 0x72b10
leaq -0x180(%rbp), %rdi
callq 0x42130
jmp 0x40895
movq -0x240(%rbp), %rsi
leaq -0x160(%rbp), %rdi
leaq -0x180(%rbp), %rdx
callq 0x34ea0
jmp 0x408b1
leaq 0x31c00(%rip), %rdi     # 0x724b8
leaq -0x160(%rbp), %rsi
callq 0x52b0
jmp 0x408c6
leaq -0x160(%rbp), %rdi
callq 0x56c0
leaq -0x180(%rbp), %rdi
callq 0x56c0
leaq -0x1a0(%rbp), %rdi
callq 0x56c0
jmp 0x409ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x4092f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x40923
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x56c0
leaq -0x180(%rbp), %rdi
callq 0x56c0
leaq -0x1a0(%rbp), %rdi
callq 0x56c0
jmp 0x40a43
movq -0x10(%rbp), %rdi
movl $0x2, %esi
movl %esi, -0x25c(%rbp)
movl $0x3, %edx
callq 0x41af0
movl -0x25c(%rbp), %esi
movq -0x8(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq -0x200(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x13410
movq -0x250(%rbp), %rdx
leaq 0x32185(%rip), %rsi     # 0x72b10
leaq -0x1e0(%rbp), %rdi
callq 0x42130
jmp 0x40999
movq -0x258(%rbp), %rsi
leaq -0x1c0(%rbp), %rdi
leaq -0x1e0(%rbp), %rdx
callq 0x34ea0
jmp 0x409b5
leaq 0x31afc(%rip), %rdi     # 0x724b8
leaq -0x1c0(%rbp), %rsi
callq 0x52b0
jmp 0x409ca
leaq -0x1c0(%rbp), %rdi
callq 0x56c0
leaq -0x1e0(%rbp), %rdi
callq 0x56c0
leaq -0x200(%rbp), %rdi
callq 0x56c0
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x40a37
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x40a2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x56c0
leaq -0x1e0(%rbp), %rdi
callq 0x56c0
leaq -0x200(%rbp), %rdi
callq 0x56c0
movq -0x68(%rbp), %rdi
callq 0x5610
nopl (%rax)