// File: /workspace/github_cpp_makefile_star2_O3/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 0x1f721
movq %rax, %r14
leaq 0x168cc(%rip), %r15     # 0x35a70
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5140
cmpq %r15, %rbx
je 0x1f1c4
leaq 0x20(%rbx), %rsi
leaq 0x168d1(%rip), %rdi     # 0x35a90
callq 0x22db8
leaq 0x58(%rbx), %rsi
leaq 0x168f9(%rip), %rdi     # 0x35ac8
callq 0x22bf6
movl 0x70(%rbx), %eax
movl %eax, 0x16903(%rip)     # 0x35ae0
leaq 0x1693c(%rip), %rdi     # 0x35b20
callq 0x229dc
movl 0x70(%rbx), %edx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x1bc6f
movq (%r15), %rsi
movq 0x8(%r15), %rdx
leaq 0x161eb(%rip), %rdi     # 0x353f8
callq 0x52a0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f22d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq %rbx, 0x70(%rsp)
movq 0x30(%rbx), %rbx
testq %rbx, %rbx
je 0x1f2c8
xorl %ebp, %ebp
leaq 0x8(%rsp), %r13
leaq 0x168d3(%rip), %r12     # 0x35b20
movl $0x1, %r14d
leaq 0x8(%rbx), %rsi
movq %r13, %rdi
callq 0x22910
movq %r12, %rdi
leaq 0x28(%rsp), %rsi
callq 0x2318c
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 0x1f29c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1f2b8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
addl %ebp, %r15d
movq (%rbx), %rbx
movl %r15d, %ebp
testq %rbx, %rbx
jne 0x1f253
jmp 0x1f2cb
xorl %r15d, %r15d
movq 0x70(%rsp), %r13
cmpl $0x0, 0x70(%r13)
jle 0x1f57d
leaq 0x60(%rsp), %r12
xorl %r14d, %r14d
leaq 0x50(%rsp), %rbp
movl $0xd1b71759, %ebx       # imm = 0xD1B71759
movl $0x1, %r13d
cmpl $0xa, %r14d
jb 0x1f33b
movl $0x4, %r13d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0x1f332
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x1f338
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x1f33b
movl %eax, %ecx
imulq %rbx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x1f302
addl $-0x3, %r13d
jmp 0x1f33b
addl $-0x2, %r13d
jmp 0x1f33b
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 0x1205c
movq 0x16689(%rip), %rcx     # 0x359f0
movq 0x1668a(%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 0x1f3a2
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x1f3aa
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 0x16757(%rip), %rdi     # 0x35b20
leaq 0x8(%rsp), %rsi
callq 0x23584
movl %r15d, (%rax)
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1f3ed
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f404
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5240
movq %rbp, %r12
movl $0x1, %r13d
cmpl $0xa, %r14d
jb 0x1f455
movl $0x4, %r13d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0x1f44c
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x1f452
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x1f455
movl %eax, %ecx
imulq %rbx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x1f41c
addl $-0x3, %r13d
jmp 0x1f455
addl $-0x2, %r13d
jmp 0x1f455
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 0x1205c
movq 0x16542(%rip), %rcx     # 0x359d0
movq 0x16543(%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 0x1f4d1
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x1f4d7
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 0x1cefe
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x15ee5(%rip), %rdi     # 0x353f8
callq 0x52a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1f534
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f54b
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1f56d
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5240
incl %r15d
incl %r14d
cmpl 0x70(%r13), %r14d
jl 0x1f2ed
movq 0x58(%r13), %rbx
movq 0x60(%r13), %r15
cmpq %r15, %rbx
je 0x1f5dc
leaq 0x8(%rsp), %r14
movq 0x15a3a(%rip), %r12     # 0x34fd0
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x1f5bc
cmpb $0x0, (%r12)
je 0x1f5b8
incl 0x8(%rax)
jmp 0x1f5bc
lock
incl 0x8(%rax)
movq %r14, %rdi
callq 0x1f7b6
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1f5d3
callq 0x18806
addq $0x10, %rbx
cmpq %r15, %rbx
jne 0x1f596
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x1c1f4
movq (%r14), %rsi
movq 0x8(%r14), %rdx
leaq 0x15dfe(%rip), %rdi     # 0x353f8
callq 0x52a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1f61b
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 0x1f648
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f719
movq 0x18(%rsp), %rsi
jmp 0x1f6ee
movq %rax, %r14
jmp 0x1f67a
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1f67a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f719
movq 0x60(%rsp), %rsi
jmp 0x1f6ee
movq %rax, %r14
jmp 0x1f6d4
movq %rax, %r14
jmp 0x1f6b8
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1f6b8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1f6d4
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1f719
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5240
jmp 0x1f719
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1f719
callq 0x18806
jmp 0x1f719
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x22980
movq %r14, %rdi
callq 0x54c0