// File: /workspace/github_c_makefile_star2_O3/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 0x7f12
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 0x7f04
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 0x7c9f
movl %edx, %edx
leaq 0xd0fa(%rip), %rsi      # 0x14d20
movq (%rsi,%rdx,8), %rsi
leaq 0xd117(%rip), %rdi      # 0x14d48
movq (%rdi,%rdx,8), %rdi
leaq 0xd134(%rip), %r8       # 0x14d70
movq (%r8,%rdx,8), %rdx
movl (%rdx), %r15d
movl (%rdi), %ebp
movq (%rsi), %r12
testb $0x20, %al
jne 0x7c55
andl $0xfffffddf, %ecx       # imm = 0xFFFFFDDF
movl %ecx, 0x44(%rbx)
movq %rbx, %rdi
callq 0xa5b1
movq %r12, 0x20(%rbx)
movl %ebp, 0x28(%rbx)
movl %r15d, 0x2c(%rbx)
movq %rbx, %rdi
callq 0xa500
leal -0x3(%rax), %ecx
cmpl $0x3, %ecx
jae 0x7cb3
cmpl $0x0, 0x40(%rbx)
je 0x7d04
movl 0x44(%rbx), %eax
movl %eax, %ecx
orl $0x200, %ecx            # imm = 0x200
movl %ecx, 0x44(%rbx)
btl $0xb, %eax
jb 0x7d04
movq 0x30(%rbx), %r12
jmp 0x7def
movq 0x8(%rbx), %rax
movq %rax, 0x20(%rbx)
movl $0x0, 0x28(%rbx)
jmp 0x7f04
decl %eax
cmpl $0x1, %eax
ja 0x7def
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 0x7d52
leaq 0x48(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x7ceb
cmpl $0x5, 0x10(%rax)
jne 0x7cdd
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
xorl %ebp, %ebp
cmpq %rbx, 0x20(%rax)
sete %bpl
addl %ebp, %ebp
jmp 0x7dbb
movq %rbx, %rdi
callq 0xa559
testq %rax, %rax
je 0x7def
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x7def
movl (%rax), %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x7def
movq 0x8(%rax), %r14
testq %r14, %r14
je 0x7def
orb $0x2, 0x45(%rbx)
movq %r14, %rdi
callq 0x7bd5
movq 0x20(%r14), %r12
jmp 0x7def
orl 0x68(%rbx), %ecx
je 0x7d6d
movl %eax, %ecx
orl $0x200, %ecx            # imm = 0x200
movl %ecx, 0x44(%rbx)
btl $0xb, %eax
jb 0x7d8d
movl 0x38(%rbx), %ebp
jmp 0x7da9
testb $0x10, %al
jne 0x7dbb
movq %rbx, %rdi
callq 0xa559
testq %rax, %rax
je 0x7dbb
orb $0x2, 0x45(%rbx)
movq 0x30(%rax), %rdi
callq 0x9fc3
jmp 0x7db9
testb $0x10, %al
jne 0x7da9
movq %rbx, %rdi
callq 0xa559
testq %rax, %rax
je 0x7da9
movq 0x30(%rax), %rdi
callq 0x9fc3
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 0xa500
cmpl $0x1, %eax
jne 0x7def
cmpl $0x1, %ebp
movl $0x2, %ecx
cmovnel %ebp, %ecx
cmpl $0x1, 0x40(%rbx)
jne 0x7de0
movl $0x2, 0x40(%rbx)
cmpl $0x1, 0x68(%rbx)
jne 0x7df1
movl $0x2, 0x68(%rbx)
jmp 0x7df1
movl %ebp, %ecx
leaq 0x20(%rbx), %r13
movq %r12, 0x20(%rbx)
movl %ecx, 0x28(%rbx)
movl %r15d, 0x2c(%rbx)
movl 0x44(%rbx), %eax
testb $0x10, %al
je 0x7ec6
cmpl $0x2, %ecx
jne 0x7ec6
movq 0x30(%rbx), %r14
testq %r14, %r14
je 0x7e30
movq %r14, %rdi
callq 0xa5b1
cmpl $0x0, 0x40(%r14)
jne 0x7ebf
movq 0x48(%rbx), %r15
testq %r15, %r15
je 0x7e81
cmpl $0x4, 0x10(%r15)
jne 0x7e7c
movq 0x20(%r15), %rdi
callq 0x9fc3
movl %eax, 0x28(%r15)
testl %eax, %eax
je 0x7e7c
movq 0x30(%r15), %rax
testq %rax, %rax
je 0x7e6a
movl (%rax), %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x7e6a
movq 0x8(%rax), %r14
jmp 0x7e6d
xorl %r14d, %r14d
movq %r14, %rdi
callq 0xa5b1
cmpl $0x0, 0x40(%r14)
jne 0x7ebf
movq (%r15), %r15
jmp 0x7e34
leaq 0x48(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x7e93
cmpl $0x5, 0x10(%rax)
jne 0x7e85
movq 0x30(%rax), %r15
testq %r15, %r15
je 0x7eb5
movq 0x10(%r15), %r14
movq %r14, %rdi
callq 0xa5b1
cmpl $0x0, 0x40(%r14)
jne 0x7ebf
movq 0x8(%r15), %r15
jmp 0x7e97
movl $0x0, 0x28(%rbx)
xorl %r14d, %r14d
movq %r14, 0x20(%rbx)
movl 0x44(%rbx), %eax
movdqu (%r13), %xmm0
pcmpeqb (%rsp), %xmm0
pmovmskb %xmm0, %ecx
cmpl $0xffff, %ecx           # imm = 0xFFFF
je 0x7f00
orl $0x400, %eax            # imm = 0x400
movl %eax, 0x44(%rbx)
movq 0x48(%rbx), %rcx
testq %rcx, %rcx
je 0x7f00
movq 0x38(%rcx), %rdx
testq %rdx, %rdx
je 0x7efb
orb $0x1, 0x30(%rdx)
movq (%rcx), %rcx
jmp 0x7ee9
testb $0x10, %al
jne 0x7f13
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ecx
andl $0x600, %ecx            # imm = 0x600
addq $0x48, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x7f2d
cmpl $0x5, 0x10(%rbx)
jne 0x7f1f
movq 0x30(%rbx), %rdx
testq %rdx, %rdx
je 0x7f04
movq 0x10(%rdx), %rsi
orl %ecx, 0x44(%rsi)
btl $0xa, %eax
jb 0x7f49
movq 0x8(%rdx), %rdx
jmp 0x7f31
movq 0x10(%rdx), %rsi
orl $0x400, 0x44(%rsi)      # imm = 0x400
movq 0x48(%rsi), %rsi
testq %rsi, %rsi
je 0x7f43
movq 0x38(%rsi), %rdi
testq %rdi, %rdi
je 0x7f6a
orb $0x1, 0x30(%rdi)
movq (%rsi), %rsi
jmp 0x7f58