// File: /workspace/github_c_makefile_star2_O2/goodpaul6[P]generic/script.c
// Function: ext_get_module_expr_list
static void ext_get_module_expr_list(script_t* script, vector_t* args)
{
	EXT_CHECK_IF_CT("get_module_expr_list");
	
	script_value_t* val = script_get_arg(args, 0);
	script_value_t* flatten_val = script_get_arg(args, 1);

	int module_index = (int)val->number;
	char flatten = flatten_val->boolean;

	script_module_t* module = vec_get(&script->modules, module_index);
	vector_t expr_list;

	vec_init(&expr_list, sizeof(script_value_t*));	

	for(int i = 0; i < module->expr_list.length; ++i)
	{
		if (flatten)
		{
			vector_t flat;
			vec_init(&flat, sizeof(expr_t*));

			flatten_expr(&flat, vec_get_value(&module->expr_list, i, expr_t*));

			for (int i = 0; i < flat.length; ++i)
			{
				script_value_t* exp_val = new_value(script, VAL_NATIVE);

				exp_val->nat.value = vec_get_value(&flat, i, expr_t*);
				exp_val->nat.on_mark = exp_val->nat.on_delete = NULL;

				vec_push_back(&expr_list, &exp_val);
			}

			vec_destroy(&flat);
		}
		else
		{
			// TODO: make script_create_native, et al and use those instead
			script_value_t* exp_val = new_value(script, VAL_NATIVE);

			exp_val->nat.value = vec_get_value(&module->expr_list, i, expr_t*);
			exp_val->nat.on_mark = exp_val->nat.on_delete = NULL;

			vec_push_back(&expr_list, &exp_val);
		}
	}

	script_push_premade_array(script, expr_list);
	script_return_top(script);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
cmpl $0x0, 0xeab7(%rip)      # 0x14248
js 0x5902
movq %rsi, %r14
xorl %r12d, %r12d
movq %rsi, %rdi
xorl %esi, %esi
callq 0x3446
movq %rax, %r15
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x3446
cvttsd2si 0x20(%r15), %ecx
movb 0x20(%rax), %al
movb %al, -0x29(%rbp)
leaq 0x2b8(%rbx), %rdi
movslq %ecx, %rsi
callq 0xc15c
movq %rax, %r14
leaq -0x70(%rbp), %rdi
pushq $0x8
popq %rsi
callq 0xbf0c
movq %r14, -0x48(%rbp)
addq $0x50, %r14
movq %r14, -0x38(%rbp)
pushq $0x8
popq %r13
leaq -0x90(%rbp), %r15
leaq -0x40(%rbp), %r14
movq -0x48(%rbp), %rax
cmpq %r12, 0x60(%rax)
jbe 0x58cf
cmpb $0x0, -0x29(%rbp)
je 0x5888
movq %r15, %rdi
pushq $0x8
popq %rsi
callq 0xbf0c
movq -0x38(%rbp), %rdi
movq %r12, -0x50(%rbp)
movq %r12, %rsi
callq 0xc15c
movq (%rax), %rsi
movq %r15, %rdi
callq 0x713b
xorl %r12d, %r12d
cmpq %r12, -0x80(%rbp)
jbe 0x587a
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2fb8
movq %rax, -0x40(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xc15c
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movq %rax, 0x20(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rcx)
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0xc1b9
incq %r12
jmp 0x5837
movq %r15, %rdi
callq 0xc3f5
movq -0x50(%rbp), %r12
jmp 0x58c7
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2fb8
movq %rax, -0x90(%rbp)
movq -0x38(%rbp), %rdi
movq %r12, %rsi
callq 0xc15c
movq (%rax), %rax
movq -0x90(%rbp), %rcx
movq %rax, 0x20(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rcx)
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0xc1b9
incq %r12
jmp 0x57fa
movups -0x70(%rbp), %xmm0
movups -0x60(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x335a
movq %rbx, %rdi
callq 0x346f
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x839d(%rip), %rsi      # 0xdca6
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2ec0