// File: lhydave[P]SysYCompilerLab/back/no_alloc.cpp
// Function: no_alloc::alloc_temp_reg[abi:cxx11](std::shared_ptr<eeyore_AST::op_node> const&, int)
string alloc_temp_reg(const shared_ptr<op_node> &temp, int tempid)
{
	auto reg = temp_prefix + to_string(tempid);
	if (temp->exp_type == EXP_NUM)
	{
		tigger_dst << emit_exp_assign(
			reg, to_string(std::static_pointer_cast<num_node>(temp)->val));
		return reg;
	}
	auto var = std::static_pointer_cast<var_node>(temp);
	dbg_printf("temp reg alloc for %s\n", var->eeyore_name.c_str());
	if (is_global(var->eeyore_name)) // global
	{
		if (func_table[""].temps[var->eeyore_name].is_array) // pointer
			tigger_dst << emit_loadaddr(
				global_prefix + to_string(global_var2no[var->eeyore_name]),
				reg);
		else // variable
			tigger_dst << emit_load(
				global_prefix + to_string(global_var2no[var->eeyore_name]),
				reg);
	}
	else if (!is_param(var->eeyore_name) &&
		now_func.temps[var->eeyore_name].is_array) // array
		tigger_dst << emit_loadaddr(var2no[var->eeyore_name], reg);
	else // variable or param
		tigger_dst << emit_load(var2no[var->eeyore_name], reg);
	return reg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x1e8(%rbp)
movq %rdi, %rax
movq %rax, -0x1f0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
movl -0x14(%rbp), %esi
leaq -0x38(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x13410
movq -0x1e8(%rbp), %rdi
movq -0x1e0(%rbp), %rdx
leaq 0x3206d(%rip), %rsi     # 0x72b10
callq 0x42130
jmp 0x40aaa
leaq -0x38(%rbp), %rdi
callq 0x56c0
movq -0x10(%rbp), %rdi
callq 0x42390
cmpl $0x4, 0x8(%rax)
jne 0x40bc1
movq -0x10(%rbp), %rsi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x423b0
movq -0x1f8(%rbp), %rdi
callq 0x42400
movl 0x50(%rax), %esi
leaq -0x88(%rbp), %rdi
callq 0x13410
jmp 0x40afa
movq -0x1e8(%rbp), %rsi
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x34ea0
jmp 0x40b13
leaq 0x3199e(%rip), %rdi     # 0x724b8
leaq -0x68(%rbp), %rsi
callq 0x52b0
jmp 0x40b25
leaq -0x68(%rbp), %rdi
callq 0x56c0
leaq -0x88(%rbp), %rdi
callq 0x56c0
leaq -0x98(%rbp), %rdi
callq 0x2afe0
movb $0x1, -0x15(%rbp)
movl $0x1, -0x9c(%rbp)
jmp 0x410b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x56c0
jmp 0x410e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x40bb0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x40ba4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x56c0
leaq -0x88(%rbp), %rdi
callq 0x56c0
leaq -0x98(%rbp), %rdi
callq 0x2afe0
jmp 0x410db
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x42460
movq -0x208(%rbp), %rdi
callq 0x42500
movq %rax, %rdi
addq $0x50, %rdi
callq 0x21fd0
movb %al, -0x1f9(%rbp)
jmp 0x40bf8
movb -0x1f9(%rbp), %al
testb $0x1, %al
jne 0x40c07
jmp 0x40f18
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x5620
movq -0x210(%rbp), %rdx
leaq 0xe038(%rip), %rsi      # 0x4ec60
leaq -0xd0(%rbp), %rdi
callq 0x8780
jmp 0x40c36
leaq 0x31b73(%rip), %rdi     # 0x727b0
leaq -0xd0(%rbp), %rsi
callq 0x241f0
movq %rax, -0x218(%rbp)
jmp 0x40c52
movq -0x218(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x228(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x42500
movq -0x228(%rbp), %rdi
movq %rax, %rsi
addq $0x50, %rsi
callq 0x27e40
movq %rax, -0x220(%rbp)
jmp 0x40c8c
movq -0x220(%rbp), %rax
movb 0x24(%rax), %al
movb %al, -0x229(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x56c0
leaq -0xd1(%rbp), %rdi
callq 0x5370
movb -0x229(%rbp), %al
testb $0x1, %al
je 0x40e10
leaq -0xb0(%rbp), %rdi
callq 0x42500
movq %rax, %rsi
addq $0x50, %rsi
leaq 0x31ecc(%rip), %rdi     # 0x72ba8
callq 0x41ec0
movq %rax, -0x238(%rbp)
jmp 0x40cea
movq -0x238(%rbp), %rax
movl (%rax), %esi
leaq -0x138(%rbp), %rdi
callq 0x13410
jmp 0x40d01
leaq 0x31d68(%rip), %rsi     # 0x72a70
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rdx
callq 0x42130
jmp 0x40d1d
movq -0x1e8(%rbp), %rdx
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x35b10
jmp 0x40d39
leaq 0x31778(%rip), %rdi     # 0x724b8
leaq -0xf8(%rbp), %rsi
callq 0x52b0
jmp 0x40d4e
leaq -0xf8(%rbp), %rdi
callq 0x56c0
leaq -0x118(%rbp), %rdi
callq 0x56c0
leaq -0x138(%rbp), %rdi
callq 0x56c0
jmp 0x40f13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x410ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x40dae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x56c0
leaq -0xd1(%rbp), %rdi
callq 0x5370
jmp 0x410ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x40dff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x40df3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x56c0
leaq -0x118(%rbp), %rdi
callq 0x56c0
leaq -0x138(%rbp), %rdi
callq 0x56c0
jmp 0x410ab
leaq -0xb0(%rbp), %rdi
callq 0x42500
movq %rax, %rsi
addq $0x50, %rsi
leaq 0x31d7e(%rip), %rdi     # 0x72ba8
callq 0x41ec0
movq %rax, -0x240(%rbp)
jmp 0x40e38
movq -0x240(%rbp), %rax
movl (%rax), %esi
leaq -0x198(%rbp), %rdi
callq 0x13410
jmp 0x40e4f
leaq 0x31c1a(%rip), %rsi     # 0x72a70
leaq -0x178(%rbp), %rdi
leaq -0x198(%rbp), %rdx
callq 0x42130
jmp 0x40e6b
movq -0x1e8(%rbp), %rdx
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x35780
jmp 0x40e87
leaq 0x3162a(%rip), %rdi     # 0x724b8
leaq -0x158(%rbp), %rsi
callq 0x52b0
jmp 0x40e9c
leaq -0x158(%rbp), %rdi
callq 0x56c0
leaq -0x178(%rbp), %rdi
callq 0x56c0
leaq -0x198(%rbp), %rdi
callq 0x56c0
jmp 0x40f13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x40f02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x40ef6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x56c0
leaq -0x178(%rbp), %rdi
callq 0x56c0
leaq -0x198(%rbp), %rdi
callq 0x56c0
jmp 0x410ab
jmp 0x4108f
leaq -0xb0(%rbp), %rdi
callq 0x42500
movq %rax, %rdi
addq $0x50, %rdi
callq 0x22090
movb %al, -0x241(%rbp)
jmp 0x40f38
movb -0x241(%rbp), %al
testb $0x1, %al
jne 0x4100a
jmp 0x40f48
leaq -0xb0(%rbp), %rdi
callq 0x42500
movq %rax, %rsi
addq $0x50, %rsi
leaq 0x31bee(%rip), %rdi     # 0x72b50
callq 0x27e40
movq %rax, -0x250(%rbp)
jmp 0x40f70
movq -0x250(%rbp), %rax
testb $0x1, 0x24(%rax)
je 0x4100a
leaq -0xb0(%rbp), %rdi
callq 0x42500
movq %rax, %rsi
addq $0x50, %rsi
leaq 0x31c45(%rip), %rdi     # 0x72be0
callq 0x41ec0
movq %rax, -0x258(%rbp)
jmp 0x40fa9
movq -0x1e8(%rbp), %rdx
movq -0x258(%rbp), %rax
movl (%rax), %esi
leaq -0x1b8(%rbp), %rdi
callq 0x35ca0
jmp 0x40fc7
leaq 0x314ea(%rip), %rdi     # 0x724b8
leaq -0x1b8(%rbp), %rsi
callq 0x52b0
jmp 0x40fdc
leaq -0x1b8(%rbp), %rdi
callq 0x56c0
jmp 0x4108d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x56c0
jmp 0x410ab
leaq -0xb0(%rbp), %rdi
callq 0x42500
movq %rax, %rsi
addq $0x50, %rsi
leaq 0x31bbc(%rip), %rdi     # 0x72be0
callq 0x41ec0
movq %rax, -0x260(%rbp)
jmp 0x41032
movq -0x1e8(%rbp), %rdx
movq -0x260(%rbp), %rax
movl (%rax), %esi
leaq -0x1d8(%rbp), %rdi
callq 0x35910
jmp 0x41050
leaq 0x31461(%rip), %rdi     # 0x724b8
leaq -0x1d8(%rbp), %rsi
callq 0x52b0
jmp 0x41065
leaq -0x1d8(%rbp), %rdi
callq 0x56c0
jmp 0x4108d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x56c0
jmp 0x410ab
jmp 0x4108f
movb $0x1, -0x15(%rbp)
movl $0x1, -0x9c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x2b0a0
jmp 0x410b9
leaq -0xb0(%rbp), %rdi
callq 0x2b0a0
jmp 0x410db
testb $0x1, -0x15(%rbp)
jne 0x410cb
movq -0x1e8(%rbp), %rdi
callq 0x56c0
movq -0x1f0(%rbp), %rax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq -0x1e8(%rbp), %rdi
callq 0x56c0
movq -0x40(%rbp), %rdi
callq 0x5610