// File: /workspace/github_cpp_makefile_star2_O1/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 0x1f7ad
movq %rax, %r14
leaq 0x16840(%rip), %r15     # 0x35a70
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5140
cmpq %r15, %rbx
je 0x1f250
leaq 0x20(%rbx), %rsi
leaq 0x16845(%rip), %rdi     # 0x35a90
callq 0x22e1c
leaq 0x58(%rbx), %rsi
leaq 0x1686d(%rip), %rdi     # 0x35ac8
callq 0x22c72
movl 0x70(%rbx), %eax
movl %eax, 0x16877(%rip)     # 0x35ae0
leaq 0x168b0(%rip), %rdi     # 0x35b20
callq 0x22a52
movl 0x70(%rbx), %edx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x1bc7c
movq (%r15), %rsi
movq 0x8(%r15), %rdx
leaq 0x1615f(%rip), %rdi     # 0x353f8
callq 0x52a0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f2b9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq %rbx, 0x70(%rsp)
movq 0x30(%rbx), %rbx
testq %rbx, %rbx
je 0x1f354
xorl %ebp, %ebp
leaq 0x8(%rsp), %r13
leaq 0x16847(%rip), %r12     # 0x35b20
movl $0x1, %r14d
leaq 0x8(%rbx), %rsi
movq %r13, %rdi
callq 0x22986
movq %r12, %rdi
leaq 0x28(%rsp), %rsi
callq 0x231ea
movl %ebp, (%rax)
movl 0x48(%rsp), %r15d
sarl $0x2, %r15d
cmpb $0x0, 0x4c(%rsp)
cmovel %r14d, %r15d
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1f328
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1f344
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
addl %ebp, %r15d
movq (%rbx), %rbx
movl %r15d, %ebp
testq %rbx, %rbx
jne 0x1f2df
jmp 0x1f357
xorl %r15d, %r15d
movq 0x70(%rsp), %r13
cmpl $0x0, 0x70(%r13)
jle 0x1f609
leaq 0x60(%rsp), %r12
xorl %r14d, %r14d
leaq 0x50(%rsp), %rbp
movl $0xd1b71759, %ebx       # imm = 0xD1B71759
movl $0x1, %r13d
cmpl $0xa, %r14d
jb 0x1f3c7
movl $0x4, %r13d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0x1f3be
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x1f3c4
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x1f3c7
movl %eax, %ecx
imulq %rbx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x1f38e
addl $-0x3, %r13d
jmp 0x1f3c7
addl $-0x2, %r13d
jmp 0x1f3c7
decl %r13d
movl %r13d, %esi
movq %r12, 0x50(%rsp)
movq %rbp, %rdi
movl $0x2d, %edx
callq 0x52b0
movq 0x50(%rsp), %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x1230e
movq 0x165fd(%rip), %rcx     # 0x359f0
movq 0x165fe(%rip), %r8      # 0x359f8
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5290
leaq 0x18(%rsp), %r13
movq %r13, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x1f42e
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x1f436
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x166cb(%rip), %rdi     # 0x35b20
leaq 0x8(%rsp), %rsi
callq 0x235ec
movl %r15d, (%rax)
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1f479
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f490
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5240
movq %rbp, %r12
movl $0x1, %r13d
cmpl $0xa, %r14d
jb 0x1f4e1
movl $0x4, %r13d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0x1f4d8
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x1f4de
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x1f4e1
movl %eax, %ecx
imulq %rbx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x1f4a8
addl $-0x3, %r13d
jmp 0x1f4e1
addl $-0x2, %r13d
jmp 0x1f4e1
decl %r13d
movl %r13d, %esi
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x78(%rsp), %rbp
movq %rbp, %rdi
movl $0x2d, %edx
callq 0x52b0
movq 0x78(%rsp), %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x1230e
movq 0x164b6(%rip), %rcx     # 0x359d0
movq 0x164b7(%rip), %r8      # 0x359d8
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5290
leaq 0x60(%rsp), %rsi
movq %rsi, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movq 0x70(%rsp), %r13
movq %r12, %rbp
je 0x1f55d
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x1f563
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rsi, %r12
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq 0x1cf17
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x15e59(%rip), %rdi     # 0x353f8
callq 0x52a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1f5c0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f5d7
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1f5f9
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5240
incl %r15d
incl %r14d
cmpl 0x70(%r13), %r14d
jl 0x1f379
movq 0x58(%r13), %rbx
movq 0x60(%r13), %r15
cmpq %r15, %rbx
je 0x1f668
leaq 0x8(%rsp), %r14
movq 0x159ae(%rip), %r12     # 0x34fd0
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x1f648
cmpb $0x0, (%r12)
je 0x1f644
incl 0x8(%rax)
jmp 0x1f648
lock
incl 0x8(%rax)
movq %r14, %rdi
callq 0x1f842
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1f65f
callq 0x18722
addq $0x10, %rbx
cmpq %r15, %rbx
jne 0x1f622
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x1c210
movq (%r14), %rsi
movq 0x8(%r14), %rdx
leaq 0x15d72(%rip), %rdi     # 0x353f8
callq 0x52a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1f6a7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
jmp 0x1f6d4
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f7a5
movq 0x18(%rsp), %rsi
jmp 0x1f77a
movq %rax, %r14
jmp 0x1f706
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1f706
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f7a5
movq 0x60(%rsp), %rsi
jmp 0x1f77a
movq %rax, %r14
jmp 0x1f760
movq %rax, %r14
jmp 0x1f744
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1f744
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1f760
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1f7a5
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5240
jmp 0x1f7a5
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1f7a5
callq 0x18722
jmp 0x1f7a5
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x229f6
movq %r14, %rdi
callq 0x54c0