// File: /workspace/github_c_makefile_star2_O2/lucvoo[P]sparse-dev/evaluate.c
// Function: degenerate
static struct symbol *degenerate(struct expression *expr)
{
	struct symbol *ctype, *base;

	if (!expr)
		return NULL;
	ctype = expr->ctype;
	if (!ctype)
		return NULL;
	base = examine_symbol_type(ctype);
	if (ctype->type == SYM_NODE)
		base = ctype->ctype.base_type;
	/*
	 * Arrays degenerate into pointers to the entries, while
	 * functions degenerate into pointers to themselves.
	 * If array was part of non-lvalue compound, we create a copy
	 * of that compound first and then act as if we were dealing with
	 * the corresponding field in there.
	 */
	switch (base->type) {
	case SYM_ARRAY:
		if (expr->type == EXPR_SLICE) {
			struct symbol *a = alloc_symbol(expr->pos, SYM_NODE);
			struct expression *e0, *e1, *e2, *e3, *e4;

			a->ctype.base_type = expr->base->ctype;
			a->bit_size = expr->base->ctype->bit_size;
			a->array_size = expr->base->ctype->array_size;

			e0 = alloc_expression(expr->pos, EXPR_SYMBOL);
			e0->symbol = a;
			e0->ctype = &lazy_ptr_ctype;

			e1 = alloc_expression(expr->pos, EXPR_PREOP);
			e1->unop = e0;
			e1->op = '*';
			e1->ctype = expr->base->ctype;	/* XXX */

			e2 = alloc_expression(expr->pos, EXPR_ASSIGNMENT);
			e2->left = e1;
			e2->right = expr->base;
			e2->op = '=';
			e2->ctype = expr->base->ctype;

			if (expr->r_bitpos) {
				e3 = alloc_expression(expr->pos, EXPR_BINOP);
				e3->op = '+';
				e3->left = e0;
				e3->right = alloc_const_expression(expr->pos,
							bits_to_bytes(expr->r_bitpos));
				e3->ctype = &lazy_ptr_ctype;
			} else {
				e3 = e0;
			}

			e4 = alloc_expression(expr->pos, EXPR_COMMA);
			e4->left = e2;
			e4->right = e3;
			e4->ctype = &lazy_ptr_ctype;

			expr->unop = e4;
			expr->type = EXPR_PREOP;
			expr->op = '*';
		}
	case SYM_FN:
		if (expr->op != '*' || expr->type != EXPR_PREOP) {
			expression_error(expr, "strange non-value function or array");
			return &bad_ctype;
		}
		if (ctype->builtin)
			sparse_error(expr->pos, "taking the address of built-in function '%s'", show_ident(ctype->ident)); 
		*expr = *expr->unop;
		ctype = create_pointer(expr, ctype, 1);
		expr->ctype = ctype;
		mark_addressable(expr);
	default:
		/* nothing */;
	}
	return ctype;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x2f800
movq %rdi, %r14
movq 0x10(%rdi), %rbx
testq %rbx, %rbx
je 0x2f800
movq %rbx, %rdi
callq 0x267cd
cmpb $0x3, (%rbx)
jne 0x2f6f5
movq 0x60(%rbx), %rax
movzbl (%rax), %eax
cmpl $0x5, %eax
je 0x2f84a
cmpl $0x6, %eax
jne 0x2f8d8
cmpb $0x1d, (%r14)
jne 0x2f84a
movq 0x8(%r14), %rdi
pushq $0x3
popq %rbp
movl %ebp, %esi
callq 0x2671f
movq %rax, %r15
movq 0x20(%r14), %rax
movq 0x10(%rax), %rax
movq %rax, 0x60(%r15)
movq 0x20(%r14), %rax
movq 0x10(%rax), %rax
movl 0x50(%rax), %eax
movl %eax, 0x50(%r15)
movq 0x20(%r14), %rax
movq 0x10(%rax), %rax
movq 0x58(%rax), %rax
movq %rax, 0x58(%r15)
movq 0x8(%r14), %rdi
movl %ebp, %esi
callq 0x30712
movq %rax, %r13
movq %r15, 0x20(%rax)
leaq 0x36eaf(%rip), %rbp     # 0x66618
movq %rbp, 0x10(%rax)
movq 0x8(%r14), %rdi
pushq $0x9
popq %rsi
callq 0x30712
movq %rax, %r12
movq %r13, 0x20(%rax)
movl $0x2a, 0x4(%rax)
movq 0x20(%r14), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%r12)
movq 0x8(%r14), %rdi
pushq $0x6
popq %rsi
callq 0x30712
movq %rax, %r15
movq %r12, 0x20(%rax)
movq 0x20(%r14), %rax
movq %rax, 0x28(%r15)
movl $0x3d, 0x4(%r15)
movq 0x20(%r14), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%r15)
cmpl $0x0, 0x28(%r14)
je 0x2f807
movq 0x8(%r14), %rdi
pushq $0x5
popq %rsi
callq 0x30712
movq %rax, %r12
movl $0x2b, 0x4(%rax)
movq %r13, 0x20(%rax)
movl 0x28(%r14), %eax
testl %eax, %eax
js 0x2f80c
leaq 0x2ef0d(%rip), %rcx     # 0x5e700
movl (%rcx), %ecx
addl %ecx, %eax
decl %eax
cltd
idivl %ecx
movl %eax, %esi
jmp 0x2f80f
xorl %ebx, %ebx
jmp 0x2f8d8
movq %r13, %r12
jmp 0x2f822
pushq $-0x1
popq %rsi
movq 0x8(%r14), %rdi
callq 0x308a8
movq %rax, 0x28(%r12)
movq %rbp, 0x10(%r12)
movq 0x8(%r14), %rdi
pushq $0x15
popq %rsi
callq 0x30712
movq %r15, 0x20(%rax)
movq %r12, 0x28(%rax)
movq %rbp, 0x10(%rax)
movq %rax, 0x20(%r14)
movb $0x9, (%r14)
movl $0x2a, 0x4(%r14)
cmpl $0x2a, 0x4(%r14)
jne 0x2f8c0
cmpb $0x9, (%r14)
jne 0x2f8c0
testb $0x8, 0x56(%rbx)
je 0x2f87b
movq 0x18(%rbx), %rdi
callq 0x2936d
movq 0x8(%r14), %rdi
leaq 0x138ad(%rip), %rsi     # 0x4311e
movq %rax, %rdx
xorl %eax, %eax
callq 0x1120e
movq 0x20(%r14), %rax
movaps (%rax), %xmm0
movaps 0x10(%rax), %xmm1
movaps 0x20(%rax), %xmm2
movaps 0x30(%rax), %xmm3
movaps %xmm0, (%r14)
movaps %xmm1, 0x10(%r14)
movaps %xmm3, 0x30(%r14)
movaps %xmm2, 0x20(%r14)
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x30b70
movq %rax, %rbx
movq %rax, 0x10(%r14)
movq %r14, %rdi
callq 0x30c65
jmp 0x2f8d8
leaq 0x13833(%rip), %rsi     # 0x430fa
movq %r14, %rdi
xorl %eax, %eax
callq 0x11292
leaq 0x36fe0(%rip), %rbx     # 0x668b8
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq