// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movl %edx, %esi
callq 0xc6d2
leaq 0x1680e(%rip), %rsi     # 0x2ea58
movq %rbx, %rdi
movq %r15, %rdx
callq 0x18e23
leaq 0x8(%rsp), %rdi
callq 0x5548
movq (%r14), %rax
cmpl $0x4, 0x8(%rax)
jne 0x182c9
leaq 0x58(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x18e9b
movq (%r15), %rax
movl 0x50(%rax), %esi
leaq 0x38(%rsp), %rdi
callq 0xc6d2
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
movq %rbx, %rsi
callq 0x15048
leaq 0x1615f(%rip), %rdi     # 0x2e400
leaq 0x8(%rsp), %rsi
callq 0x5210
leaq 0x8(%rsp), %rdi
callq 0x5548
leaq 0x38(%rsp), %rdi
callq 0x5548
leaq 0x60(%rsp), %rdi
jmp 0x184bd
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x18eb7
movq (%r15), %rdi
addq $0x50, %rdi
callq 0x10030
testb %al, %al
je 0x183a0
leaq 0x7628(%rip), %rsi      # 0x1f91c
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x68d2
leaq 0x163ee(%rip), %rdi     # 0x2e6f8
leaq 0x8(%rsp), %rsi
callq 0x1499e
addq $0x20, %rax
movq 0x28(%rsp), %rsi
addq $0x50, %rsi
movq %rax, %rdi
callq 0x11d64
movb 0x24(%rax), %bpl
leaq 0x8(%rsp), %rdi
callq 0x5548
cmpb $0x1, %bpl
jne 0x18440
movq 0x28(%rsp), %rsi
addq $0x50, %rsi
leaq 0x1679f(%rip), %rdi     # 0x2eaf0
callq 0x19624
movl (%rax), %esi
leaq 0x58(%rsp), %rdi
callq 0xc6d2
leaq 0x1664f(%rip), %rsi     # 0x2e9b8
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x18e23
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %rbx, %rdx
callq 0x15941
leaq 0x1606f(%rip), %rdi     # 0x2e400
leaq 0x8(%rsp), %rsi
callq 0x5210
jmp 0x1849a
movq 0x28(%rsp), %rdi
addq $0x50, %rdi
callq 0x100a0
testb %al, %al
jne 0x18404
movq 0x28(%rsp), %rsi
addq $0x50, %rsi
leaq 0x166d6(%rip), %rdi     # 0x2ea98
callq 0x11d64
cmpb $0x1, 0x24(%rax)
jne 0x18404
movq 0x28(%rsp), %rsi
addq $0x50, %rsi
leaq 0x1674b(%rip), %rdi     # 0x2eb28
callq 0x19624
movl (%rax), %esi
leaq 0x8(%rsp), %rdi
movq %rbx, %rdx
callq 0x15a5e
leaq 0x16008(%rip), %rdi     # 0x2e400
leaq 0x8(%rsp), %rsi
callq 0x5210
jmp 0x18439
movq 0x28(%rsp), %rsi
addq $0x50, %rsi
leaq 0x16714(%rip), %rdi     # 0x2eb28
callq 0x19624
movl (%rax), %esi
leaq 0x8(%rsp), %rdi
movq %rbx, %rdx
callq 0x157d8
leaq 0x15fd1(%rip), %rdi     # 0x2e400
leaq 0x8(%rsp), %rsi
callq 0x5210
leaq 0x8(%rsp), %rdi
jmp 0x184b3
movq 0x28(%rsp), %rsi
addq $0x50, %rsi
leaq 0x166a0(%rip), %rdi     # 0x2eaf0
callq 0x19624
movl (%rax), %esi
leaq 0x58(%rsp), %rdi
callq 0xc6d2
leaq 0x16550(%rip), %rsi     # 0x2e9b8
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x18e23
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %rbx, %rdx
callq 0x156bb
leaq 0x15f70(%rip), %rdi     # 0x2e400
leaq 0x8(%rsp), %rsi
callq 0x5210
leaq 0x8(%rsp), %rdi
callq 0x5548
leaq 0x38(%rsp), %rdi
callq 0x5548
leaq 0x58(%rsp), %rdi
callq 0x5548
leaq 0x30(%rsp), %rdi
callq 0x11548
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1850c
jmp 0x184d4
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5548
jmp 0x184e8
jmp 0x184e5
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x5548
jmp 0x184f9
jmp 0x184f6
movq %rax, %r14
leaq 0x58(%rsp), %rdi
jmp 0x18514
jmp 0x18543
jmp 0x1850c
jmp 0x18543
jmp 0x18543
jmp 0x18543
jmp 0x18543
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5548
jmp 0x18546
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5548
jmp 0x1852d
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x5548
jmp 0x1853c
movq %rax, %r14
leaq 0x60(%rsp), %rdi
jmp 0x1854b
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x11548
movq %rbx, %rdi
callq 0x5548
movq %r14, %rdi
callq 0x54c0
movq %rax, %r14
leaq 0x8(%rsp), %rdi
jmp 0x18553