// File: lhydave[P]SysYCompilerLab/back/no_alloc.cpp
// Function: no_alloc::gen_stmt(std::shared_ptr<eeyore_AST::stmt_node> const&)
void gen_stmt(const shared_ptr<stmt_node> &stmt)
{
	if (stmt->label != -1)
		tigger_dst << emit_label(stmt->label);
	switch (stmt->stmt_type)
	{
	case STMT_ASSIGN:
	{
		dbg_printf("assign stmt gen\n");
		auto stmt_new = std::static_pointer_cast<assign_node>(stmt);
		gen_assign(stmt_new->lval, stmt_new->rval);
		break;
	}
	case STMT_GOTO:
	{
		dbg_printf("goto stmt gen\n");
		auto stmt_new = std::static_pointer_cast<goto_node>(stmt);
		gen_goto(stmt_new);
		break;
	}
	case STMT_RET:
	{
		dbg_printf("ret stmt gen\n");
		auto stmt_new = std::static_pointer_cast<ret_node>(stmt);
		gen_ret(stmt_new);
		break;
	}
	case STMT_CALL:
	{
		dbg_printf("call stmt gen\n");
		auto stmt_new = std::static_pointer_cast<call_node>(stmt);
		gen_call(stmt_new);
		break;
	}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x26d80
cmpl $-0x1, 0x4(%rax)
je 0x3f884
movq -0x8(%rbp), %rdi
callq 0x26d80
movl 0x4(%rax), %esi
leaq -0x28(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x352b0
movq -0xa8(%rbp), %rsi
leaq 0x32c60(%rip), %rdi     # 0x724b8
callq 0x52b0
jmp 0x3f85f
leaq -0x28(%rbp), %rdi
callq 0x56c0
jmp 0x3f884
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x56c0
jmp 0x3fa76
movq -0x8(%rbp), %rdi
callq 0x26d80
movl (%rax), %eax
movq %rax, -0xb0(%rbp)
subq $0x3, %rax
ja 0x3fa6d
movq -0xb0(%rbp), %rax
leaq 0xf216(%rip), %rcx      # 0x4eac4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rsi
leaq -0x48(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x42260
movq -0xc0(%rbp), %rdi
callq 0x422b0
movq -0xc0(%rbp), %rdi
addq $0x8, %rax
movq %rax, -0xb8(%rbp)
callq 0x422b0
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
addq $0x18, %rsi
callq 0x3fa80
jmp 0x3f903
leaq -0x48(%rbp), %rdi
callq 0x26c00
jmp 0x3fa6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x26c00
jmp 0x3fa76
movq -0x8(%rbp), %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x26ad0
movq -0xc8(%rbp), %rdi
callq 0x3fcf0
jmp 0x3f94d
leaq -0x58(%rbp), %rdi
callq 0x26a80
jmp 0x3fa6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x26a80
jmp 0x3fa76
movq -0x8(%rbp), %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x422d0
movq -0xd0(%rbp), %rdi
callq 0x401f0
jmp 0x3f997
leaq -0x68(%rbp), %rdi
callq 0x26cc0
jmp 0x3fa6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x26cc0
jmp 0x3fa76
movq -0x8(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x42320
leaq -0x99(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x5620
movq -0xd8(%rbp), %rdx
leaq 0xf273(%rip), %rsi      # 0x4ec60
leaq -0x98(%rbp), %rdi
callq 0x8780
jmp 0x3f9fb
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x40300
jmp 0x3fa0d
leaq -0x98(%rbp), %rdi
callq 0x56c0
leaq -0x99(%rbp), %rdi
callq 0x5370
leaq -0x78(%rbp), %rdi
callq 0x2c7e0
jmp 0x3fa6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3fa56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x56c0
leaq -0x99(%rbp), %rdi
callq 0x5370
leaq -0x78(%rbp), %rdi
callq 0x2c7e0
jmp 0x3fa76
addq $0xe0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x5610
nop