// File: /workspace/github_c_makefile_star2_O1/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 0x85b7
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 0x85a9
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 0x8306
movl %edx, %edx
leaq 0xda8f(%rip), %rsi      # 0x15d20
movq (%rsi,%rdx,8), %rsi
leaq 0xdaac(%rip), %rdi      # 0x15d48
movq (%rdi,%rdx,8), %rdi
leaq 0xdac9(%rip), %r8       # 0x15d70
movq (%r8,%rdx,8), %rdx
movl (%rdx), %r15d
movl (%rdi), %ebp
movq (%rsi), %r12
testb $0x20, %al
jne 0x82c0
andl $0xfffffddf, %ecx       # imm = 0xFFFFFDDF
movl %ecx, 0x44(%rbx)
movq %rbx, %rdi
callq 0xad68
movq %r12, 0x20(%rbx)
movl %ebp, 0x28(%rbx)
movl %r15d, 0x2c(%rbx)
movq %rbx, %rdi
callq 0xacb7
leal -0x3(%rax), %ecx
cmpl $0x3, %ecx
jae 0x831a
cmpl $0x0, 0x40(%rbx)
je 0x8358
movl 0x44(%rbx), %eax
movl %eax, %ecx
orl $0x200, %ecx            # imm = 0x200
movl %ecx, 0x44(%rbx)
btl $0xb, %eax
jb 0x8358
movq 0x30(%rbx), %r12
jmp 0x8443
movq 0x8(%rbx), %rax
movq %rax, 0x20(%rbx)
movl $0x0, 0x28(%rbx)
jmp 0x85a9
decl %eax
cmpl $0x1, %eax
ja 0x8443
movl 0x44(%rbx), %eax
testb $0x20, %al
je 0x8382
cmpl $0x2, 0x40(%rbx)
jne 0x8382
leaq 0x48(%rbx), %rax
movq (%rax), %rax
cmpl $0x5, 0x10(%rax)
jne 0x8336
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
xorl %ebp, %ebp
cmpq %rbx, 0x20(%rax)
sete %bpl
addl %ebp, %ebp
jmp 0x840f
movq %rbx, %rdi
callq 0xad10
testq %rax, %rax
je 0x8443
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x83a0
movl (%rax), %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x83a0
movq 0x8(%rax), %r14
jmp 0x83a3
movl 0x68(%rbx), %ecx
orl 0x40(%rbx), %ecx
je 0x83c1
movl %eax, %ecx
orl $0x200, %ecx            # imm = 0x200
movl %ecx, 0x44(%rbx)
btl $0xb, %eax
jb 0x83e1
movl 0x38(%rbx), %ebp
jmp 0x83fd
xorl %r14d, %r14d
testq %r14, %r14
je 0x8443
orb $0x2, 0x45(%rbx)
movq %r14, %rdi
callq 0x8244
movq 0x20(%r14), %r12
jmp 0x8443
testb $0x10, %al
jne 0x840f
movq %rbx, %rdi
callq 0xad10
testq %rax, %rax
je 0x840f
orb $0x2, 0x45(%rbx)
movq 0x30(%rax), %rdi
callq 0xa799
jmp 0x840d
testb $0x10, %al
jne 0x83fd
movq %rbx, %rdi
callq 0xad10
testq %rax, %rax
je 0x83fd
movq 0x30(%rax), %rdi
callq 0xa799
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 0xacb7
cmpl $0x1, %eax
jne 0x8443
cmpl $0x1, %ebp
movl $0x2, %eax
cmovnel %ebp, %eax
cmpl $0x1, 0x40(%rbx)
jne 0x8434
movl $0x2, 0x40(%rbx)
cmpl $0x1, 0x68(%rbx)
jne 0x8445
movl $0x2, 0x68(%rbx)
jmp 0x8445
movl %ebp, %eax
leaq 0x20(%rbx), %r13
movq %r12, 0x20(%rbx)
movl %eax, 0x28(%rbx)
movl %r15d, 0x2c(%rbx)
testb $0x10, 0x44(%rbx)
je 0x8511
cmpl $0x2, %eax
jne 0x8511
movq 0x30(%rbx), %r14
testq %r14, %r14
je 0x8483
movq %r14, %rdi
callq 0xad68
cmpl $0x0, 0x40(%r14)
jne 0x850d
movq 0x48(%rbx), %r15
testq %r15, %r15
je 0x84d4
cmpl $0x4, 0x10(%r15)
jne 0x84cf
movq 0x20(%r15), %rdi
callq 0xa799
movl %eax, 0x28(%r15)
testl %eax, %eax
je 0x84cf
movq 0x30(%r15), %rax
testq %rax, %rax
je 0x84bd
movl (%rax), %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x84bd
movq 0x8(%rax), %r14
jmp 0x84c0
xorl %r14d, %r14d
movq %r14, %rdi
callq 0xad68
cmpl $0x0, 0x40(%r14)
jne 0x850d
movq (%r15), %r15
jmp 0x8487
leaq 0x48(%rbx), %rax
movq (%rax), %rax
cmpl $0x5, 0x10(%rax)
jne 0x84d8
movq 0x30(%rax), %r15
testq %r15, %r15
je 0x8503
movq 0x10(%r15), %r14
movq %r14, %rdi
callq 0xad68
cmpl $0x0, 0x40(%r14)
jne 0x850d
movq 0x8(%r15), %r15
jmp 0x84e5
movl $0x0, 0x28(%rbx)
xorl %r14d, %r14d
movq %r14, (%r13)
movdqu (%r13), %xmm0
pcmpeqb (%rsp), %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x8546
orb $0x4, 0x45(%rbx)
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x8546
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x8541
orb $0x1, 0x30(%rcx)
movq (%rax), %rax
jmp 0x852f
movl 0x44(%rbx), %eax
testb $0x10, %al
je 0x85a9
addq $0x48, %rbx
movq (%rbx), %rbx
cmpl $0x5, 0x10(%rbx)
jne 0x8551
movq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0x85a9
movl %eax, %edx
andl $0x600, %edx            # imm = 0x600
movq 0x10(%rcx), %rsi
orl %edx, 0x44(%rsi)
btl $0xa, %eax
jb 0x8583
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
jne 0x856b
jmp 0x85a9
movq 0x10(%rcx), %rsi
orl $0x400, 0x44(%rsi)      # imm = 0x400
movq 0x48(%rsi), %rsi
testq %rsi, %rsi
je 0x8578
movq 0x38(%rsi), %rdi
testq %rdi, %rdi
je 0x85a4
orb $0x1, 0x30(%rdi)
movq (%rsi), %rsi
jmp 0x8592
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq