// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/evaluate.c
// Function: evaluate_dereference
static struct symbol *evaluate_dereference(struct expression *expr)
{
	struct expression *op = expr->unop;
	struct symbol *ctype = op->ctype, *node, *target;

	/* Simplify: *&(expr) => (expr) */
	if (op->type == EXPR_PREOP && op->op == '&') {
		*expr = *op->unop;
		expr->flags = CEF_NONE;
		return expr->ctype;
	}

	examine_symbol_type(ctype);

	/* Dereferencing a node drops all the node information. */
	if (ctype->type == SYM_NODE)
		ctype = ctype->ctype.base_type;

	target = ctype->ctype.base_type;

	switch (ctype->type) {
	default:
		expression_error(expr, "cannot dereference this type");
		return NULL;
	case SYM_FN:
		*expr = *op;
		return expr->ctype;
	case SYM_PTR:
		examine_symbol_type(target);
		node = alloc_symbol(expr->pos, SYM_NODE);
		node->ctype.modifiers = target->ctype.modifiers & MOD_SPECIFIER;
		merge_type(node, ctype);
		break;

	case SYM_ARRAY:
		if (!lvalue_expression(op)) {
			expression_error(op, "non-lvalue array??");
			return NULL;
		}

		/* Do the implied "addressof" on the array */
		*op = *op->unop;

		/*
		 * When an array is dereferenced, we need to pick
		 * up the attributes of the original node too..
		 */
		node = alloc_symbol(expr->pos, SYM_NODE);
		merge_type(node, op->ctype);
		merge_type(node, ctype);
		break;
	}

	node->bit_size = target->bit_size;
	node->array_size = target->array_size;

	expr->ctype = node;
	return node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x9, %eax
jne 0x53146
movq -0x18(%rbp), %rax
cmpl $0x26, 0x4(%rax)
jne 0x53146
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x40, %edx
callq 0x111d0
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffff00ff, %ecx       # imm = 0xFFFF00FF
orl $0x0, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x532cd
movq -0x20(%rbp), %rdi
callq 0x3f650
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x3, %eax
jne 0x5316b
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x34(%rbp)
subl $0x4, %eax
je 0x531e2
jmp 0x53188
movl -0x34(%rbp), %eax
subl $0x5, %eax
je 0x531bf
jmp 0x53192
movl -0x34(%rbp), %eax
subl $0x6, %eax
je 0x53227
jmp 0x531a0
movq -0x10(%rbp), %rdi
leaq 0x18dfd(%rip), %rsi     # 0x6bfa8
movb $0x0, %al
callq 0x17030
movq $0x0, -0x8(%rbp)
jmp 0x532cd
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x40, %edx
callq 0x111d0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x532cd
movq -0x30(%rbp), %rdi
callq 0x3f650
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x3, %esi
callq 0x3f4d0
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rcx
andq $0xe000, %rcx           # imm = 0xE000
movq -0x28(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x3f530
jmp 0x5329b
movq -0x18(%rbp), %rdi
callq 0x52a10
cmpl $0x0, %eax
jne 0x53251
movq -0x18(%rbp), %rdi
leaq 0x18d85(%rip), %rsi     # 0x6bfc5
movb $0x0, %al
callq 0x17030
movq $0x0, -0x8(%rbp)
jmp 0x532cd
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x40, %edx
callq 0x111d0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x3, %esi
callq 0x3f4d0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x3f530
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x3f530
movq -0x30(%rbp), %rax
movl 0x50(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)