// File: /workspace/github_c_makefile_star2_O0/goodpaul6[P]generic/script.c
// Function: reference_variable
static var_decl_t* reference_variable(script_t* script, const char* name)
{
	if(g_cur_func)
	{
		for(int scope = g_scope; scope >= 0; --scope)
		{
			for(int i = 0; i < g_cur_func->locals.length; ++i)
			{
				var_decl_t* decl = vec_get_value(&g_cur_func->locals, i, var_decl_t*);
				if(decl->scope == scope && strcmp(decl->name, name) == 0) return decl;
			}
		}
		
		for(int i = 0; i < g_cur_func->args.length; ++i)
		{
			var_decl_t* decl = vec_get_value(&g_cur_func->args, i, var_decl_t*);
			if(strcmp(decl->name, name) == 0) return decl;
		}
	}

	for (int module_index = 0; module_index < script->modules.length; ++module_index)
	{
		script_module_t* module = vec_get(&script->modules, module_index);
		for (int i = 0; i < module->globals.length; ++i)
		{
			var_decl_t* decl = vec_get_value(&module->globals, i, var_decl_t*);
			if (strcmp(decl->name, name) == 0) return decl;
		}
	}
	
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, 0x10580(%rip)     # 0x1a4a8
je 0xa021
movl 0x1056c(%rip), %eax     # 0x1a4a0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x9fbc
movl $0x0, -0x20(%rbp)
movslq -0x20(%rbp), %rax
movq 0x10559(%rip), %rcx     # 0x1a4a8
cmpq 0x30(%rcx), %rax
jae 0x9fac
movq 0x1054c(%rip), %rdi     # 0x1a4a8
addq $0x20, %rdi
movslq -0x20(%rbp), %rsi
callq 0x11890
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x9f9f
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2130
cmpl $0x0, %eax
jne 0x9f9f
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa0cd
jmp 0x9fa1
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x9f44
jmp 0x9fae
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x9f37
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
movq 0x104da(%rip), %rcx     # 0x1a4a8
cmpq 0x50(%rcx), %rax
jae 0xa01f
movq 0x104cd(%rip), %rdi     # 0x1a4a8
addq $0x40, %rdi
movslq -0x2c(%rbp), %rsi
callq 0x11890
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2130
cmpl $0x0, %eax
jne 0xa012
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa0cd
jmp 0xa014
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9fc3
jmp 0xa021
movl $0x0, -0x3c(%rbp)
movslq -0x3c(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x2c8(%rcx), %rax
jae 0xa0c5
movq -0x10(%rbp), %rdi
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0x3c(%rbp), %rsi
callq 0x11890
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movslq -0x4c(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq 0x2100(%rcx), %rax
jae 0xa0b5
movq -0x48(%rbp), %rdi
addq $0x20f0, %rdi           # imm = 0x20F0
movslq -0x4c(%rbp), %rsi
callq 0x11890
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2130
cmpl $0x0, %eax
jne 0xa0a8
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa0cd
jmp 0xa0aa
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xa05c
jmp 0xa0b7
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xa028
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)