// File: /workspace/github_c_makefile_star2_O3/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 0xdd50
movq (%r14), %rdi
movl 0x28(%rdi), %eax
cmpq $0x1a, %rax
ja 0x8137
leaq 0x72b2(%rip), %rcx      # 0xf22c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x38(%rdi), %rsi
jmp 0x80f6
movq 0x38(%rdi), %rsi
movq %rbx, %rdi
callq 0x7f46
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
jmp 0x80f6
movq 0x40(%rdi), %rsi
jmp 0x80f6
cmpq $0x0, 0x50(%rdi)
je 0x80fe
xorl %r14d, %r14d
addq $0x40, %rdi
movq %r14, %rsi
callq 0xdcf3
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f46
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x50(%rdi)
ja 0x7fbc
jmp 0x80fe
cmpq $0x0, 0x48(%rdi)
je 0x80fe
xorl %r14d, %r14d
addq $0x38, %rdi
movq %r14, %rsi
callq 0xdcf3
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f46
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x48(%rdi)
ja 0x7ff3
jmp 0x80fe
movq 0x38(%rdi), %rsi
movq %rbx, %rdi
callq 0x7f46
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
movq %rbx, %rdi
callq 0x7f46
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rsi
testq %rsi, %rsi
jne 0x80f6
jmp 0x80fe
movq 0x38(%rdi), %rsi
movq %rbx, %rdi
callq 0x7f46
movq -0x18(%rbp), %rdi
cmpq $0x0, 0x50(%rdi)
je 0x80fe
xorl %r14d, %r14d
addq $0x40, %rdi
movq %r14, %rsi
callq 0xdcf3
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f46
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x50(%rdi)
ja 0x806c
jmp 0x80fe
cmpq $0x0, 0x50(%rdi)
je 0x80fe
xorl %r14d, %r14d
addq $0x40, %rdi
movq %r14, %rsi
callq 0xdcf3
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f46
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x50(%rdi)
ja 0x809c
jmp 0x80fe
movq 0x38(%rdi), %rsi
movq %rbx, %rdi
callq 0x7f46
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
movq %rbx, %rdi
callq 0x7f46
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rsi
movq %rbx, %rdi
callq 0x7f46
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rsi
movq %rbx, %rdi
callq 0x7f46
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
cmpq $0x0, 0x48(%rdi)
je 0x80fe
xorl %r14d, %r14d
addq $0x38, %rdi
movq %r14, %rsi
callq 0xdcf3
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f46
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x48(%rdi)
ja 0x8111
jmp 0x80fe
leaq 0x7a4e(%rip), %rdi      # 0xfb8c
leaq 0x7a49(%rip), %rsi      # 0xfb8e
leaq 0x7b9d(%rip), %rcx      # 0xfce9
movl $0xbc9, %edx            # imm = 0xBC9
callq 0x2100