// File: /workspace/github_c_makefile_star2_O2/saltyJeff[P]uClibcpp/extra/config/./symbol.c
// Function: sym_calc_value
void sym_calc_value(struct symbol *sym)
{
	struct symbol_value newval, oldval;
	struct property *prop;
	struct expr *e;

	if (!sym)
		return;

	if (sym->flags & SYMBOL_VALID)
		return;
	sym->flags |= SYMBOL_VALID;

	oldval = sym->curr;

	switch (sym->type) {
	case S_INT:
	case S_HEX:
	case S_STRING:
		newval = symbol_empty.curr;
		break;
	case S_BOOLEAN:
	case S_TRISTATE:
		newval = symbol_no.curr;
		break;
	default:
		sym->curr.val = sym->name;
		sym->curr.tri = no;
		return;
	}
	if (!sym_is_choice_value(sym))
		sym->flags &= ~SYMBOL_WRITE;

	sym_calc_visibility(sym);

	/* set default if recursively called */
	sym->curr = newval;

	switch (sym_get_type(sym)) {
	case S_BOOLEAN:
	case S_TRISTATE:
		if (sym_is_choice_value(sym) && sym->visible == yes) {
			prop = sym_get_choice_prop(sym);
			newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
		} else if (E_OR(sym->visible, sym->rev_dep.tri) != no) {
			sym->flags |= SYMBOL_WRITE;
			if (sym_has_value(sym))
				newval.tri = sym->user.tri;
			else if (!sym_is_choice(sym)) {
				prop = sym_get_default_prop(sym);
				if (prop)
					newval.tri = expr_calc_value(prop->expr);
			}
			newval.tri = E_OR(E_AND(newval.tri, sym->visible), sym->rev_dep.tri);
		} else if (!sym_is_choice(sym)) {
			prop = sym_get_default_prop(sym);
			if (prop) {
				sym->flags |= SYMBOL_WRITE;
				newval.tri = expr_calc_value(prop->expr);
			}
		}
		if (sym_get_type(sym) == S_BOOLEAN) {
			if (newval.tri == mod)
				newval.tri = yes;
			if (sym->visible == mod)
				sym->visible = yes;
			if (sym->rev_dep.tri == mod)
				sym->rev_dep.tri = yes;
		}
		break;
	case S_STRING:
	case S_HEX:
	case S_INT:
		if (sym->visible != no) {
			sym->flags |= SYMBOL_WRITE;
			if (sym_has_value(sym)) {
				newval.val = sym->user.val;
				break;
			}
		}
		prop = sym_get_default_prop(sym);
		if (prop) {
			struct symbol *ds = prop_get_symbol(prop);
			if (ds) {
				sym->flags |= SYMBOL_WRITE;
				sym_calc_value(ds);
				newval.val = ds->curr.val;
			}
		}
		break;
	default:
		;
	}

	sym->curr = newval;
	if (sym_is_choice(sym) && newval.tri == yes)
		sym->curr.val = sym_calc_choice(sym);

	if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
		sym_set_changed(sym);

	if (sym_is_choice(sym)) {
		int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
		prop = sym_get_choice_prop(sym);
		for (e = prop->expr; e; e = e->left.expr) {
			e->right.sym->flags |= flags;
			if (flags & SYMBOL_CHANGED)
				sym_set_changed(e->right.sym);
		}
	}
}

