// File: /workspace/github_c_makefile_star2_O0/qpfiffer[P]lair/src/eval.c
// Function: infer_atom_at_runtime
static const struct _lair_ast *_infer_atom_at_runtime(
		struct _lair_runtime *r,
		const struct _lair_ast *ast_node,
		const struct _lair_env *top_env) {
	/* This function attempts to modify an LR_ATOM into something more useful. */
	check(r, ast_node->atom.type == LR_ATOM, ERR_RUNTIME,
			"Can't infer an already inferred atom.");
	const char *func_name = ast_node->atom.value.str;
	const size_t func_len = strlen(ast_node->atom.value.str);
	struct _lair_ast *to_return = calloc(1, sizeof(struct _lair_ast));
	memcpy(to_return, ast_node, sizeof(struct _lair_ast));

	const struct _lair_env *env = top_env;
	while (env != NULL) {
		const struct _lair_function *builtin_function = _tst_map_get(env->c_functions, func_name, func_len);
		if (builtin_function != NULL) {
			to_return->atom.type = LR_FUNCTION_DEF;
			return to_return;
		}

		const struct _lair_ast *defined_function_ast = _tst_map_get(env->functions, func_name, func_len);
		if (defined_function_ast != NULL) {
			to_return->atom.type = LR_FUNCTION_DEF;
			return to_return;
		}

		const struct _lair_ast *not_variable_ast = (struct _lair_ast *)_tst_map_get(env->not_variables, func_name, func_len);
		if (not_variable_ast != NULL) {
			to_return->atom.type = not_variable_ast->atom.type;
			to_return->atom.value = not_variable_ast->atom.value;
			return to_return;
		}
		env = env->parent;
	}

	free(to_return);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
cmpl $0xe, 0x28(%rax)
sete %al
andb $0x1, %al
movzbl %al, %esi
movl $0x2, %edx
leaq 0x3783(%rip), %rcx      # 0x65c7
callq 0x1830
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x1060
movq %rax, -0x30(%rbp)
movl $0x1, %edi
movl $0x38, %esi
callq 0x1110
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x38, %edx
callq 0x1140
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x2f63
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x3a90
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x2ed6
movq -0x38(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2f74
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x3a90
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x2f0b
movq -0x38(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2f74
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x3a90
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x2f53
movq -0x58(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x38(%rbp), %rax
movq -0x58(%rbp), %rcx
movq 0x30(%rcx), %rcx
movq %rcx, 0x30(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2f74
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x2e93
movq -0x38(%rbp), %rdi
callq 0x1030
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop