// File: /workspace/github_c_makefile_star2_O1/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 0xdf81
movq (%r14), %rax
movl 0x28(%rax), %ecx
cmpq $0x1a, %rcx
ja 0x8150
leaq 0x72a4(%rip), %rdx      # 0xf22c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq 0x38(%rax), %rsi
jmp 0x7fab
movq 0x38(%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x38(%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rsi
jmp 0x7fab
movq 0x38(%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rsi
testq %rsi, %rsi
jne 0x7fab
jmp 0x7fb3
movq 0x38(%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
movq -0x18(%rbp), %rdi
cmpq $0x0, 0x50(%rdi)
je 0x7fb3
xorl %r14d, %r14d
addq $0x40, %rdi
movq %r14, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x50(%rdi)
ja 0x803b
jmp 0x7fb3
movq -0x18(%rbp), %rdi
cmpq $0x0, 0x50(%rdi)
je 0x7fb3
xorl %r14d, %r14d
addq $0x40, %rdi
movq %r14, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x50(%rdi)
ja 0x8076
jmp 0x7fb3
movq -0x18(%rbp), %rdi
cmpq $0x0, 0x50(%rdi)
je 0x7fb3
xorl %r14d, %r14d
addq $0x40, %rdi
movq %r14, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x50(%rdi)
ja 0x80b1
jmp 0x7fb3
movq -0x18(%rbp), %rdi
cmpq $0x0, 0x48(%rdi)
je 0x7fb3
xorl %r14d, %r14d
addq $0x38, %rdi
movq %r14, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x48(%rdi)
ja 0x80ec
jmp 0x7fb3
movq -0x18(%rbp), %rdi
cmpq $0x0, 0x48(%rdi)
je 0x7fb3
xorl %r14d, %r14d
addq $0x38, %rdi
movq %r14, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7f54
incq %r14
movq -0x18(%rbp), %rdi
cmpq %r14, 0x48(%rdi)
ja 0x8127
jmp 0x7fb3
leaq 0x7a35(%rip), %rdi      # 0xfb8c
leaq 0x7a30(%rip), %rsi      # 0xfb8e
leaq 0x7b84(%rip), %rcx      # 0xfce9
movl $0xbc9, %edx            # imm = 0xBC9
callq 0x2100