// File: /workspace/github_c_makefile_star2_O1/saltyJeff[P]uClibcpp/extra/config/./menu.c
// Function: menu_finalize
void menu_finalize(struct menu *parent)
{
	struct menu *menu, *last_menu;
	struct symbol *sym;
	struct property *prop;
	struct expr *parentdep, *basedep, *dep, *dep2, **ep;

	sym = parent->sym;
	if (parent->list) {
		if (sym && sym_is_choice(sym)) {
			/* find the first choice value and find out choice type */
			for (menu = parent->list; menu; menu = menu->next) {
				if (menu->sym) {
					current_entry = parent;
					menu_set_type(menu->sym->type);
					current_entry = menu;
					menu_set_type(sym->type);
					break;
				}
			}
			parentdep = expr_alloc_symbol(sym);
		} else if (parent->prompt)
			parentdep = parent->prompt->visible.expr;
		else
			parentdep = parent->dep;

		for (menu = parent->list; menu; menu = menu->next) {
			basedep = expr_transform(menu->dep);
			basedep = expr_alloc_and(expr_copy(parentdep), basedep);
			basedep = expr_eliminate_dups(basedep);
			menu->dep = basedep;
			if (menu->sym)
				prop = menu->sym->prop;
			else
				prop = menu->prompt;
			for (; prop; prop = prop->next) {
				if (prop->menu != menu)
					continue;
				dep = expr_transform(prop->visible.expr);
				dep = expr_alloc_and(expr_copy(basedep), dep);
				dep = expr_eliminate_dups(dep);
				if (menu->sym && menu->sym->type != S_TRISTATE)
					dep = expr_trans_bool(dep);
				prop->visible.expr = dep;
				if (prop->type == P_SELECT) {
					struct symbol *es = prop_get_symbol(prop);
					es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr,
							expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
				}
			}
		}
		for (menu = parent->list; menu; menu = menu->next)
			menu_finalize(menu);
	} else if (sym) {
		basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
		basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
		basedep = expr_eliminate_dups(expr_transform(basedep));
		last_menu = NULL;
		for (menu = parent->next; menu; menu = menu->next) {
			dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
			if (!expr_contains_symbol(dep, sym))
				break;
			if (expr_depends_symbol(dep, sym))
				goto next;
			dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no);
			dep = expr_eliminate_dups(expr_transform(dep));
			dep2 = expr_copy(basedep);
			expr_eliminate_eq(&dep, &dep2);
			expr_free(dep);
			if (!expr_is_yes(dep2)) {
				expr_free(dep2);
				break;
			}
			expr_free(dep2);
		next:
			menu_finalize(menu);
			menu->parent = parent;
			last_menu = menu;
		}
		if (last_menu) {
			parent->list = parent->next;
			parent->next = last_menu->next;
			last_menu->next = NULL;
		}
	}
	for (menu = parent->list; menu; menu = menu->next) {
		if (sym && sym_is_choice(sym) && menu->sym) {
			menu->sym->flags |= SYMBOL_CHOICEVAL;
			if (!menu->prompt)
				fprintf(stderr, "%s:%d:warning: choice value must have a prompt\n",
					menu->file->name, menu->lineno);
			for (prop = menu->sym->prop; prop; prop = prop->next) {
				if (prop->type == P_PROMPT && prop->menu != menu) {
					fprintf(stderr, "%s:%d:warning: choice values currently only support a single prompt\n",
						prop->file->name, prop->lineno);
					
				}
				if (prop->type == P_DEFAULT)
					fprintf(stderr, "%s:%d:warning: defaults for choice values not supported\n",
						prop->file->name, prop->lineno);
			}
			current_entry = menu;
			menu_set_type(sym->type);
			menu_add_symbol(P_CHOICE, sym, NULL);
			prop = sym_get_choice_prop(sym);
			for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)
				;
			*ep = expr_alloc_one(E_CHOICE, NULL);
			(*ep)->right.sym = menu->sym;
		}
		if (menu->list && (!menu->prompt || !menu->prompt->text)) {
			for (last_menu = menu->list; ; last_menu = last_menu->next) {
				last_menu->parent = parent;
				if (!last_menu->next)
					break;
			}
			last_menu->next = menu->next;
			menu->next = menu->list;
			menu->list = NULL;
		}
	}

	if (sym && !(sym->flags & SYMBOL_WARNED)) {
		struct symbol *sym2;
		if (sym->type == S_UNKNOWN)
			fprintf(stderr, "%s:%d:warning: config symbol defined without type\n",
				parent->file->name, parent->lineno);

		if (sym_is_choice(sym) && !parent->prompt)
			fprintf(stderr, "%s:%d:warning: choice must have a prompt\n",
				parent->file->name, parent->lineno);

		for (prop = sym->prop; prop; prop = prop->next) {
			switch (prop->type) {
			case P_DEFAULT:
				if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
				    prop->expr->type != E_SYMBOL)
					fprintf(stderr, "%s:%d:warning: default must be a single symbol\n",
						prop->file->name, prop->lineno);
				break;
			case P_SELECT:
				sym2 = prop_get_symbol(prop);
				if ((sym->type != S_BOOLEAN) || (sym2->type != S_BOOLEAN))
					fprintf(stderr, "%s:%d:warning: enable is only allowed with booleans\n",
						prop->file->name, prop->lineno);
				break;
			case P_RANGE:
				if (sym->type != S_INT && sym->type != S_HEX)
					fprintf(stderr, "%s:%d:warning: range is only allowed for int or hex symbols\n",
						prop->file->name, prop->lineno);
				if (!sym_string_valid(sym, prop->expr->left.sym->name) ||
				    !sym_string_valid(sym, prop->expr->right.sym->name))
					fprintf(stderr, "%s:%d:warning: range is invalid\n",
						prop->file->name, prop->lineno);
				break;
			default:
				;
			}
		}
		sym->flags |= SYMBOL_WARNED;
	}

	if (sym && !sym_is_optional(sym) && parent->prompt) {
		sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr,
				expr_alloc_and(parent->prompt->visible.expr,
					expr_alloc_symbol(&symbol_mod)));
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq 0x18(%rdi), %rax
leaq 0x10(%rdi), %r14
cmpq $0x0, 0x10(%rdi)
movq %rax, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movq %r14, 0x28(%rsp)
je 0x6659
testq %rax, %rax
je 0x6643
testb $0x10, 0x44(%rax)
jne 0x667d
movq 0x20(%rdi), %rax
testq %rax, %rax
je 0x66e5
movq 0x20(%rax), %rax
jmp 0x66e9
testq %rax, %rax
je 0x6a23
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x68e0
movq 0x20(%rax), %rdi
jmp 0x68e2
movq %r14, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x66b4
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x6680
movq %rdi, 0xfe08(%rip)      # 0x164a0
movl 0x18(%rax), %edi
callq 0x5ff1
movq %rbx, 0xfdf9(%rip)      # 0x164a0
movq 0x8(%rsp), %rax
movl 0x18(%rax), %edi
callq 0x5ff1
movl $0x18, %edi
callq 0x2220
movq %rax, %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl $0x7, (%rax)
movq 0x8(%rsp), %rax
movq %rcx, 0x20(%rsp)
movq %rax, 0x8(%rcx)
jmp 0x66ee
movq 0x28(%rdi), %rax
movq %rax, 0x20(%rsp)
movq (%r14), %r15
testq %r15, %r15
je 0x68c2
movq 0x28(%r15), %rdi
callq 0x9f4c
movq %rax, %r12
movq 0x20(%rsp), %rdi
callq 0x8f91
testq %rax, %rax
je 0x6743
movq %rax, %r13
testq %r12, %r12
je 0x6740
movl $0x18, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x2, (%rax)
movq %r13, 0x8(%rax)
movq %r12, 0x10(%rax)
movq %rax, %r12
jmp 0x6743
movq %r13, %r12
movq %r12, %rdi
callq 0x9b73
movq %rax, %r14
movq %rax, 0x28(%r15)
movq 0x18(%r15), %rax
leaq 0x48(%rax), %rcx
leaq 0x20(%r15), %rdx
testq %rax, %rax
cmoveq %rdx, %rcx
movq (%rcx), %rbx
testq %rbx, %rbx
je 0x68ba
movq %r14, 0x38(%rsp)
cmpq %r15, 0x38(%rbx)
jne 0x68ae
movq 0x20(%rbx), %rdi
callq 0x9f4c
movq %rax, 0x18(%rsp)
movq %r14, %rdi
callq 0x8f91
movq 0x18(%rsp), %r13
testq %rax, %rax
je 0x67ce
movq %rax, %rbp
testq %r13, %r13
je 0x67cb
movl $0x18, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x2, (%rax)
movq %rbp, 0x8(%rax)
movq %r13, 0x10(%rax)
movq %rax, %r13
jmp 0x67ce
movq %rbp, %r13
movq %r13, 0x18(%rsp)
movq %r13, %rdi
callq 0x9b73
movq %rax, 0x18(%rsp)
movq 0x18(%r15), %rcx
testq %rcx, %rcx
je 0x67fc
cmpl $0x2, 0x18(%rcx)
je 0x67fc
movq %rax, %rdi
callq 0x94c4
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rbp
movq %rbp, 0x20(%rbx)
cmpl $0x6, 0x10(%rbx)
jne 0x68ae
movq 0x30(%rbx), %rax
movq 0x8(%rax), %r14
movq 0x60(%r14), %rax
movq %rax, 0x40(%rsp)
movq 0x18(%r15), %r12
movl $0x18, %edi
callq 0x2220
movq %rax, %r13
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl $0x7, (%rax)
movq %r12, 0x8(%rax)
movq %rbp, %rdi
callq 0x8f91
testq %rax, %rax
je 0x687a
movq %rax, %rbp
movl $0x18, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x2, (%rax)
movq %r13, 0x8(%rax)
movq %rbp, 0x10(%rax)
movq %rax, %r13
movq 0x40(%rsp), %r12
testq %r12, %r12
je 0x68a5
movl $0x18, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x1, (%rax)
movq %r12, 0x8(%rax)
movq %r13, 0x10(%rax)
movq %rax, %r13
movq %r13, 0x60(%r14)
movq 0x38(%rsp), %r14
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x6776
movq (%r15), %r15
jmp 0x66f1
movq 0x28(%rsp), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x6a23
movq %r15, %rdi
callq 0x660c
movq (%r15), %r15
jmp 0x68ca
xorl %edi, %edi
leaq 0xf92f(%rip), %rdx      # 0x16218
movl $0x5, %esi
callq 0xa4bc
movq %rax, %rdi
callq 0x9f4c
movq %rax, %rdi
callq 0x9b73
movq %rax, %r12
movq 0x10(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x69f8
xorl %ebx, %ebx
leaq 0x30(%rsp), %r13
movq 0x8(%rsp), %r14
movq %rax, %r15
movq 0x20(%rax), %rax
leaq 0x20(%rax), %rcx
leaq 0x28(%r15), %rdx
testq %rax, %rax
cmoveq %rdx, %rcx
movq (%rcx), %rbp
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0xa1da
testl %eax, %eax
je 0x6a02
movq %rbp, %rdi
movq %r14, %rsi
callq 0xa246
testb %al, %al
jne 0x69d6
movq %rbp, %rdi
movl $0x5, %esi
leaq 0xf8a6(%rip), %rdx      # 0x16218
callq 0xa4bc
movq %rax, 0x18(%rsp)
movq %rax, %rdi
callq 0x9f4c
movq %rax, %rdi
callq 0x9b73
movq %rax, 0x18(%rsp)
movq %r12, %rdi
callq 0x8f91
movq %rax, 0x30(%rsp)
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x9090
movq 0x18(%rsp), %rdi
callq 0x9034
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x69d1
cmpl $0x7, (%rdi)
jne 0x69fd
leaq 0xf8bd(%rip), %rax      # 0x16288
cmpq %rax, 0x8(%rdi)
jne 0x69fd
callq 0x9034
movq %r15, %rdi
callq 0x660c
movq 0x10(%rsp), %rax
movq %rax, 0x8(%r15)
movq (%r15), %rax
movq %r15, %rbx
testq %rax, %rax
jne 0x6923
jmp 0x6a05
xorl %r15d, %r15d
jmp 0x6a05
callq 0x9034
movq %rbx, %r15
testq %r15, %r15
je 0x6a23
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x10(%rcx)
movq (%r15), %rax
movq %rax, (%rcx)
movq $0x0, (%r15)
movq 0x28(%rsp), %rax
movq (%rax), %r15
testq %r15, %r15
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
je 0x6b95
leaq 0x48(%r8), %r13
xorl %ebp, %ebp
testq %r8, %r8
je 0x6b39
testb $0x10, 0x44(%r8)
je 0x6b39
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x6b39
orb $0x20, 0x44(%rax)
cmpq $0x0, 0x20(%r15)
je 0x6b83
movq 0x18(%r15), %rax
movq 0x48(%rax), %r12
testq %r12, %r12
je 0x6abc
cmpl $0x1, 0x10(%r12)
jne 0x6a90
cmpq %r15, 0x38(%r12)
jne 0x6aad
cmpl $0x4, 0x10(%r12)
je 0x6a9e
movq (%r12), %r12
jmp 0x6a7c
movq %r12, %rdi
callq 0x2688
movq 0x8(%rsp), %r8
jmp 0x6a98
movq %r12, %rdi
callq 0x265c
movq 0x8(%rsp), %r8
jmp 0x6a90
movq %r15, 0xf9dd(%rip)      # 0x164a0
movq %r8, %rbx
movl 0x18(%r8), %edi
callq 0x5ff1
movl $0x5, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x606a
movq %r13, %rax
movq (%rax), %rax
testq %rax, %rax
je 0x6af1
cmpl $0x5, 0x10(%rax)
jne 0x6ae1
jmp 0x6af3
xorl %eax, %eax
addq $0x30, %rax
movq %rax, %rbx
movq (%rax), %rcx
leaq 0x8(%rcx), %rax
testq %rcx, %rcx
jne 0x6af7
movl $0x18, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rbp, 0x10(%rax)
movl $0x6, (%rax)
movq %rbp, 0x8(%rax)
movq %rax, (%rbx)
movq 0x18(%r15), %rcx
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x6b75
movq 0x20(%r15), %rcx
testq %rcx, %rcx
je 0x6b52
cmpq $0x0, 0x18(%rcx)
jne 0x6b75
movq %rax, %rdx
movq %rdx, %rcx
movq %rdi, 0x8(%rdx)
movq (%rdx), %rdx
testq %rdx, %rdx
jne 0x6b55
movq (%r15), %rdx
movq %rdx, (%rcx)
movq %rax, (%r15)
movq $0x0, 0x10(%r15)
movq (%r15), %r15
testq %r15, %r15
jne 0x6a44
jmp 0x6b95
movq %r15, %rdi
callq 0x2630
movq 0x8(%rsp), %r8
jmp 0x6a74
testq %r8, %r8
je 0x6d70
testb $-0x80, 0x45(%r8)
jne 0x6ccf
cmpl $0x0, 0x18(%r8)
je 0x6d7f
testb $0x10, 0x44(%r8)
je 0x6bc6
cmpq $0x0, 0x20(%rdi)
je 0x6d93
movq 0x48(%r8), %r15
testq %r15, %r15
je 0x6cca
leaq 0xb2ca(%rip), %rbx      # 0x11ea4
leaq 0xb251(%rip), %r12      # 0x11e32
leaq 0xb21a(%rip), %r13      # 0x11e02
movl 0x10(%r15), %eax
cmpl $0x7, %eax
je 0x6c3a
cmpl $0x6, %eax
je 0x6c21
cmpl $0x4, %eax
jne 0x6caf
movl 0x18(%r8), %eax
addl $-0x3, %eax
cmpl $0x2, %eax
ja 0x6caf
movq 0x30(%r15), %rax
cmpl $0x7, (%rax)
movq %r13, %rsi
je 0x6caf
jmp 0x6c9d
movq 0x30(%r15), %rax
testq %rax, %rax
je 0x6c88
movl (%rax), %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x6c88
movq 0x8(%rax), %rax
jmp 0x6c8a
movl 0x18(%r8), %eax
addl $-0x3, %eax
cmpl $0x2, %eax
jae 0x6cbd
movq 0x30(%r15), %r14
movq 0x8(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsp), %rdi
callq 0x8123
movq %rbx, %rsi
testb %al, %al
je 0x6c9d
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsp), %rdi
callq 0x8123
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
movq %rbx, %rsi
testb %al, %al
jne 0x6caf
jmp 0x6c9d
xorl %eax, %eax
cmpl $0x1, 0x18(%r8)
movq %r12, %rsi
jne 0x6c9d
cmpl $0x1, 0x18(%rax)
movq %r12, %rsi
je 0x6caf
movq %r15, %rdi
callq 0x2738
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
movq (%r15), %r15
testq %r15, %r15
jne 0x6be8
jmp 0x6cca
movq %r15, %rdi
callq 0x270c
jmp 0x6c46
orb $-0x80, 0x45(%r8)
testb $0x1, 0x45(%r8)
jne 0x6d70
movq 0x20(%rdi), %rax
testq %rax, %rax
je 0x6d70
movq 0x60(%r8), %rbx
movq 0x20(%rax), %r15
movl $0x18, %edi
callq 0x2220
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl $0x7, (%rax)
leaq 0xf5e1(%rip), %rax      # 0x162f8
movq %rax, 0x8(%r14)
testq %r15, %r15
je 0x6d41
movl $0x18, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x2, (%rax)
movq %r15, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %rax, %r14
testq %rbx, %rbx
je 0x6d67
movl $0x18, %edi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x1, (%rax)
movq %rbx, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %rax, %r14
movq 0x8(%rsp), %rax
movq %r14, 0x60(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x26b4
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
jmp 0x6bb4
callq 0x26e0
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
jmp 0x6bc6