// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/evaluate.c
// Function: evaluate_member_dereference
static struct symbol *evaluate_member_dereference(struct expression *expr)
{
	int offset;
	struct symbol *ctype, *member;
	struct expression *deref = expr->deref, *add;
	struct ident *ident = expr->member;
	struct ident *address_space;
	unsigned int mod;

	if (!evaluate_expression(deref))
		return NULL;
	if (!ident) {
		expression_error(expr, "bad member name");
		return NULL;
	}

	ctype = deref->ctype;
	examine_symbol_type(ctype);
	address_space = ctype->ctype.as;
	mod = ctype->ctype.modifiers;
	if (ctype->type == SYM_NODE) {
		ctype = ctype->ctype.base_type;
		combine_address_space(deref->pos, &address_space, ctype->ctype.as);
		mod |= ctype->ctype.modifiers;
	}
	if (!ctype || (ctype->type != SYM_STRUCT && ctype->type != SYM_UNION)) {
		expression_error(expr, "expected structure or union");
		return NULL;
	}
	offset = 0;
	member = find_identifier(ident, ctype->symbol_list, &offset);
	if (!member) {
		const char *type = ctype->type == SYM_STRUCT ? "struct" : "union";
		const char *name = "<unnamed>";
		int namelen = 9;
		if (ctype->ident) {
			name = ctype->ident->name;
			namelen = ctype->ident->len;
		}
		if (ctype->symbol_list)
			expression_error(expr, "no member '%s' in %s %.*s",
				show_ident(ident), type, namelen, name);
		else
			expression_error(expr, "using member '%s' in "
				"incomplete %s %.*s", show_ident(ident),
				type, namelen, name);
		return NULL;
	}

	/*
	 * The member needs to take on the address space and modifiers of
	 * the "parent" type.
	 */
	member = convert_to_as_mod(member, address_space, mod);
	ctype = get_base_type(member);

	if (!lvalue_expression(deref)) {
		if (deref->type != EXPR_SLICE) {
			expr->base = deref;
			expr->r_bitpos = 0;
		} else {
			expr->base = deref->base;
			expr->r_bitpos = deref->r_bitpos;
		}
		expr->r_bitpos += bytes_to_bits(offset);
		expr->type = EXPR_SLICE;
		expr->r_bitpos += member->bit_offset;
		expr->ctype = member;
		return member;
	}

	deref = deref->unop;
	expr->deref = deref;

	add = evaluate_offset(deref, offset);
	expr->type = EXPR_PREOP;
	expr->op = '*';
	expr->unop = add;

