// File: /workspace/github_c_makefile_star2_O0/goodpaul6[P]generic/script.c
// Function: add_module
static int add_module(script_t* script, const char* local_path, const char* module_name, const char* code)
{
	// NOTE: This'll slow down add module a bit (but who cares, how many modules could you possibly have :)
	if (local_path)
	{
		for (int i = 0; i < script->modules.length; ++i)
		{
			script_module_t* module = vec_get(&script->modules, i);
			if (module->local_path)
			{
				if (strcmp(module->local_path, local_path) == 0)
					return i;
			}
		}
	}
	
	script_module_t module;
	
	module.start_pc = -1;
	module.end_pc = -1;
	module.name = module_name ? estrdup(module_name) : NULL;
	module.local_path = local_path ? estrdup(local_path) : NULL;
	module.source_code = estrdup(code);
	module.parsed = 0;
	module.compiled = 0;
	
	vec_init(&module.referenced_modules, sizeof(int));

	vec_init(&module.expr_list, sizeof(expr_t*));
	vec_init(&module.compile_time_blocks, sizeof(expr_t*));
	
	vec_init(&module.globals, sizeof(var_decl_t*));
	vec_init(&module.functions, sizeof(func_decl_t*));
	vec_init(&module.all_type_tags, sizeof(type_tag_t*));
	map_init(&module.user_type_tags);

	vec_push_back(&script->modules, &module);
	return script->modules.length - 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2160, %rsp           # imm = 0x2160
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x3d2f
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x2c8(%rcx), %rax
jae 0x3d2d
movq -0x10(%rbp), %rdi
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0x2c(%rbp), %rsi
callq 0x11890
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x3d20
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2130
cmpl $0x0, %eax
jne 0x3d1e
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e86
jmp 0x3d20
jmp 0x3d22
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3cc9
jmp 0x3d2f
movq $-0x1, -0x2128(%rbp)
movq $-0x1, -0x2120(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x3d5e
movq -0x20(%rbp), %rdi
callq 0x2500
movq %rax, -0x2150(%rbp)
jmp 0x3d69
xorl %eax, %eax
movq %rax, -0x2150(%rbp)
jmp 0x3d69
movq -0x2150(%rbp), %rax
movq %rax, -0x2110(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x3d90
movq -0x18(%rbp), %rdi
callq 0x2500
movq %rax, -0x2158(%rbp)
jmp 0x3d9b
xorl %eax, %eax
movq %rax, -0x2158(%rbp)
jmp 0x3d9b
movq -0x2158(%rbp), %rax
movq %rax, -0x2108(%rbp)
movq -0x28(%rbp), %rdi
callq 0x2500
movq %rax, -0x2118(%rbp)
movb $0x0, -0x2100(%rbp)
movb $0x0, -0x20ff(%rbp)
leaq -0x2148(%rbp), %rdi
movl $0x4, %esi
callq 0x114e0
leaq -0x2148(%rbp), %rdi
addq $0x50, %rdi
movl $0x8, %esi
callq 0x114e0
leaq -0x2148(%rbp), %rdi
addq $0x70, %rdi
movl $0x8, %esi
callq 0x114e0
leaq -0x2148(%rbp), %rdi
addq $0x20f0, %rdi           # imm = 0x20F0
movl $0x8, %esi
callq 0x114e0
leaq -0x2148(%rbp), %rdi
addq $0x20d0, %rdi           # imm = 0x20D0
movl $0x8, %esi
callq 0x114e0
leaq -0x2148(%rbp), %rdi
addq $0x90, %rdi
movl $0x8, %esi
callq 0x114e0
leaq -0x2148(%rbp), %rdi
addq $0xb0, %rdi
callq 0x11e10
movq -0x10(%rbp), %rdi
addq $0x2b8, %rdi            # imm = 0x2B8
leaq -0x2148(%rbp), %rsi
callq 0x11960
movq -0x10(%rbp), %rax
movq 0x2c8(%rax), %rax
subq $0x1, %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2160, %rsp           # imm = 0x2160
popq %rbp
retq
nopw %cs:(%rax,%rax)