// File: /workspace/github_c_makefile_star2_O3/goodpaul6[P]generic/script.c
// Function: resolve_symbols
static void resolve_symbols(script_t* script, expr_t* exp)
{
	switch(exp->type)
	{
		case EXP_ATOMIC:
		{
			resolve_symbols(script, exp->atomx);
		} break;
		
		case EXP_DOT: case EXP_COLON:
		{
			resolve_symbols(script, exp->dotx.value);
		} break;
		
		case EXP_STRUCT_NEW:
		{
			for(int i = 0; i < exp->newx.init.length; ++i)
				resolve_symbols(script, vec_get_value(&exp->newx.init, i, expr_t*));
		} break;
		
		case EXP_STRUCT_DECL:
		{
			for(int i = 0; i < exp->struct_tag->ds.members.length; ++i)
			{
				type_tag_member_t* mem = vec_get(&exp->struct_tag->ds.members, i);
				if(mem->default_value)
					resolve_symbols(script, mem->default_value);
			}
		} break;
		
		case EXP_NULL:
		case EXP_EXTERN:
		case EXP_EXTERN_LIST:
		case EXP_NUMBER:
		case EXP_STRING:
		case EXP_CHAR:
		case EXP_BOOL: break;
	
		case EXP_VAR:
		{
			if(exp->varx.decl) return;
			exp->varx.decl = reference_variable(script, exp->varx.name);
			if(!exp->varx.decl) 
			{
				if(reference_function(script, exp->varx.name)) return;
				if(get_type_tag_from_name(script, exp->varx.name)) return;
				error_defer_e(exp, "Attempted to reference undeclared entity '%s'\n", exp->varx.name);
			}
		} break;
		
		case EXP_UNARY:
		{
			resolve_symbols(script, exp->unaryx.rhs);
		} break;
		
		case EXP_BINARY:
		{
			resolve_symbols(script, exp->binx.lhs);
			resolve_symbols(script, exp->binx.rhs);
		} break;
		
		case EXP_PAREN:
		{
			resolve_symbols(script, exp->paren);
		} break;
		
		case EXP_BLOCK:
		{
			for(int i = 0; i < exp->block.length; ++i)
				resolve_symbols(script, vec_get_value(&exp->block, i, expr_t*));
		} break;
		
		case EXP_ARRAY_INDEX:
		{
			resolve_symbols(script, exp->array_index.array);
			resolve_symbols(script, exp->array_index.index);
		} break;
		
		case EXP_ARRAY_LITERAL:
		{
			for(int i = 0; i < exp->array_literal.values.length; ++i)
				resolve_symbols(script, vec_get_value(&exp->array_literal.values, i, expr_t*));
		} break;
		
		case EXP_IF:
		{
			resolve_symbols(script, exp->ifx.cond);
			resolve_symbols(script, exp->ifx.body);
			if(exp->ifx.alt) resolve_symbols(script, exp->ifx.alt);
		} break;
		
		case EXP_WHILE:
		{
			resolve_symbols(script, exp->whilex.cond);
			resolve_symbols(script, exp->whilex.body);
		} break;
		
		case EXP_FOR:
		{
			resolve_symbols(script, exp->forx.init);
			resolve_symbols(script, exp->forx.cond);
			resolve_symbols(script, exp->forx.step);
			resolve_symbols(script, exp->forx.body);
		} break;

		case EXP_RETURN:
		{
			if(exp->retx.value)
				resolve_symbols(script, exp->retx.value);
		} break;
		
		case EXP_CALL:
		{
			for(int i = 0; i < exp->callx.args.length; ++i)
				resolve_symbols(script, vec_get_value(&exp->callx.args, i, expr_t*));
			resolve_symbols(script, exp->callx.func);
		} break;
		
		case EXP_FUNC:
		{
			resolve_symbols(script, exp->funcx.body);
		} break;
		
		case EXP_WRITE:
		{
			resolve_symbols(script, exp->write);
		} break;
		
		case EXP_LEN:
		{
			resolve_symbols(script, exp->len);
		} break;

		default:
			assert(0);
			break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq 0x68b9(%rip), %r15      # 0xf298
movq %rdi, -0x30(%rbp)
movl 0x28(%rbx), %eax
cmpq $0x1a, %rax
ja 0x8c09
movl $0x38, %r14d
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq 0x38(%rbx), %rsi
callq 0x89c7
movq -0x30(%rbp), %rdi
movl $0x40, %r14d
jmp 0x8a83
movq 0x38(%rbx), %rsi
callq 0x89c7
movq 0x40(%rbx), %rsi
movq -0x30(%rbp), %rdi
callq 0x89c7
movq 0x48(%rbx), %rsi
movq -0x30(%rbp), %rdi
callq 0x89c7
movq -0x30(%rbp), %rdi
movl $0x50, %r14d
jmp 0x8a83
movq 0x40(%rbx), %rbx
jmp 0x8aaa
cmpq $0x0, 0x50(%rbx)
je 0x8a83
leaq 0x40(%rbx), %r15
xorl %r12d, %r12d
movq %rdi, %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0xdcf3
movq (%rax), %rsi
movq %r13, %rdi
callq 0x89c7
incq %r12
cmpq %r12, 0x50(%rbx)
ja 0x8a5a
movq %r13, %rdi
leaq 0x6815(%rip), %r15      # 0xf298
movq (%rbx,%r14), %rbx
jmp 0x89e3
movq 0x38(%rbx), %rsi
callq 0x89c7
movq 0x40(%rbx), %rsi
movq -0x30(%rbp), %rdi
callq 0x89c7
movq -0x30(%rbp), %rdi
movq 0x48(%rbx), %rbx
testq %rbx, %rbx
jne 0x89e3
jmp 0x8bfa
cmpq $0x0, 0x50(%rbx)
je 0x8bfa
leaq 0x40(%rbx), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdcf3
movq (%rax), %rsi
movq -0x30(%rbp), %rdi
callq 0x89c7
incq %r12
cmpq %r12, 0x50(%rbx)
ja 0x8aca
jmp 0x8bfa
cmpq $0x0, 0x50(%rbx)
je 0x8bfa
leaq 0x40(%rbx), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdcf3
movq (%rax), %rsi
movq -0x30(%rbp), %rdi
callq 0x89c7
incq %r12
cmpq %r12, 0x50(%rbx)
ja 0x8b01
jmp 0x8bfa
movq 0x38(%rbx), %rdi
cmpq $0x0, 0x70(%rdi)
je 0x8bfa
xorl %r15d, %r15d
addq $0x60, %rdi
movq %r15, %rsi
callq 0xdcf3
movq 0x18(%rax), %rsi
testq %rsi, %rsi
je 0x8b56
movq -0x30(%rbp), %rdi
callq 0x89c7
incq %r15
movq 0x38(%rbx), %rdi
cmpq %r15, 0x70(%rdi)
ja 0x8b38
jmp 0x8bfa
cmpq $0x0, 0x40(%rbx)
jne 0x8bfa
movq 0x38(%rbx), %rsi
callq 0x863a
movq -0x30(%rbp), %rdi
movq %rax, 0x40(%rbx)
testq %rax, %rax
jne 0x8bfa
movq 0x38(%rbx), %rsi
callq 0x846c
movq -0x30(%rbp), %rdi
testq %rax, %rax
jne 0x8bfa
movq 0x38(%rbx), %rsi
callq 0x8c28
testq %rax, %rax
jne 0x8bfa
movq 0x38(%rbx), %rdx
leaq 0x7b28(%rip), %rsi      # 0x106dc
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b3
cmpq $0x0, 0x48(%rbx)
je 0x8bfa
leaq 0x38(%rbx), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdcf3
movq (%rax), %rsi
movq -0x30(%rbp), %rdi
callq 0x89c7
incq %r12
cmpq %r12, 0x48(%rbx)
ja 0x8bda
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6f7c(%rip), %rdi      # 0xfb8c
leaq 0x6f77(%rip), %rsi      # 0xfb8e
leaq 0x7aed(%rip), %rcx      # 0x1070b
movl $0xc54, %edx            # imm = 0xC54
callq 0x2100