// File: /workspace/github_c_makefile_star2_O3/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 0x32d58
movq %rdi, %r14
movq 0x10(%rdi), %rbx
testq %rbx, %rbx
je 0x32d58
movq %rbx, %rdi
callq 0x2b0b8
cmpb $0x3, (%rbx)
jne 0x32c2b
movq 0x60(%rbx), %rax
movzbl (%rax), %eax
cmpl $0x5, %eax
je 0x32dd6
cmpl $0x6, %eax
jne 0x32e72
cmpb $0x1d, (%r14)
jne 0x32dd6
movq 0x8(%r14), %rdi
movl $0x3, %esi
callq 0x2b00b
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), %r12
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r13
movq %r12, 0x8(%rax)
movw $0x3, (%rax)
movq %r15, 0x20(%rax)
leaq 0x39970(%rip), %rax     # 0x6c618
movq %rax, 0x10(%r13)
movq 0x8(%r14), %r15
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r12
movq %r15, 0x8(%rax)
movw $0x9, (%rax)
movq %r13, 0x20(%rax)
movl $0x2a, 0x4(%rax)
movq 0x20(%r14), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%r12)
movq 0x8(%r14), %rbp
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r15
movq %rbp, 0x8(%rax)
movw $0x6, (%rax)
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 0x32d5f
movq 0x8(%r14), %rbp
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r12
movq %rbp, 0x8(%rax)
movw $0x5, (%rax)
movl $0x2b, 0x4(%rax)
movq %r13, 0x20(%rax)
movl 0x28(%r14), %eax
testl %eax, %eax
js 0x32d6b
leaq 0x319b6(%rip), %rcx     # 0x64700
movl (%rcx), %ecx
addl %ecx, %eax
decl %eax
cltd
idivl %ecx
movslq %eax, %r13
jmp 0x32d72
xorl %ebx, %ebx
jmp 0x32e72
movq %r13, %r12
leaq 0x398af(%rip), %rbp     # 0x6c618
jmp 0x32da6
movq $-0x1, %r13
movq 0x8(%r14), %rbp
xorl %edi, %edi
callq 0x2f9f5
movq %rbp, 0x8(%rax)
movq %r13, 0x20(%rax)
leaq 0x389ac(%rip), %rcx     # 0x6b738
movq %rcx, 0x10(%rax)
movw $0x3101, (%rax)         # imm = 0x3101
movq %rax, 0x28(%r12)
leaq 0x39877(%rip), %rbp     # 0x6c618
movq %rbp, 0x10(%r12)
movq 0x8(%r14), %r13
xorl %edi, %edi
callq 0x2f9f5
movq %r13, 0x8(%rax)
movw $0x15, (%rax)
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 0x32e5a
cmpb $0x9, (%r14)
jne 0x32e5a
testb $0x8, 0x56(%rbx)
je 0x32e07
movq 0x18(%rbx), %rdi
callq 0x2de35
movq 0x8(%r14), %rdi
leaq 0x170d1(%rip), %rsi     # 0x49ece
movq %rax, %rdx
xorl %eax, %eax
callq 0x11a80
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)
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x36b58
movq %rax, %rbx
movq %rax, 0x10(%r14)
movzbl (%r14), %eax
cmpl $0x5, %eax
jne 0x32e84
cmpl $0x2b, 0x4(%r14)
jne 0x32e72
movq 0x20(%r14), %r14
jmp 0x32e44
leaq 0x17049(%rip), %rsi     # 0x49eaa
movq %r14, %rdi
xorl %eax, %eax
callq 0x11b04
leaq 0x39a46(%rip), %rbx     # 0x6c8b8
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, %eax
jne 0x32e72
movq 0x20(%r14), %rax
orq $0x100, 0x68(%rax)      # imm = 0x100
jmp 0x32e72