// File: /workspace/github_cpp_makefile_star2_O2/lhydave[P]SysYCompilerLab/back/no_alloc.cpp
// Function: no_alloc::gen_func(eeyore_AST::func_entry const&)
void gen_func(const func_entry &func)
{
	auto stk_size = stack_size(func);
	now_func = func;
	var2no.clear();
	tigger_dst << emit_func_begin(func.eeyore_name, func.param_n, stk_size);
	dbg_printf("func %s begin, param: %d, size: %lu\n",
		func.eeyore_name.c_str(), func.param_n, stk_size);
	// initialize mappings
	int posi = 0;
	for (auto i : func.temps)
	{
		var2no[i.second.eeyore_name] = posi;
		dbg_printf(
			"temp var %s mapped to %d\n", i.second.eeyore_name.c_str(), posi);
		if (i.second.is_array)
			posi += i.second.size / int_size;
		else
			posi++;
	}
	for (auto i = 0; i < func.param_n; i++)
	{
		var2no[eeyore_param_prefix + to_string(i)] = posi;
		tigger_dst << emit_store(param_prefix + to_string(i), posi);
		posi++;
	}
	for (auto i : func.funcbody)
		gen_stmt(i);
	tigger_dst << emit_func_end(func.eeyore_name);
	dbg_printf("func %s end\n", func.eeyore_name.c_str());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
callq 0x177dc
movq %rax, %r14
leaq 0x174e5(%rip), %rdi     # 0x2ea78
movq %rbx, %rsi
callq 0x18de8
leaq 0x17586(%rip), %rdi     # 0x2eb28
callq 0x18f0c
movl 0x70(%rbx), %edx
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x14dbc
leaq 0x16e3c(%rip), %rdi     # 0x2e400
movq %r15, %rsi
callq 0x5210
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x5548
movq %rbx, 0x8(%rsp)
leaq 0x30(%rbx), %r13
xorl %ebx, %ebx
leaq 0x1753d(%rip), %r12     # 0x2eb28
pushq $0x1
popq %rbp
movq (%r13), %r13
testq %r13, %r13
je 0x17634
leaq 0x8(%r13), %rsi
movq %r14, %rdi
callq 0x18d88
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
callq 0x19624
movl %ebx, (%rax)
movl 0x50(%rsp), %r15d
sarl $0x2, %r15d
cmpb $0x0, 0x54(%rsp)
cmovel %ebp, %r15d
addl %ebx, %r15d
movq %r14, %rdi
callq 0x11830
movl %r15d, %ebx
jmp 0x175ee
xorl %r14d, %r14d
leaq 0x58(%rsp), %r15
leaq 0x10(%rsp), %r13
leaq 0x78(%rsp), %r12
movq 0x8(%rsp), %rax
cmpl 0x70(%rax), %r14d
jge 0x176f0
movq %r15, %rdi
movl %r14d, %esi
callq 0xc6d2
movq %r13, %rdi
leaq 0x1738e(%rip), %rsi     # 0x2e9f8
movq %r15, %rdx
callq 0x18e23
leaq 0x174af(%rip), %rdi     # 0x2eb28
movq %r13, %rsi
callq 0x19a24
leal (%rbx,%r14), %ebp
movl %ebp, (%rax)
movq %r13, %rdi
callq 0x5548
movq %r15, %rdi
callq 0x5548
movq %r12, %rdi
movl %r14d, %esi
callq 0xc6d2
movq %r15, %rdi
leaq 0x1732c(%rip), %rsi     # 0x2e9d8
movq %r12, %rdx
callq 0x18e23
movq %r13, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x15563
leaq 0x16d38(%rip), %rdi     # 0x2e400
movq %r13, %rsi
callq 0x5210
movq %r13, %rdi
callq 0x5548
movq %r15, %rdi
callq 0x5548
movq %r12, %rdi
callq 0x5548
incl %r14d
jmp 0x17646
movq 0x8(%rsp), %r13
movq 0x58(%r13), %r15
movq 0x60(%r13), %rbx
leaq 0x18(%rsp), %r14
leaq 0x10(%rsp), %r12
cmpq %rbx, %r15
je 0x1772d
movq %r12, %rdi
movq %r15, %rsi
callq 0x1430c
movq %r12, %rdi
callq 0x1783b
movq %r14, %rdi
callq 0x11548
addq $0x10, %r15
jmp 0x17707
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x14f8b
leaq 0x16cbc(%rip), %rdi     # 0x2e400
movq %r14, %rsi
callq 0x5210
leaq 0x10(%rsp), %rdi
callq 0x5548
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1776a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x177c0
movq %rax, %rbx
movq %r14, %rdi
callq 0x11548
jmp 0x177c5
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5548
jmp 0x17793
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x5548
jmp 0x177b1
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5548
jmp 0x177bb
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0x177c0
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x5548
movq %rbx, %rdi
callq 0x54c0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x11830
jmp 0x177c5