// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x4bb70
cmpq $0x0, %rax
jne 0x4fabf
movq $0x0, -0x8(%rbp)
jmp 0x4fcda
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x4c1c0
movq %rax, -0x108(%rbp)
cmpq $0x0, %rax
jne 0x4fae6
movq $0x0, -0x8(%rbp)
jmp 0x4fcda
movq -0x108(%rbp), %rsi
leaq -0x100(%rbp), %rdi
movl $0xe0, %edx
callq 0x111d0
movq -0x98(%rbp), %rax
andq $-0x1e01, %rax          # imm = 0xE1FF
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x4fc69
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rdi
callq 0x4f490
cmpq $0x0, %rax
jne 0x4fb4e
jmp 0x4fc58
movq -0x110(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x6, %eax
jne 0x4fbcb
movq -0x118(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x4fbcb
movq -0x118(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x12190
movq -0x118(%rbp), %rax
movq 0x58(%rax), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x4fbad
jmp 0x4fc58
movq -0x110(%rbp), %rax
movq 0x4(%rax), %rdi
leaq 0x1c791(%rip), %rsi     # 0x6c350
movb $0x0, %al
callq 0x16f90
jmp 0x4fc58
movq -0x110(%rbp), %rdi
callq 0x52860
cmpl $0x0, %eax
je 0x4fbf7
movq -0x110(%rbp), %rax
movq 0x4(%rax), %rdi
leaq 0x1c792(%rip), %rsi     # 0x6c380
movb $0x0, %al
callq 0x16f90
jmp 0x4fc58
movq -0x110(%rbp), %rax
cmpl $0x0, 0x50(%rax)
jle 0x4fc15
movq -0x110(%rbp), %rdi
callq 0x52630
cmpl $0x0, %eax
je 0x4fc30
movq -0x110(%rbp), %rax
movq 0x4(%rax), %rdi
leaq 0x1c77c(%rip), %rsi     # 0x6c3a3
movb $0x0, %al
callq 0x16f90
jmp 0x4fc58
movq -0x110(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x53c60
cmpl $0x0, %eax
jne 0x4fc4a
jmp 0x4fc58
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x4fcbb
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x4fb1e
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x4fcb9
movq -0x10(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x108(%rbp), %rdi
callq 0x33340
movq %rax, %rdx
movq -0x120(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1c720(%rip), %rsi     # 0x6c3c8
movb $0x0, %al
callq 0x16f90
movq $0x0, -0x8(%rbp)
jmp 0x4fcda
jmp 0x4fcbb
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x40, %edx
callq 0x111d0
movq -0x10(%rbp), %rdi
callq 0x4bb70
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)