// File: /workspace/github_c_makefile_star2_O3/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 $0x138, %rsp            # imm = 0x138
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
callq 0x32223
testq %rax, %rax
je 0x36229
movq 0x20(%rbx), %rdi
callq 0x32bf6
testq %rax, %rax
je 0x36229
leaq 0x58(%rsp), %r14
movl $0xe0, %edx
movq %r14, %rdi
movq %rax, (%rsp)
movq %rax, %rsi
callq 0xe1e0
andb $-0x1f, 0x69(%r14)
movq 0x30(%rbx), %r12
testq %r12, %r12
je 0x3622d
leaq 0x1450a(%rip), %r13     # 0x4a660
leaq 0x14526(%rip), %r15     # 0x4a683
movq (%r12), %rbp
movq %rbp, %rdi
callq 0x35be9
testq %rax, %rax
je 0x361b8
movq 0x60(%rbp), %r14
movzbl (%r14), %eax
cmpl $0x6, %eax
jne 0x3619b
movq 0x58(%r14), %rdi
testq %rdi, %rdi
je 0x3619b
callq 0xf4bf
movq 0x58(%r14), %rax
cmpb $0x1, (%rax)
leaq 0x14499(%rip), %rsi     # 0x4a630
jne 0x361ad
jmp 0x361b8
movzbl (%rbp), %ecx
cmpl $0x3, %ecx
cmovnel %ecx, %eax
movq %r13, %rsi
cmpl $0x5, %eax
jne 0x361c4
movq 0x4(%rbp), %rdi
xorl %eax, %eax
callq 0x11a80
movq 0x10(%r12), %r12
testq %r12, %r12
jne 0x3615d
jmp 0x3622d
cmpl $0x3, %ecx
cmovneq %rbp, %r14
movq %r15, %rsi
cmpq 0x29d73(%rip), %r14     # 0x5ff48
je 0x361ad
cmpl $0x0, 0x50(%rbp)
movq %r15, %rsi
jle 0x361ad
leaq 0x38(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
leaq 0x58(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x10(%rsp), %rax
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq %rbp, 0x8(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x31898
testq %rax, %rax
jne 0x361b8
movq 0x8(%r12), %rax
jmp 0x36236
xorl %ebx, %ebx
jmp 0x36281
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x36261
movaps (%rax), %xmm0
movaps 0x10(%rax), %xmm1
movaps 0x20(%rax), %xmm2
movaps 0x30(%rax), %xmm3
movaps %xmm3, 0x30(%rbx)
movaps %xmm2, 0x20(%rbx)
movaps %xmm1, 0x10(%rbx)
movaps %xmm0, (%rbx)
movq %rbx, %rdi
callq 0x32223
movq %rax, %rbx
jmp 0x36281
movq (%rsp), %rdi
callq 0x237c5
movq 0x8(%rbx), %rdi
leaq 0x14433(%rip), %rsi     # 0x4a6a8
xorl %ebx, %ebx
movq %rax, %rdx
xorl %eax, %eax
callq 0x11a80
movq %rbx, %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq