// File: /workspace/github_c_makefile_star2_O1/saltyJeff[P]uClibcpp/extra/config/./confdata.c
// Function: conf_write
int conf_write(const char *name)
{
	FILE *out, *out_h;
	struct symbol *sym;
	struct menu *menu;
	const char *basename;
	char dirname[128], tmpname[128], newname[128];
	int type, l;
	const char *str;

	dirname[0] = 0;
	if (name && name[0]) {
		char *slash = strrchr(name, '/');
		if (slash) {
			int size = slash - name + 1;
			memcpy(dirname, name, size);
			dirname[size] = 0;
			if (slash[1])
				basename = slash + 1;
			else
				basename = conf_def_filename;
		} else
			basename = name;
	} else
		basename = conf_def_filename;

	sprintf(newname, "%s.tmpconfig.%d", dirname, getpid());
	out = fopen(newname, "w");
	if (!out)
		return 1;
	out_h = NULL;
	if (!name) {
		out_h = fopen(".tmpconfig.h", "w");
		if (!out_h)
			return 1;
	}
	fprintf(out, "#\n"
		     "# Automatically generated make config: don't edit\n"
		     "#\n");
	if (out_h)
		fprintf(out_h, "/*\n"
			     " * Automatically generated C config: don't edit\n"
			     " */\n"
			     "/*\n"
			     " * Version Number\n"
			     " */\n"
			     "#define __UCLIBCXX_MAJOR__ %s\n"
			     "#define __UCLIBCXX_MINOR__ %s\n"
			     "#define __UCLIBCXX_SUBLEVEL__ %s\n",
			     getenv("MAJOR_VERSION"),
			     getenv("MINOR_VERSION"),
			     getenv("SUBLEVEL"));

	if (!sym_change_count)
		sym_clear_all_valid();

	menu = rootmenu.list;
	while (menu) {
		sym = menu->sym;
		if (!sym) {
			if (!menu_is_visible(menu))
				goto next;
			str = menu_get_prompt(menu);
			fprintf(out, "\n"
				     "#\n"
				     "# %s\n"
				     "#\n", str);
			if (out_h)
				fprintf(out_h, "\n"
					       "/*\n"
					       " * %s\n"
					       " */\n", str);
		} else if (!(sym->flags & SYMBOL_CHOICE)) {
			sym_calc_value(sym);
			if (!(sym->flags & SYMBOL_WRITE))
				goto next;
			sym->flags &= ~SYMBOL_WRITE;
			type = sym->type;
			if (type == S_TRISTATE) {
				sym_calc_value(modules_sym);
				if (modules_sym->curr.tri == no)
					type = S_BOOLEAN;
			}
			switch (type) {
			case S_BOOLEAN:
			case S_TRISTATE:
				switch (sym_get_tristate_value(sym)) {
				case no:
					fprintf(out, "# %s is not set\n", sym->name);
					if (out_h)
						fprintf(out_h, "#undef __%s__\n", sym->name);
					break;
				case mod:
					fprintf(out, "%s=m\n", sym->name);
					if (out_h)
						fprintf(out_h, "#define %s_MODULE 1\n", sym->name);
					break;
				case yes:
					fprintf(out, "%s=y\n", sym->name);
					if (out_h)
						fprintf(out_h, "#define __%s__ 1\n", sym->name);
					break;
				}
				break;
			case S_STRING:
				// fix me
				str = sym_get_string_value(sym);
				fprintf(out, "%s=\"", sym->name);
				if (out_h)
					fprintf(out_h, "#define __%s__ \"", sym->name);
				do {
					l = strcspn(str, "\"\\");
					if (l) {
						fwrite(str, l, 1, out);
						if (out_h)
							fwrite(str, l, 1, out_h);
					}
					str += l;
					while (*str == '\\' || *str == '"') {
						fprintf(out, "\\%c", *str);
						if (out_h)
							fprintf(out_h, "\\%c", *str);
						str++;
					}
				} while (*str);
				fputs("\"\n", out);
				if (out_h)
					fputs("\"\n", out_h);
				break;
			case S_HEX:
				str = sym_get_string_value(sym);
				if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
					fprintf(out, "%s=%s\n", sym->name, str);
					if (out_h)
						fprintf(out_h, "#define __%s__ 0x%s\n", sym->name, str);
					break;
				}
			case S_INT:
				str = sym_get_string_value(sym);
				fprintf(out, "%s=%s\n", sym->name, str);
				if (out_h)
					fprintf(out_h, "#define __%s__ %s\n", sym->name, str);
				break;
			}
		}

	next:
		if (menu->list) {
			menu = menu->list;
			continue;
		}
		if (menu->next)
			menu = menu->next;
		else while ((menu = menu->parent)) {
			if (menu->next) {
				menu = menu->next;
				break;
			}
		}
	}
	fclose(out);
	if (out_h) {
		fclose(out_h);
		rename(".tmpconfig.h", "include/system_configuration.h");
		file_write_dep(NULL);
	}
	if (!name || basename != conf_def_filename) {
		if (!name)
			name = conf_def_filename;
		sprintf(tmpname, "%s.old", name);
		rename(name, tmpname);
	}
	sprintf(tmpname, "%s%s", dirname, basename);
	if (rename(newname, tmpname))
		return 1;

	sym_change_count = 0;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %r13
