// File: /workspace/github_c_makefile_star2_O2/goodpaul6[P]generic/script.c
// Function: flatten_expr
static void flatten_expr(vector_t* expr_list, expr_t* exp)
{
	vec_push_back(expr_list, &exp);

	switch (exp->type)
	{
		case EXP_NULL:
		case EXP_BOOL:
		case EXP_CHAR:
		case EXP_NUMBER:
		case EXP_STRING:
		case EXP_EXTERN:
		case EXP_VAR:
		case EXP_STRUCT_DECL:
			break;

		case EXP_EXTERN_LIST:
		{
			for (int i = 0; i < exp->extern_array.length; ++i)
				flatten_expr(expr_list, vec_get_value(&exp->extern_array, i, expr_t*));
		} break;

		case EXP_DOT:
		case EXP_COLON:
		{
			flatten_expr(expr_list, exp->dotx.value);
		} break;

		case EXP_STRUCT_NEW:
		{
			for (int i = 0; i < exp->newx.init.length; ++i)
				flatten_expr(expr_list, vec_get_value(&exp->newx.init, i, expr_t*));
		} break;

		case EXP_PAREN:
		{
			flatten_expr(expr_list, exp->paren);
		} break;

		case EXP_ARRAY_INDEX:
		{
			flatten_expr(expr_list, exp->array_index.array);
			flatten_expr(expr_list, exp->array_index.index);
		} break;

		case EXP_ARRAY_LITERAL:
		{
			for (int i = 0; i < exp->array_literal.values.length; ++i)
				flatten_expr(expr_list, vec_get_value(&exp->array_literal.values, i, expr_t*));
		} break;
		
		case EXP_UNARY:
		{
			flatten_expr(expr_list, exp->unaryx.rhs);
		} break;

		case EXP_BINARY:
		{
			flatten_expr(expr_list, exp->binx.lhs);
			flatten_expr(expr_list, exp->binx.rhs);
		} break;

		case EXP_CALL:
		{
			flatten_expr(expr_list, exp->callx.func);
	
			for (int i = 0; i < exp->callx.args.length; ++i)
				flatten_expr(expr_list, vec_get_value(&exp->callx.args, i, expr_t*));
		} break;

		case EXP_RETURN:
		{
			flatten_expr(expr_list, exp->retx.value);
		} break;

		case EXP_BLOCK:
		{
			for (int i = 0; i < exp->block.length; ++i)
				flatten_expr(expr_list, vec_get_value(&exp->block, i, expr_t*));
		} break;

		case EXP_FUNC:
		{
			flatten_expr(expr_list, exp->funcx.body);
		} break;

		case EXP_ATOMIC:
		{
			flatten_expr(expr_list, exp->atomx);
		} break;

		case EXP_IF:
		{
			flatten_expr(expr_list, exp->ifx.cond);
			flatten_expr(expr_list, exp->ifx.body);

			if (exp->ifx.alt)
				flatten_expr(expr_list, exp->ifx.alt);
		} break;

		case EXP_WHILE:
		{
			flatten_expr(expr_list, exp->whilex.cond);
			flatten_expr(expr_list, exp->whilex.body);
		} break;

		case EXP_FOR:
		{
			flatten_expr(expr_list, exp->forx.init);
			flatten_expr(expr_list, exp->forx.cond);
			flatten_expr(expr_list, exp->forx.step);
			flatten_expr(expr_list, exp->forx.body);
		} break;

		case EXP_WRITE:
		{
			flatten_expr(expr_list, exp->write);
		} break;

		case EXP_LEN:
		{
			flatten_expr(expr_list, exp->len);
		} break;

		default:
			assert(0);
			break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq -0x18(%rbp), %r14
movq %rsi, (%r14)
movq %r14, %rsi
callq 0xc1b9
movq (%r14), %rdi
movl 0x28(%rdi), %eax
cmpq $0x1a, %rax
ja 0x72ff
leaq 0x607d(%rip), %rcx      # 0xd1ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x38(%rdi), %rsi
jmp 0x72c5
movq 0x38(%rdi), %rsi
movq %rbx, %rdi
callq 0x713b
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
jmp 0x72c5
movq 0x40(%rdi), %rsi
jmp 0x72c5
xorl %r14d, %r14d
cmpq %r14, 0x50(%rdi)
jbe 0x72cd
addq $0x40, %rdi
movq %r14, %rsi
callq 0xc15c
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x713b
incq %r14
movq -0x18(%rbp), %rdi
jmp 0x71a6
xorl %r14d, %r14d
cmpq %r14, 0x48(%rdi)
jbe 0x72cd
addq $0x38, %rdi
movq %r14, %rsi
callq 0xc15c
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x713b
incq %r14
movq -0x18(%rbp), %rdi
jmp 0x71d3
movq 0x38(%rdi), %rsi
movq %rbx, %rdi
callq 0x713b
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
movq %rbx, %rdi
callq 0x713b
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rsi
testq %rsi, %rsi
jne 0x72c5
jmp 0x72cd
movq 0x38(%rdi), %rsi
movq %rbx, %rdi
callq 0x713b
xorl %r14d, %r14d
movq -0x18(%rbp), %rdi
cmpq %r14, 0x50(%rdi)
jbe 0x72cd
addq $0x40, %rdi
movq %r14, %rsi
callq 0xc15c
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x713b
incq %r14
jmp 0x723e
xorl %r14d, %r14d
cmpq %r14, 0x50(%rdi)
jbe 0x72cd
addq $0x40, %rdi
movq %r14, %rsi
callq 0xc15c
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x713b
incq %r14
movq -0x18(%rbp), %rdi
jmp 0x726b
movq 0x38(%rdi), %rsi
movq %rbx, %rdi
callq 0x713b
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
movq %rbx, %rdi
callq 0x713b
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rsi
movq %rbx, %rdi
callq 0x713b
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rsi
movq %rbx, %rdi
callq 0x713b
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
xorl %r14d, %r14d
cmpq %r14, 0x48(%rdi)
jbe 0x72cd
addq $0x38, %rdi
movq %r14, %rsi
callq 0xc15c
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x713b
incq %r14
movq -0x18(%rbp), %rdi
jmp 0x72d9
leaq 0x688e(%rip), %rdi      # 0xdb94
leaq 0x6889(%rip), %rsi      # 0xdb96
leaq 0x69dd(%rip), %rcx      # 0xdcf1
movl $0xbc9, %edx            # imm = 0xBC9
callq 0x2100