	expr->ctype = member;
	return member;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x20(%rdi), %r15
movq 0x28(%rdi), %r12
movq %r15, %rdi
callq 0x32223
testq %rax, %rax
je 0x34be1
testq %r12, %r12
je 0x34be9
movq 0x10(%r15), %r13
movq %r13, %rdi
callq 0x2b0b8
movq 0x68(%r13), %rbp
movq 0x80(%r13), %rcx
movzbl (%r13), %eax
cmpl $0x3, %eax
jne 0x34c01
movq 0x60(%r13), %r13
movq 0x80(%r13), %rax
testq %rax, %rax
je 0x34bf8
testq %rcx, %rcx
je 0x34bf5
cmpq %rax, %rcx
je 0x34bf8
movq 0x8(%r15), %rdi
leaq 0x11e6b(%rip), %rsi     # 0x46a3c
xorl %eax, %eax
callq 0x11a80
leaq 0x30801(%rip), %rcx     # 0x653e0
jmp 0x34bf8
xorl %r14d, %r14d
jmp 0x34e01
leaq 0x158ef(%rip), %rsi     # 0x4a4df
jmp 0x34d39
movq %rax, %rcx
orq 0x68(%r13), %rbp
movzbl (%r13), %eax
addl $-0x7, %eax
cmpl $0x2, %eax
jae 0x34d32
movq %rcx, 0x8(%rsp)
leaq 0x14(%rsp), %rdx
movl $0x0, (%rdx)
movq 0x98(%r13), %rsi
movq %r12, %rdi
callq 0x37a8b
testq %rax, %rax
je 0x34d4b
movq %rax, %r14
movq 0x68(%rax), %rax
orl %eax, %ebp
movslq %ebp, %r13
movq 0x8(%rsp), %rcx
cmpq %rcx, 0x80(%r14)
jne 0x34c54
cmpq %r13, %rax
je 0x34c88
movq 0x4(%r14), %rdi
movl $0x3, %esi
movq %rcx, %rbp
callq 0x2b00b
movq %rax, %r12
movl $0xe0, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0xe1e0
movq %rbp, 0x80(%r12)
movq %r13, 0x68(%r12)
movq %r12, %r14
movq 0x60(%r14), %rdi
callq 0x2b0b8
movzbl (%r15), %eax
cmpl $0x1d, %eax
je 0x34d81
cmpl $0x9, %eax
jne 0x34d79
cmpl $0x2a, 0x4(%r15)
jne 0x34d79
movq 0x20(%r15), %r12
movq %r12, 0x20(%rbx)
movslq 0x14(%rsp), %r13
movq 0x8(%r12), %rbp
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r15
movq %rbp, 0x8(%rax)
movw $0x5, (%rax)
movl $0x2b, 0x4(%rax)
movq %r12, 0x20(%rax)
movq 0x8(%r12), %rbp
xorl %edi, %edi
callq 0x2f9f5
movq %rbp, 0x8(%rax)
movw $0x1, (%rax)
movq %rax, 0x28(%r15)
leaq 0x36a36(%rip), %rcx     # 0x6b738
movq %rcx, 0x10(%rax)
movq 0x28(%r15), %rax
movq %r13, 0x20(%rax)
leaq 0x37903(%rip), %rax     # 0x6c618
movq %rax, 0x10(%r15)
movb 0x1(%r12), %al
movb %al, 0x1(%r15)
movb $0x9, (%rbx)
movl $0x2a, 0x4(%rbx)
movq %r15, 0x20(%rbx)
jmp 0x34dad
leaq 0x157b6(%rip), %rsi     # 0x4a4ef
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11b04
jmp 0x34e01
cmpb $0x7, (%r13)
leaq 0xf5c5(%rip), %rax      # 0x4431c
leaq 0x12b18(%rip), %r15     # 0x47876
cmoveq %rax, %r15
movq 0x18(%r13), %rbp
testq %rbp, %rbp
je 0x34db3
movzbl 0x10(%rbp), %eax
movl %eax, 0x8(%rsp)
addq $0x12, %rbp
jmp 0x34dc2
movq %r15, 0x20(%rbx)
xorl %eax, %eax
jmp 0x34d8d
movq 0x20(%r15), %rax
movq %rax, 0x20(%rbx)
movl 0x28(%r15), %eax
leaq 0x2f96c(%rip), %rcx     # 0x64700
movl (%rcx), %ecx
imull 0x14(%rsp), %ecx
addl %eax, %ecx
movl %ecx, 0x28(%rbx)
movb $0x1d, (%rbx)
movzbl 0x54(%r14), %eax
addl %ecx, %eax
movl %eax, 0x28(%rbx)
movq %r14, 0x10(%rbx)
jmp 0x34e01
movl $0x9, 0x8(%rsp)
leaq 0x15749(%rip), %rbp     # 0x4a50b
movq 0x98(%r13), %r14
movq %r12, %rdi
callq 0x2de35
testq %r14, %r14
je 0x34ddf
leaq 0x15738(%rip), %rsi     # 0x4a515
jmp 0x34de6
leaq 0x15749(%rip), %rsi     # 0x4a52f
xorl %r14d, %r14d
movq %rbx, %rdi
movq %rax, %rdx
movq %r15, %rcx
movl 0x8(%rsp), %r8d
movq %rbp, %r9
xorl %eax, %eax
callq 0x11b04
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq