// File: /workspace/github_c_makefile_star2_O1/lucvoo[P]sparse-dev/evaluate.c
// Function: evaluate_generic_selection
static struct symbol *evaluate_generic_selection(struct expression *expr)
{
	struct type_expression *map;
	struct expression *res;
	struct symbol source;
	struct symbol *ctrl;

	if (!evaluate_expression(expr->control))
		return NULL;
	if (!(ctrl = degenerate(expr->control)))
		return NULL;

	source = *ctrl;
	source.ctype.modifiers &= ~(MOD_QUALIFIER|MOD_ATOMIC);
	for (map = expr->map; map; map = map->next) {
		struct symbol *stype = map->type;
		struct symbol *base;

		if (!evaluate_symbol(stype))
			continue;

		base = stype->ctype.base_type;
		if (base->type == SYM_ARRAY && base->array_size) {
			get_expression_value_silent(base->array_size);
			if (base->array_size->type == EXPR_VALUE)
				continue;
			sparse_error(stype->pos, "variable length array type in generic selection");
			continue;
		}
		if (is_func_type(stype)) {
			sparse_error(stype->pos, "function type in generic selection");
			continue;
		}
		if (stype->bit_size <= 0 || is_void_type(stype)) {
			sparse_error(stype->pos, "incomplete type in generic selection");
			continue;
		}
		if (!type_selection(&source, stype))
			continue;

		res = map->expr;
		goto found;
	}
	res = expr->def;
	if (!res) {
		sparse_error(expr->pos, "no generic selection for '%s'", show_typename(ctrl));
		return NULL;
	}

found:
	*expr = *res;
	return evaluate_expression(expr);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
callq 0x32c63
testq %rax, %rax
je 0x36d73
movq 0x20(%rbx), %rdi
callq 0x33628
testq %rax, %rax
je 0x36d73
leaq 0x68(%rsp), %r14
movl $0xe0, %edx
movq %r14, %rdi
movq %rax, 0x8(%rsp)
movq %rax, %rsi
callq 0xe1e0
andb $-0x1f, 0x69(%r14)
movq 0x30(%rbx), %rbp
testq %rbp, %rbp
je 0x36d3a
movq (%rbp), %r12
movq %r12, %rdi
callq 0x366a3
movb $0x1, %r15b
testq %rax, %rax
je 0x36d28
movq 0x60(%r12), %r14
cmpb $0x6, (%r14)
jne 0x36c88
movq 0x58(%r14), %rdi
testq %rdi, %rdi
je 0x36c88
callq 0xf2fb
movq 0x58(%r14), %rax
cmpb $0x1, (%rax)
je 0x36d28
movq 0x4(%r12), %rdi
leaq 0x14a3d(%rip), %rsi     # 0x4b6c0
jmp 0x36d21
movzbl (%r12), %eax
cmpl $0x3, %eax
movq %r12, %rcx
cmoveq %r14, %rcx
cmpb $0x5, (%rcx)
jne 0x36caa
movq 0x4(%r12), %rdi
leaq 0x14a48(%rip), %rsi     # 0x4b6f0
jmp 0x36d21
cmpl $0x3, %eax
cmovneq %r12, %r14
cmpq 0x2a280(%rip), %r14     # 0x60f38
je 0x36d15
cmpl $0x0, 0x50(%r12)
jle 0x36d15
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x50(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x60(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x10(%rsp)
movq %rcx, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq %r12, 0x10(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x32020
testq %rax, %rax
jne 0x36d28
movq 0x8(%rbp), %r13
xorl %r15d, %r15d
jmp 0x36d28
movq 0x4(%r12), %rdi
leaq 0x149f2(%rip), %rsi     # 0x4b713
xorl %eax, %eax
callq 0x11a38
testb %r15b, %r15b
je 0x36d43
movq 0x10(%rbp), %rbp
testq %rbp, %rbp
jne 0x36c39
movq 0x28(%rbx), %r13
testq %r13, %r13
je 0x36d8a
movaps (%r13), %xmm0
movaps 0x10(%r13), %xmm1
movaps 0x20(%r13), %xmm2
movaps 0x30(%r13), %xmm3
movaps %xmm3, 0x30(%rbx)
movaps %xmm2, 0x20(%rbx)
movaps %xmm1, 0x10(%rbx)
movaps %xmm0, (%rbx)
movq %rbx, %rdi
callq 0x32c63
movq %rax, %rbx
jmp 0x36d75
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
callq 0x2386c
movq 0x8(%rbx), %rdi
leaq 0x14999(%rip), %rsi     # 0x4b738
xorl %ebx, %ebx
movq %rax, %rdx
xorl %eax, %eax
callq 0x11a38
jmp 0x36d75