// File: /workspace/github_c_makefile_star2_O3/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 %rdi, %rcx
movq 0x10(%rdi), %rbx
movq 0x18(%rdi), %r15
leaq 0x10(%rdi), %rax
movq %rax, 0x20(%rsp)
testq %rbx, %rbx
movq %r15, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
je 0x5ff6
testq %r15, %r15
je 0x5fd6
testb $0x10, 0x44(%r15)
jne 0x6015
movq 0x20(%rcx), %rax
addq $0x28, %rcx
leaq 0x20(%rax), %rdx
testq %rax, %rax
cmoveq %rcx, %rdx
movq (%rdx), %rax
movq %rax, 0x28(%rsp)
jmp 0x6078
testq %r15, %r15
je 0x66ff
movq 0x20(%rcx), %rax
testq %rax, %rax
je 0x625a
movq 0x20(%rax), %rdi
jmp 0x625c
movq 0x20(%rsp), %r14
movq (%r14), %r14
testq %r14, %r14
je 0x6051
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x601a
movq %rcx, 0xf46e(%rip)      # 0x154a0
movl 0x18(%rax), %edi
movq %rcx, %rbx
callq 0x5970
movq %r14, 0xf45c(%rip)      # 0x154a0
movl 0x18(%r15), %edi
callq 0x5970
movq 0x10(%rbx), %rbx
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl $0x7, (%rax)
movq %rax, 0x28(%rsp)
movq %r15, 0x8(%rax)
testq %rbx, %rbx
je 0x639d
movq 0x28(%rbx), %rdi
callq 0x97f1
movq %rax, %r12
movq 0x28(%rsp), %rdi
callq 0x88c5
testq %rax, %rax
je 0x60c0
movq %rax, %r13
testq %r12, %r12
je 0x60bd
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl $0x2, (%rax)
movq %r13, 0x8(%rax)
movq %r12, 0x10(%rax)
movq %rax, %r12
jmp 0x60c0
movq %r13, %r12
movq %r12, %rdi
callq 0x9461
movq %rax, %r14
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rax
leaq 0x48(%rax), %rcx
leaq 0x20(%rbx), %rdx
testq %rax, %rax
cmoveq %rdx, %rcx
movq (%rcx), %r15
testq %r15, %r15
je 0x621e
movq %r14, 0x38(%rsp)
cmpq %rbx, 0x38(%r15)
jne 0x6212
movq 0x20(%r15), %rdi
callq 0x97f1
movq %rax, %r13
movq %r14, %rdi
callq 0x88c5
testq %rax, %rax
je 0x6143
movq %rax, %rbp
testq %r13, %r13
je 0x6140
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl $0x2, (%rax)
movq %rbp, 0x8(%rax)
movq %r13, 0x10(%rax)
movq %rax, %r13
jmp 0x6143
movq %rbp, %r13
movq %r13, %rdi
callq 0x9461
movq %rax, %rbp
movq %rax, 0x18(%rsp)
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x616f
cmpl $0x2, 0x18(%rax)
je 0x616f
movq %rbp, %rdi
callq 0x8dd6
movq %rbp, 0x18(%rsp)
movq %rbp, 0x20(%r15)
cmpl $0x6, 0x10(%r15)
jne 0x6212
movq 0x30(%r15), %rax
movq 0x8(%rax), %r14
movq 0x60(%r14), %rax
movq %rax, 0x40(%rsp)
movq 0x18(%rbx), %r12
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movq %rax, %r13
movl $0x7, (%rax)
movq %r12, 0x8(%rax)
movq %rbp, %rdi
callq 0x88c5
testq %rax, %rax
je 0x61df
movq %rax, %rbp
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl $0x2, (%rax)
movq %r13, 0x8(%rax)
movq %rbp, 0x10(%rax)
movq %rax, %r13
movq 0x40(%rsp), %r12
testq %r12, %r12
je 0x6209
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl $0x1, (%rax)
movq %r12, 0x8(%rax)
movq %r13, 0x10(%rax)
movq %rax, %r13
movq %r13, 0x60(%r14)
movq 0x38(%rsp), %r14
movq (%r15), %r15
testq %r15, %r15
jne 0x60f3
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x6078
movq 0x20(%rsp), %rax
movq (%rax), %r15
testq %r15, %r15
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r8
je 0x6530
movq %r15, %rdi
callq 0x5f99
movq (%r15), %r15
testq %r15, %r15
jne 0x6245
jmp 0x639d
xorl %edi, %edi
leaq 0xefb5(%rip), %rdx      # 0x15218
movl $0x5, %esi
callq 0x9d57
movq %rax, %rdi
callq 0x97f1
movq %rax, %rdi
callq 0x9461
movq %rax, %r15
movq 0x8(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x639d
xorl %ebx, %ebx
leaq 0x30(%rsp), %r13
movq 0x10(%rsp), %r14
movq %rax, %r12
movq 0x20(%rax), %rax
leaq 0x20(%rax), %rcx
leaq 0x28(%r12), %rdx
testq %rax, %rax
cmoveq %rdx, %rcx
movq (%rcx), %rbp
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x9a79
testl %eax, %eax
je 0x637a
movq %rbp, %rdi
movq %r14, %rsi
callq 0x9afd
testb %al, %al
jne 0x6351
movq %rbp, %rdi
movl $0x5, %esi
leaq 0xef2b(%rip), %rdx      # 0x15218
callq 0x9d57
movq %rax, 0x18(%rsp)
movq %rax, %rdi
callq 0x97f1
movq %rax, %rdi
callq 0x9461
movq %rax, 0x18(%rsp)
movq %r15, %rdi
callq 0x88c5
movq %rax, 0x30(%rsp)
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x89c7
movq 0x18(%rsp), %rdi
callq 0x8968
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x634c
cmpl $0x7, (%rdi)
jne 0x6375
leaq 0xef42(%rip), %rax      # 0x15288
cmpq %rax, 0x8(%rdi)
jne 0x6375
callq 0x8968
movq %r12, %rdi
callq 0x5f99
movq 0x8(%rsp), %rax
movq %rax, 0x8(%r12)
movq (%r12), %rax
movq %r12, %rbx
testq %rax, %rax
jne 0x629d
jmp 0x6382
callq 0x8968
movq %rbx, %r12
testq %rbx, %rbx
je 0x639d
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x10(%rcx)
movq (%r12), %rax
movq %rax, (%rcx)
movq $0x0, (%r12)
movq 0x20(%rsp), %rax
movq (%rax), %r15
testq %r15, %r15
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r8
je 0x6530
leaq 0x48(%r13), %rbx
movq 0xec35(%rip), %rbp      # 0x14ff8
leaq 0xa93d(%rip), %r12      # 0x10d07
testq %r13, %r13
je 0x64ba
testb $0x10, 0x44(%r13)
je 0x64ba
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x64ba
orb $0x20, 0x44(%rax)
cmpq $0x0, 0x20(%r15)
je 0x6509
movq 0x48(%rax), %r13
testq %r13, %r13
je 0x6445
movl 0x10(%r13), %eax
cmpl $0x1, %eax
jne 0x6430
cmpq %r15, 0x38(%r13)
je 0x6435
movq (%rbp), %rdi
movq 0x40(%r13), %rax
movq 0x10(%rax), %rdx
movl 0x48(%r13), %ecx
movq %r12, %rsi
xorl %eax, %eax
callq 0x21b0
movl 0x10(%r13), %eax
cmpl $0x4, %eax
je 0x643b
movq (%r13), %r13
jmp 0x63fe
movq %r13, %rdi
callq 0x25fa
jmp 0x6435
movq %r15, 0xf054(%rip)      # 0x154a0
movq 0x10(%rsp), %r13
movl 0x18(%r13), %edi
callq 0x5970
movl $0x5, %edi
movq %r13, %rsi
xorl %edx, %edx
callq 0x59e9
movq %rbx, %rax
movq (%rax), %rax
testq %rax, %rax
je 0x647a
cmpl $0x5, 0x10(%rax)
jne 0x646c
addq $0x30, %rax
movq %rax, %r14
movq (%rax), %rcx
leaq 0x8(%rcx), %rax
testq %rcx, %rcx
jne 0x647e
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl $0x6, (%rax)
movq $0x0, 0x8(%rax)
movq %rax, (%r14)
movq 0x18(%r15), %rcx
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %r8
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x64d3
movq 0x20(%r15), %rcx
testq %rcx, %rcx
je 0x64d8
cmpq $0x0, 0x18(%rcx)
je 0x64d8
movq (%r15), %rax
jmp 0x64fb
movq %rax, %rdx
movq %rdx, %rcx
movq %r8, 0x8(%rdx)
movq (%rdx), %rdx
testq %rdx, %rdx
jne 0x64db
movq (%r15), %rdx
movq %rdx, (%rcx)
movq %rax, (%r15)
movq $0x0, 0x10(%r15)
movq %rax, %r15
testq %rax, %rax
jne 0x63ca
jmp 0x6530
movq (%rbp), %rdi
movq 0x38(%r15), %rax
movq 0x10(%rax), %rdx
movl 0x40(%r15), %ecx
leaq 0xa7b7(%rip), %rsi      # 0x10cd7
xorl %eax, %eax
callq 0x21b0
movq 0x18(%r15), %rax
jmp 0x63fa
testq %r13, %r13
je 0x66ff
movl 0x44(%r13), %eax
testw %ax, %ax
js 0x6673
cmpl $0x0, 0x18(%r13)
je 0x670e
testb $0x10, %al
je 0x6560
cmpq $0x0, 0x20(%r8)
je 0x6740
movq 0x48(%r13), %r15
testq %r15, %r15
je 0x6661
leaq 0xa910(%rip), %rbx      # 0x10e84
leaq 0xa897(%rip), %r12      # 0x10e12
leaq 0xa860(%rip), %r13      # 0x10de2
movq 0x10(%rsp), %rbp
movl 0x10(%r15), %eax
cmpl $0x7, %eax
je 0x65dd
cmpl $0x6, %eax
je 0x65c4
cmpl $0x4, %eax
jne 0x6649
movq 0x10(%rsp), %rax
movl 0x18(%rax), %eax
addl $-0x3, %eax
cmpl $0x2, %eax
ja 0x6649
movq 0x30(%r15), %rax
cmpl $0x7, (%rax)
movq %r13, %rsi
je 0x6649
jmp 0x663c
movq 0x30(%r15), %rax
testq %rax, %rax
je 0x6623
movl (%rax), %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x6623
movq 0x8(%rax), %rax
jmp 0x6625
movl 0x18(%rbp), %eax
addl $-0x3, %eax
cmpl $0x2, %eax
jae 0x6657
movq 0x30(%r15), %r14
movq 0x8(%r14), %rax
movq 0x8(%rax), %rsi
movq %rbp, %rdi
callq 0x7ab5
movq %rbx, %rsi
testb %al, %al
je 0x663c
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rsp), %rdi
callq 0x7ab5
movq 0x8(%rsp), %r8
movq %rbx, %rsi
testb %al, %al
jne 0x6649
jmp 0x663c
xorl %eax, %eax
movq 0x10(%rsp), %rcx
cmpl $0x1, 0x18(%rcx)
movq %r12, %rsi
jne 0x663c
cmpl $0x1, 0x18(%rax)
movq %r12, %rsi
je 0x6649
movq %r15, %rdi
callq 0x267e
movq 0x8(%rsp), %r8
movq (%r15), %r15
testq %r15, %r15
jne 0x6587
jmp 0x6661
movq %r15, %rdi
callq 0x2652
jmp 0x65e8
movl $0x8000, %eax           # imm = 0x8000
movq 0x10(%rsp), %r13
orl 0x44(%r13), %eax
movl %eax, 0x44(%r13)
btl $0x8, %eax
jb 0x66ff
movq 0x20(%r8), %rax
testq %rax, %rax
je 0x66ff
movq 0x60(%r13), %rbx
movq 0x20(%rax), %r15
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movq %rax, %r14
movl $0x7, (%rax)
leaq 0xec4b(%rip), %rax      # 0x152f8
movq %rax, 0x8(%r14)
testq %r15, %r15
je 0x66d6
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl $0x2, (%rax)
movq %r15, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %rax, %r14
testq %rbx, %rbx
je 0x66fb
movl $0x1, %edi
movl $0x18, %esi
callq 0x2180
movl $0x1, (%rax)
movq %rbx, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %rax, %r14
movq %r14, 0x60(%r13)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xe8e3(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movq 0x38(%r8), %rax
movq 0x10(%rax), %rdx
movl 0x40(%r8), %ecx
leaq 0xa65a(%rip), %rsi      # 0x10d85
xorl %eax, %eax
callq 0x21b0
movq 0x8(%rsp), %r8
movl 0x44(%r13), %eax
jmp 0x6551
movq %r8, %rdi
callq 0x2626
movq 0x8(%rsp), %r8
jmp 0x6560