// Assembly:
testq %rdi, %rdi
je 0x7485
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x44(%rdi), %eax
testb %al, %al
js 0x7477
movl %eax, %ecx
orl $0x80, %ecx
movl %ecx, 0x44(%rbx)
movdqu 0x20(%rbx), %xmm0
movdqa %xmm0, (%rsp)
movl 0x18(%rbx), %edx
decl %edx
cmpl $0x5, %edx
jae 0x726c
movl %edx, %edx
leaq 0xcb59(%rip), %rsi      # 0x13d50
movq (%rsi,%rdx,8), %rsi
leaq 0xcb76(%rip), %rdi      # 0x13d78
movq (%rdi,%rdx,8), %rdi
leaq 0xcb93(%rip), %r8       # 0x13da0
movq (%r8,%rdx,8), %rdx
movl (%rdx), %r15d
movl (%rdi), %ebp
movq (%rsi), %r12
testb $0x20, %al
jne 0x7226
andl $0xfffffddf, %ecx       # imm = 0xFFFFFDDF
movl %ecx, 0x44(%rbx)
movq %rbx, %rdi
callq 0x9665
movq %r12, 0x20(%rbx)
movl %ebp, 0x28(%rbx)
movl %r15d, 0x2c(%rbx)
movq %rbx, %rdi
callq 0x95b6
leal -0x3(%rax), %ecx
cmpl $0x3, %ecx
jae 0x727d
cmpl $0x0, 0x40(%rbx)
je 0x72c4
movl 0x44(%rbx), %eax
movl %eax, %ecx
orl $0x200, %ecx            # imm = 0x200
movl %ecx, 0x44(%rbx)
btl $0xb, %eax
jb 0x72c4
movq 0x30(%rbx), %r12
jmp 0x7399
movq 0x8(%rbx), %rax
movq %rax, 0x20(%rbx)
andl $0x0, 0x28(%rbx)
jmp 0x7477
decl %eax
cmpl $0x1, %eax
ja 0x7399
movl 0x40(%rbx), %ecx
movl 0x44(%rbx), %eax
movl %eax, %edx
shrb $0x5, %dl
cmpl $0x2, %ecx
sete %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x72fe
movq %rbx, %rdi
callq 0x7194
movq %rax, %rdi
callq 0x7179
xorl %ebp, %ebp
cmpq %rbx, 0x20(%rax)
sete %bpl
addl %ebp, %ebp
jmp 0x7367
movq %rbx, %rdi
callq 0x960f
testq %rax, %rax
je 0x7399
movq %rax, %rdi
callq 0x7179
testq %rax, %rax
je 0x7399
movq %rax, %r14
orb $0x2, 0x45(%rbx)
movq %rax, %rdi
callq 0x71aa
movq 0x20(%r14), %r12
jmp 0x7399
orl 0x68(%rbx), %ecx
je 0x7319
movl %eax, %ecx
orl $0x200, %ecx            # imm = 0x200
movl %ecx, 0x44(%rbx)
btl $0xb, %eax
jb 0x7339
movl 0x38(%rbx), %ebp
jmp 0x7355
testb $0x10, %al
jne 0x7367
movq %rbx, %rdi
callq 0x960f
testq %rax, %rax
je 0x7367
orb $0x2, 0x45(%rbx)
movq 0x30(%rax), %rdi
callq 0x9165
jmp 0x7365
testb $0x10, %al
jne 0x7355
movq %rbx, %rdi
callq 0x960f
testq %rax, %rax
je 0x7355
movq 0x30(%rax), %rdi
callq 0x9165
movl %eax, %ebp
movl 0x40(%rbx), %eax
movl 0x68(%rbx), %ecx
cmpl %eax, %ebp
cmovbl %ebp, %eax
cmpl %ecx, %eax
cmovbel %ecx, %eax
movl %eax, %ebp
movq %rbx, %rdi
callq 0x95b6
cmpl $0x1, %eax
jne 0x7399
cmpl $0x1, %ebp
pushq $0x2
popq %rax
cmovnel %ebp, %eax
cmpl $0x1, 0x40(%rbx)
jne 0x738a
movl $0x2, 0x40(%rbx)
cmpl $0x1, 0x68(%rbx)
jne 0x739b
movl $0x2, 0x68(%rbx)
jmp 0x739b
movl %ebp, %eax
leaq 0x20(%rbx), %r13
movq %r12, 0x20(%rbx)
movl %eax, 0x28(%rbx)
movl %r15d, 0x2c(%rbx)
testb $0x10, 0x44(%rbx)
je 0x7450
cmpl $0x2, %eax
jne 0x7450
movq 0x30(%rbx), %r14
testq %r14, %r14
je 0x73d5
movq %r14, %rdi
callq 0x9665
cmpl $0x0, 0x40(%r14)
jne 0x744c
leaq 0x48(%rbx), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x7415
cmpl $0x4, 0x10(%r15)
jne 0x73d9
movq 0x20(%r15), %rdi
callq 0x9165
movl %eax, 0x28(%r15)
testl %eax, %eax
je 0x73d9
movq %r15, %rdi
callq 0x7179
movq %rax, %r14
movq %rax, %rdi
callq 0x9665
cmpl $0x0, 0x40(%r14)
je 0x73d9
jmp 0x744c
movq %rbx, %rdi
callq 0x7194
movq %rax, %r15
addq $0x30, %r15
movq (%r15), %r15
testq %r15, %r15
je 0x7445
movq 0x10(%r15), %r14
movq %r14, %rdi
callq 0x9665
addq $0x8, %r15
cmpl $0x0, 0x40(%r14)
je 0x7424
jmp 0x744c
andl $0x0, 0x28(%rbx)
xorl %r14d, %r14d
movq %r14, (%r13)
movdqu (%r13), %xmm0
pcmpeqb (%rsp), %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x746e
movq %rbx, %rdi
callq 0x96d6
movl 0x44(%rbx), %ebp
testb $0x10, %bpl
jne 0x7486
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %r14d
andl $0x600, %r14d           # imm = 0x600
movq %rbx, %rdi
callq 0x7194
movq %rax, %rbx
addq $0x30, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x7477
movq 0x10(%rbx), %rax
orl %r14d, 0x44(%rax)
btl $0xa, %ebp
jae 0x74be
movq 0x10(%rbx), %rdi
callq 0x96d6
addq $0x8, %rbx
jmp 0x749f