movb $0x0, 0x20(%rsp)
leaq 0x8a92(%rip), %r14      # 0x11206
testq %rdi, %rdi
je 0x87cb
cmpb $0x0, (%r13)
je 0x87cb
movq %r13, %rdi
movl $0x2f, %esi
callq 0x2110
movq %r13, %r14
testq %rax, %rax
je 0x87cb
movq %rax, %rbx
subl %r13d, %eax
incl %eax
movslq %eax, %r14
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x21e0
movb $0x0, 0x20(%rsp,%r14)
movq %rbx, %rax
incq %rax
cmpb $0x0, 0x1(%rbx)
leaq 0x8a3f(%rip), %r14      # 0x11206
cmovneq %rax, %r14
callq 0x20c0
leaq 0x9163(%rip), %rsi      # 0x1193a
leaq 0xa0(%rsp), %rbx
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x22c0
leaq 0x9b31(%rip), %rsi      # 0x12328
movq %rbx, %rdi
callq 0x2270
movl $0x1, %ebp
testq %rax, %rax
je 0x8d2e
movq %rax, %r15
testq %r13, %r13
je 0x881a
xorl %r12d, %r12d
jmp 0x8839
leaq 0x9129(%rip), %rdi      # 0x1194a
leaq 0x9b00(%rip), %rsi      # 0x12328
callq 0x2270
movq %rax, %r12
testq %rax, %rax
je 0x8d2e
movq %r14, 0x10(%rsp)
leaq 0x9112(%rip), %rdi      # 0x11957
movl $0x36, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x22e0
testq %r12, %r12
je 0x88a0
leaq 0x91d9(%rip), %rdi      # 0x11a3c
callq 0x2030
movq %rax, %rbx
leaq 0x91d8(%rip), %rdi      # 0x11a4a
callq 0x2030
movq %rax, %r14
leaq 0x91d7(%rip), %rdi      # 0x11a58
callq 0x2030
leaq 0x9101(%rip), %rsi      # 0x1198e
movq %r12, %rdi
movq %rbx, %rdx
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x21a0
movq %r13, 0x18(%rsp)
cmpl $0x0, 0xe46c(%rip)      # 0x16d18
jne 0x88b3
callq 0x8d42
movq 0xdc0e(%rip), %r13      # 0x164c8
testq %r13, %r13
je 0x8c69
leaq 0x921a(%rip), %rbp      # 0x11ae4
movq 0x18(%r13), %r14
testq %r14, %r14
je 0x898c
testb $0x10, 0x44(%r14)
jne 0x89e4
movq %r14, %rdi
callq 0x8244
movl 0x44(%r14), %eax
btl $0x9, %eax
jae 0x89e4
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
movl %eax, 0x44(%r14)
movl 0x18(%r14), %eax
cmpl $0x2, %eax
jne 0x8929
movq 0xdb9f(%rip), %rdi      # 0x164b0
callq 0x8244
movq 0xdb93(%rip), %rax      # 0x164b0
cmpl $0x1, 0x28(%rax)
movl $0x2, %eax
sbbl $0x0, %eax
decl %eax
cmpl $0x4, %eax
ja 0x89e4
leaq 0x3c0d(%rip), %rcx      # 0xc548
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x28(%r14), %eax
cmpl $0x2, %eax
je 0x8c38
cmpl $0x1, %eax
je 0x8c07
testl %eax, %eax
jne 0x89e4
movq 0x8(%r14), %rdx
movq %r15, %rdi
leaq 0x910b(%rip), %rsi      # 0x11a7b
xorl %eax, %eax
callq 0x21a0
testq %r12, %r12
je 0x89e4
movq 0x8(%r14), %rdx
movq %r12, %rdi
leaq 0x9102(%rip), %rsi      # 0x11a8c
jmp 0x89dd
movq %r13, %rdi
callq 0x8d75
testb %al, %al
je 0x89e4
movq 0x20(%r13), %rax
testq %rax, %rax
je 0x89a7
addq $0x18, %rax
jmp 0x89b4
movq 0x18(%r13), %rax
testq %rax, %rax
je 0x8a14
addq $0x8, %rax
movq (%rax), %rbx
movq %r15, %rdi
leaq 0x90a0(%rip), %rsi      # 0x11a61
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21a0
testq %r12, %r12
je 0x89e4
movq %r12, %rdi
leaq 0x9092(%rip), %rsi      # 0x11a6c
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21a0
movq 0x10(%r13), %rax
testq %rax, %rax
je 0x89fe
movq %rax, %r13
testq %rax, %rax
jne 0x88ca
jmp 0x8c69
movq (%r13), %rax
testq %rax, %rax
jne 0x89ed
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0x89fe
xorl %eax, %eax
jmp 0x89ed
xorl %ebx, %ebx
jmp 0x89b7
movl 0x18(%r14), %eax
decl %eax
cmpl $0x1, %eax
ja 0x8a67
movl 0x28(%r14), %eax
cmpq $0x3, %rax
jae 0x8a67
leaq 0xd364(%rip), %rcx      # 0x15d98
leaq (%rcx,%rax,8), %rax
jmp 0x8a6b
movl 0x18(%r14), %eax
decl %eax
cmpl $0x1, %eax
ja 0x8b57
movl 0x28(%r14), %eax
cmpq $0x3, %rax
jae 0x8b57
leaq 0xd33a(%rip), %rcx      # 0x15d98
leaq (%rcx,%rax,8), %rax
jmp 0x8b5b
leaq 0x20(%r14), %rax
movq (%rax), %rbx
movq 0x8(%r14), %rdx
movq %r15, %rdi
leaq 0x9052(%rip), %rsi      # 0x11ace
xorl %eax, %eax
callq 0x21a0
testq %r12, %r12
je 0x8a9d
movq 0x8(%r14), %rdx
movq %r12, %rdi
leaq 0x903d(%rip), %rsi      # 0x11ad3
xorl %eax, %eax
callq 0x21a0
movq %rbx, %rdi
leaq 0x8e4a(%rip), %rsi      # 0x118f1
callq 0x2150
movq %rax, %r14
testl %r14d, %r14d
je 0x8ae6
movslq %r14d, %rsi
movl $0x1, %edx
movq %rbx, %rdi
movq %rsi, 0x8(%rsp)
movq %r15, %rcx
callq 0x22e0
testq %r12, %r12
je 0x8ae6
movl $0x1, %edx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rcx
callq 0x22e0
movslq %r14d, %rax
addq %rax, %rbx
movzbl (%rbx), %eax
cmpl $0x22, %eax
je 0x8af9
cmpl $0x5c, %eax
jne 0x8b23
movsbl %al, %edx
movq %r15, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x21a0
testq %r12, %r12
je 0x8b1e
movsbl (%rbx), %edx
movq %r12, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x21a0
incq %rbx
jmp 0x8aec
testl %eax, %eax
jne 0x8a9d
leaq 0x8d29(%rip), %rdi      # 0x1185b
movq %r15, %rsi
callq 0x2120
testq %r12, %r12
je 0x89e4
leaq 0x8d11(%rip), %rdi      # 0x1185b
movq %r12, %rsi
callq 0x2120
jmp 0x89e4
leaq 0x20(%r14), %rax
movq (%rax), %rbx
cmpb $0x30, (%rbx)
jne 0x8bc9
movzbl 0x1(%rbx), %eax
orl $0x20, %eax
cmpl $0x78, %eax
jne 0x8bc9
movl 0x18(%r14), %eax
decl %eax
cmpl $0x1, %eax
ja 0x8b91
movl 0x28(%r14), %eax
cmpq $0x3, %rax
jae 0x8b91
leaq 0xd20d(%rip), %rcx      # 0x15d98
leaq (%rcx,%rax,8), %rax
jmp 0x8b95
leaq 0x20(%r14), %rax
movq (%rax), %rbx
movq 0x8(%r14), %rdx
movq %r15, %rdi
leaq 0x8f42(%rip), %rsi      # 0x11ae8
movq %rbx, %rcx
xorl %eax, %eax
callq 0x21a0
testq %r12, %r12
je 0x89e4
movq 0x8(%r14), %rdx
movq %r12, %rdi
leaq 0x8f3d(%rip), %rsi      # 0x11b04
jmp 0x8bf8
movq 0x8(%r14), %rdx
movq %r15, %rdi
leaq 0x8f11(%rip), %rsi      # 0x11ae8
movq %rbx, %rcx
xorl %eax, %eax
callq 0x21a0
testq %r12, %r12
je 0x89e4
movq 0x8(%r14), %rdx
movq %r12, %rdi
leaq 0x8ef7(%rip), %rsi      # 0x11aef
movq %rbx, %rcx
xorl %eax, %eax
callq 0x21a0
jmp 0x89e4
movq 0x8(%r14), %rdx
movq %r15, %rdi
leaq 0x8e86(%rip), %rsi      # 0x11a9b
xorl %eax, %eax
callq 0x21a0
testq %r12, %r12
je 0x89e4
movq 0x8(%r14), %rdx
movq %r12, %rdi
leaq 0x8e6e(%rip), %rsi      # 0x11aa1
jmp 0x89dd
movq 0x8(%r14), %rdx
movq %r15, %rdi
leaq 0x8e70(%rip), %rsi      # 0x11ab6
xorl %eax, %eax
callq 0x21a0
testq %r12, %r12
je 0x89e4
movq 0x8(%r14), %rdx
movq %r12, %rdi
leaq 0x8e58(%rip), %rsi      # 0x11abc
jmp 0x89dd
movq %r15, %rdi
callq 0x20d0
testq %r12, %r12
je 0x8c98
movq %r12, %rdi
callq 0x20d0
leaq 0x8cc5(%rip), %rdi      # 0x1194a
leaq 0x8e8b(%rip), %rsi      # 0x11b17
callq 0x2280
xorl %edi, %edi
callq 0x8e3a
movq 0x18(%rsp), %rcx
testq %rcx, %rcx
movq 0x10(%rsp), %r15
movl $0x1, %ebp
je 0x8cb8
leaq 0x8553(%rip), %rax      # 0x11206
cmpq %rax, %r15
je 0x8ced
testq %rcx, %rcx
leaq 0x8544(%rip), %rbx      # 0x11206
cmovneq %rcx, %rbx
leaq 0x8e69(%rip), %rsi      # 0x11b36
leaq 0x120(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22c0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2280
leaq 0x8e49(%rip), %rsi      # 0x11b3d
leaq 0x120(%rsp), %rbx
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x22c0
leaq 0xa0(%rsp), %rdi
movq %rbx, %rsi
callq 0x2280
testl %eax, %eax
jne 0x8d2e
movl $0x0, 0xdfec(%rip)      # 0x16d18
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq