// File: /workspace/github_c_makefile_star2_O1/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 0x337b5
movq %rdi, %r14
movq 0x10(%rdi), %rbx
testq %rbx, %rbx
je 0x337b5
movq %rbx, %rdi
callq 0x2b5f4
cmpb $0x3, (%rbx)
jne 0x3365d
movq 0x60(%rbx), %rax
movzbl (%rax), %eax
cmpl $0x5, %eax
je 0x33849
cmpl $0x6, %eax
jne 0x338d9
cmpb $0x1d, (%r14)
jne 0x33849
movq 0x8(%r14), %rdi
movl $0x3, %esi
callq 0x2b547
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 0x30029
movq %rax, %r13
movl (%rax), %eax
orl $0x3, %eax
movq %r12, 0x8(%r13)
andl $0xffff0003, %eax       # imm = 0xFFFF0003
movl %eax, (%r13)
movq %r15, 0x20(%r13)
leaq 0x39f35(%rip), %rax     # 0x6d618
movq %rax, 0x10(%r13)
movq 0x8(%r14), %r15
xorl %edi, %edi
callq 0x30029
movq %rax, %r12
movl (%rax), %eax
orl $0x9, %eax
movq %r15, 0x8(%r12)
andl $0xffff0009, %eax       # imm = 0xFFFF0009
movl %eax, (%r12)
movq %r13, 0x20(%r12)
movl $0x2a, 0x4(%r12)
movq 0x20(%r14), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%r12)
movq 0x8(%r14), %rbp
xorl %edi, %edi
callq 0x30029
movq %rax, %r15
movl (%rax), %eax
orl $0x6, %eax
movq %rbp, 0x8(%r15)
andl $0xffff0006, %eax       # imm = 0xFFFF0006
movl %eax, (%r15)
movq %r12, 0x20(%r15)
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 0x337bc
movq 0x8(%r14), %rbp
xorl %edi, %edi
callq 0x30029
movq %rax, %r12
movl (%rax), %eax
orl $0x5, %eax
movq %rbp, 0x8(%r12)
andl $0xffff0005, %eax       # imm = 0xFFFF0005
movl %eax, (%r12)
movl $0x2b, 0x4(%r12)
movq %r13, 0x20(%r12)
movl 0x28(%r14), %eax
testl %eax, %eax
js 0x337c8
leaq 0x31f59(%rip), %rcx     # 0x65700
movl (%rcx), %ecx
addl %ecx, %eax
decl %eax
cltd
idivl %ecx
movslq %eax, %r13
jmp 0x337cf
xorl %ebx, %ebx
jmp 0x338d9
movq %r13, %r12
leaq 0x39e52(%rip), %rbp     # 0x6d618
jmp 0x33811
movq $-0x1, %r13
movq 0x8(%r14), %rbp
xorl %edi, %edi
callq 0x30029
movl (%rax), %ecx
orl $0x1, %ecx
movq %rbp, 0x8(%rax)
movq %r13, 0x20(%rax)
leaq 0x38f4a(%rip), %rdx     # 0x6c738
movq %rdx, 0x10(%rax)
andl $0xffff0001, %ecx       # imm = 0xFFFF0001
orl $0x3100, %ecx           # imm = 0x3100
movl %ecx, (%rax)
movq %rax, 0x28(%r12)
leaq 0x39e0c(%rip), %rbp     # 0x6d618
movq %rbp, 0x10(%r12)
movq 0x8(%r14), %r13
xorl %edi, %edi
callq 0x30029
movl (%rax), %ecx
orl $0x15, %ecx
movq %r13, 0x8(%rax)
andl $0xffff0015, %ecx       # imm = 0xFFFF0015
movl %ecx, (%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 0x338c1
cmpb $0x9, (%r14)
jne 0x338c1
testb $0x8, 0x56(%rbx)
je 0x3387a
movq 0x18(%rbx), %rdi
callq 0x2e465
movq 0x8(%r14), %rdi
leaq 0x176ee(%rip), %rsi     # 0x4af5e
movq %rax, %rdx
xorl %eax, %eax
callq 0x11a38
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 0x3765b
movq %rax, %rbx
movq %rax, 0x10(%r14)
movq %r14, %rdi
callq 0x377b2
jmp 0x338d9
leaq 0x17672(%rip), %rsi     # 0x4af3a
movq %r14, %rdi
xorl %eax, %eax
callq 0x11abc
leaq 0x39fdf(%rip), %rbx     # 0x6d8b8
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq