// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/evaluate.c
// Function: evaluate_offsetof
static struct symbol *evaluate_offsetof(struct expression *expr)
{
	struct expression *e = expr->down;
	struct symbol *ctype = expr->in;
	int class;

	if (expr->op == '.') {
		struct symbol *field;
		int offset = 0;
		if (!ctype) {
			expression_error(expr, "expected structure or union");
			return NULL;
		}
		examine_symbol_type(ctype);
		class = classify_type(ctype, &ctype);
		if (class != TYPE_COMPOUND) {
			expression_error(expr, "expected structure or union");
			return NULL;
		}

		field = find_identifier(expr->ident, ctype->symbol_list, &offset);
		if (!field) {
			expression_error(expr, "unknown member");
			return NULL;
		}
		ctype = field;
		expr->type = EXPR_VALUE;
		expr->flags = CEF_SET_ICE;
		expr->value = offset;
		expr->taint = 0;
		expr->ctype = size_t_ctype;
	} else {
		if (!ctype) {
			expression_error(expr, "expected structure or union");
			return NULL;
		}
		examine_symbol_type(ctype);
		class = classify_type(ctype, &ctype);
		if (class != (TYPE_COMPOUND | TYPE_PTR)) {
			expression_error(expr, "expected array");
			return NULL;
		}
		ctype = ctype->ctype.base_type;
		if (!expr->index) {
			expr->type = EXPR_VALUE;
			expr->flags = CEF_SET_ICE;
			expr->value = 0;
			expr->taint = 0;
			expr->ctype = size_t_ctype;
		} else {
			struct expression *idx = expr->index, *m;
			struct symbol *i_type = evaluate_expression(idx);
			unsigned old_idx_flags;
			int i_class = classify_type(i_type, &i_type);

			if (!is_int(i_class)) {
				expression_error(expr, "non-integer index");
				return NULL;
			}
			unrestrict(idx, i_class, &i_type);
			old_idx_flags = idx->flags;
			idx = cast_to(idx, size_t_ctype);
			idx->flags = old_idx_flags;
			m = alloc_const_expression(expr->pos,
						   bits_to_bytes(ctype->bit_size));
			m->ctype = size_t_ctype;
			m->flags = CEF_SET_INT;
			expr->type = EXPR_BINOP;
			expr->left = idx;
			expr->right = m;
			expr->op = '*';
			expr->ctype = size_t_ctype;
			expr->flags = m->flags & idx->flags & ~CEF_CONST_MASK;
		}
	}
	if (e) {
		struct expression *copy = __alloc_expression(0);
		*copy = *expr;
		if (e->type == EXPR_OFFSETOF)
			e->in = ctype;
		if (!evaluate_expression(e))
			return NULL;
		expr->type = EXPR_BINOP;
		expr->flags = e->flags & copy->flags & ~CEF_CONST_MASK;
		expr->op = '+';
		expr->ctype = size_t_ctype;
		expr->left = copy;
		expr->right = e;
	}
	return size_t_ctype;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2e, 0x4(%rax)
jne 0x4f74e
movl $0x0, -0x34(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x4f66f
movq -0x10(%rbp), %rdi
leaq 0x1cbb4(%rip), %rsi     # 0x6c20f
movb $0x0, %al
callq 0x17030
movq $0x0, -0x8(%rbp)
jmp 0x4fa82
movq -0x20(%rbp), %rdi
callq 0x3f650
movq -0x20(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x4bf20
movl %eax, -0x24(%rbp)
cmpl $0x20, -0x24(%rbp)
je 0x4f6ad
movq -0x10(%rbp), %rdi
leaq 0x1cb76(%rip), %rsi     # 0x6c20f
movb $0x0, %al
callq 0x17030
movq $0x0, -0x8(%rbp)
jmp 0x4fa82
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x98(%rax), %rsi
leaq -0x34(%rbp), %rdx
callq 0x538c0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4f6f3
movq -0x10(%rbp), %rdi
leaq 0x1cc41(%rip), %rsi     # 0x6c320
movb $0x0, %al
callq 0x17030
movq $0x0, -0x8(%rbp)
jmp 0x4fa82
movq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffff00ff, %ecx       # imm = 0xFFFF00FF
orl $0x3000, %ecx           # imm = 0x3000
movl %ecx, (%rax)
movslq -0x34(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x28(%rax)
leaq 0x3aeb2(%rip), %rax     # 0x8a5f0
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x4f993
cmpq $0x0, -0x20(%rbp)
jne 0x4f774
movq -0x10(%rbp), %rdi
leaq 0x1caaf(%rip), %rsi     # 0x6c20f
movb $0x0, %al
callq 0x17030
movq $0x0, -0x8(%rbp)
jmp 0x4fa82
movq -0x20(%rbp), %rdi
callq 0x3f650
movq -0x20(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x4bf20
movl %eax, -0x24(%rbp)
cmpl $0x30, -0x24(%rbp)
je 0x4f7b2
movq -0x10(%rbp), %rdi
leaq 0x1cb91(%rip), %rsi     # 0x6c32f
movb $0x0, %al
callq 0x17030
movq $0x0, -0x8(%rbp)
jmp 0x4fa82
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x4f81c
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffff00ff, %ecx       # imm = 0xFFFF00FF
orl $0x3000, %ecx           # imm = 0x3000
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x28(%rax)
leaq 0x3ade4(%rip), %rax     # 0x8a5f0
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x4f991
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x4bb70
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4bf20
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
andl $0x9, %eax
cmpl $0x1, %eax
je 0x4f86f
movq -0x10(%rbp), %rdi
leaq 0x1cae3(%rip), %rsi     # 0x6c33e
movb $0x0, %al
callq 0x17030
movq $0x0, -0x8(%rbp)
jmp 0x4fa82
movq -0x40(%rbp), %rdi
movl -0x58(%rbp), %esi
leaq -0x50(%rbp), %rdx
callq 0x51240
movq -0x40(%rbp), %rax
movl (%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, -0x54(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x3ad55(%rip), %rax     # 0x8a5f0
movq (%rax), %rsi
callq 0x4c020
movq %rax, -0x40(%rbp)
movl -0x54(%rbp), %edx
movq -0x40(%rbp), %rax
movl (%rax), %ecx
andl $0xff, %edx
shll $0x8, %edx
andl $0xffff00ff, %ecx       # imm = 0xFFFF00FF
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movl 0x50(%rax), %edi
callq 0x513e0
movl %eax, %esi
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x50de0
movq %rax, -0x48(%rbp)
leaq 0x3acff(%rip), %rax     # 0x8a5f0
movq (%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rax
movl (%rax), %ecx
andl $0xffff00ff, %ecx       # imm = 0xFFFF00FF
orl $0x3100, %ecx           # imm = 0x3100
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x5, %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x2a, 0x4(%rax)
leaq 0x3aca5(%rip), %rax     # 0x8a5f0
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rax
movl (%rax), %edx
shrl $0x8, %edx
andl $0xff, %edx
movq -0x40(%rbp), %rax
movl (%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
andl %eax, %edx
andl $-0xc, %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xff, %edx
shll $0x8, %edx
andl $0xffff00ff, %ecx       # imm = 0xFFFF00FF
orl %edx, %ecx
movl %ecx, (%rax)
jmp 0x4f993
cmpq $0x0, -0x18(%rbp)
je 0x4fa74
xorl %edi, %edi
callq 0x46d40
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x40, %edx
callq 0x111d0
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1e, %eax
jne 0x4f9d7
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rdi
callq 0x4bb70
cmpq $0x0, %rax
jne 0x4f9f3
movq $0x0, -0x8(%rbp)
jmp 0x4fa82
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x5, %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl (%rax), %edx
shrl $0x8, %edx
andl $0xff, %edx
movq -0x60(%rbp), %rax
movl (%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
andl %eax, %edx
andl $-0xc, %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xff, %edx
shll $0x8, %edx
andl $0xffff00ff, %ecx       # imm = 0xFFFF00FF
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl $0x2b, 0x4(%rax)
leaq 0x3ab9f(%rip), %rax     # 0x8a5f0
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
leaq 0x3ab75(%rip), %rax     # 0x8a5f0
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)