// File: /workspace/github_c_makefile_star2_O3/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 $0x198, %rsp            # imm = 0x198
movq %rdi, %r14
movb $0x0, 0x10(%rsp)
leaq 0x80bb(%rip), %r13      # 0x101e6
testq %rdi, %rdi
je 0x8181
cmpb $0x0, (%r14)
je 0x8181
movq %r14, %rdi
movl $0x2f, %esi
callq 0x2110
movq %r14, %r13
testq %rax, %rax
je 0x8181
movq %rax, %rbx
subl %r14d, %eax
incl %eax
movslq %eax, %r15
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x21f0
movb $0x0, 0x10(%rsp,%r15)
movq %rbx, %rax
incq %rax
cmpb $0x0, 0x1(%rbx)
leaq 0x8069(%rip), %r13      # 0x101e6
cmovneq %rax, %r13
callq 0x20c0
leaq 0x878d(%rip), %rsi      # 0x1091a
leaq 0x90(%rsp), %rbx
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x22d0
leaq 0x915b(%rip), %rsi      # 0x11308
movq %rbx, %rdi
callq 0x2280
movl $0x1, %ebp
testq %rax, %rax
je 0x8669
movq %rax, %r15
testq %r14, %r14
je 0x81f1
leaq 0x8765(%rip), %rdi      # 0x10937
movl $0x36, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x22f0
movq $0x0, (%rsp)
jmp 0x8271
leaq 0x8732(%rip), %rdi      # 0x1092a
leaq 0x9109(%rip), %rsi      # 0x11308
callq 0x2280
testq %rax, %rax
je 0x8669
leaq 0x8723(%rip), %rdi      # 0x10937
movl $0x36, %esi
movl $0x1, %edx
movq %r15, %rcx
movq %rax, %rbp
callq 0x22f0
leaq 0x87ec(%rip), %rdi      # 0x10a1c
callq 0x2030
movq %rax, %rbx
leaq 0x87eb(%rip), %rdi      # 0x10a2a
callq 0x2030
movq %rax, %r12
leaq 0x87ea(%rip), %rdi      # 0x10a38
callq 0x2030
leaq 0x8714(%rip), %rsi      # 0x1096e
movq %rbp, (%rsp)
movq %rbp, %rdi
movq %rbx, %rdx
movq %r12, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x21b0
movq %r13, 0x8(%rsp)
cmpl $0x0, 0xda9b(%rip)      # 0x15d18
jne 0x8284
callq 0x867d
movq 0xd23d(%rip), %rax      # 0x154c8
testq %rax, %rax
je 0x85a6
leaq 0x8829(%rip), %r13      # 0x10ac4
movq %rax, %rbp
movq 0x18(%rax), %rbx
testq %rbx, %rbx
je 0x8348
testb $0x10, 0x44(%rbx)
jne 0x856c
movq %rbx, %rdi
callq 0x7bd5
movl 0x44(%rbx), %eax
btl $0x9, %eax
jae 0x856c
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
movl %eax, 0x44(%rbx)
movl 0x18(%rbx), %eax
decl %eax
cmpl $0x4, %eax
ja 0x856c
leaq 0x3241(%rip), %rcx      # 0xb528
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0xd1b9(%rip), %rdi      # 0x154b0
callq 0x7bd5
movl 0x28(%rbx), %eax
cmpl $0x2, %eax
je 0x8552
cmpl $0x1, %eax
je 0x8524
testl %eax, %eax
jne 0x856c
movq 0x8(%rbx), %rdx
movq %r15, %rdi
leaq 0x8734(%rip), %rsi      # 0x10a5b
xorl %eax, %eax
callq 0x21b0
testq %r14, %r14
jne 0x856c
movq 0x8(%rbx), %rdx
movq (%rsp), %rdi
leaq 0x8726(%rip), %rsi      # 0x10a6c
jmp 0x83a2
movq %rbp, %rdi
callq 0x86b0
testb %al, %al
je 0x856c
movq 0x20(%rbp), %rax
testq %rax, %rax
je 0x8367
addq $0x18, %rax
jmp 0x8374
movq 0x18(%rbp), %rax
testq %rax, %rax
je 0x83ae
addq $0x8, %rax
movq (%rax), %rbx
movq %r15, %rdi
leaq 0x86c0(%rip), %rsi      # 0x10a41
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21b0
testq %r14, %r14
jne 0x856c
movq (%rsp), %rdi
leaq 0x86ad(%rip), %rsi      # 0x10a4c
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21b0
jmp 0x856c
xorl %ebx, %ebx
jmp 0x8377
movq 0x8(%rbx), %rdx
movq 0x20(%rbx), %r12
movq %r15, %rdi
leaq 0x86ea(%rip), %rsi      # 0x10aae
xorl %eax, %eax
callq 0x21b0
testq %r14, %r14
jne 0x83e6
movq 0x8(%rbx), %rdx
movq (%rsp), %rdi
leaq 0x86d4(%rip), %rsi      # 0x10ab3
xorl %eax, %eax
callq 0x21b0
movq %r12, %rdi
leaq 0x84e1(%rip), %rsi      # 0x108d1
callq 0x2150
testl %eax, %eax
je 0x842a
movslq %eax, %rbx
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x22f0
testq %r14, %r14
jne 0x842c
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
movq (%rsp), %rcx
callq 0x22f0
jmp 0x842c
xorl %ebx, %ebx
addq %rbx, %r12
movzbl (%r12), %edx
cmpl $0x22, %edx
je 0x843e
cmpl $0x5c, %edx
jne 0x8468
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x21b0
testq %r14, %r14
jne 0x8463
movsbl (%r12), %edx
movq (%rsp), %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x21b0
incq %r12
jmp 0x842f
testl %edx, %edx
jne 0x83e6
leaq 0x83c4(%rip), %rdi      # 0x1083b
movq %r15, %rsi
callq 0x2120
testq %r14, %r14
jne 0x856c
leaq 0x83ac(%rip), %rdi      # 0x1083b
movq (%rsp), %rsi
callq 0x2120
jmp 0x856c
movq 0x20(%rbx), %r12
cmpb $0x30, (%r12)
jne 0x84ec
movzbl 0x1(%r12), %eax
orl $0x20, %eax
cmpl $0x78, %eax
jne 0x84ec
movq 0x8(%rbx), %rdx
movq 0x20(%rbx), %r12
movq %r15, %rdi
leaq 0x8600(%rip), %rsi      # 0x10ac8
movq %r12, %rcx
xorl %eax, %eax
callq 0x21b0
testq %r14, %r14
jne 0x856c
movq 0x8(%rbx), %rdx
movq (%rsp), %rdi
leaq 0x85fa(%rip), %rsi      # 0x10ae4
jmp 0x8518
movq 0x8(%rbx), %rdx
movq %r15, %rdi
leaq 0x85ce(%rip), %rsi      # 0x10ac8
movq %r12, %rcx
xorl %eax, %eax
callq 0x21b0
testq %r14, %r14
jne 0x856c
movq 0x8(%rbx), %rdx
movq (%rsp), %rdi
leaq 0x85b7(%rip), %rsi      # 0x10acf
movq %r12, %rcx
xorl %eax, %eax
callq 0x21b0
jmp 0x856c
movq 0x8(%rbx), %rdx
movq %r15, %rdi
leaq 0x8549(%rip), %rsi      # 0x10a7b
xorl %eax, %eax
callq 0x21b0
testq %r14, %r14
jne 0x856c
movq 0x8(%rbx), %rdx
movq (%rsp), %rdi
leaq 0x8534(%rip), %rsi      # 0x10a81
jmp 0x83a2
movq 0x8(%rbx), %rdx
movq %r15, %rdi
leaq 0x8536(%rip), %rsi      # 0x10a96
xorl %eax, %eax
callq 0x21b0
testq %r14, %r14
je 0x8592
movq 0x10(%rbp), %rax
testq %rax, %rax
jne 0x829b
jmp 0x8584
movq 0x8(%rbp), %rbp
testq %rbp, %rbp
je 0x85a6
movq (%rbp), %rax
testq %rax, %rax
je 0x857b
jmp 0x829b
movq 0x8(%rbx), %rdx
movq (%rsp), %rdi
leaq 0x84fb(%rip), %rsi      # 0x10a9c
jmp 0x83a2
movq %r15, %rdi
callq 0x20d0
testq %r14, %r14
je 0x85cd
movq 0x8(%rsp), %r15
movl $0x1, %ebp
je 0x8601
leaq 0x7c20(%rip), %rax      # 0x101e6
cmpq %rax, %r15
je 0x8628
jmp 0x8601
movq (%rsp), %rdi
callq 0x20d0
leaq 0x834d(%rip), %rdi      # 0x1092a
leaq 0x8513(%rip), %rsi      # 0x10af7
callq 0x2290
xorl %edi, %edi
callq 0x8770
leaq 0x7bef(%rip), %r14      # 0x101e6
movq 0x8(%rsp), %r15
movl $0x1, %ebp
leaq 0x850e(%rip), %rsi      # 0x10b16
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22d0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2290
leaq 0x84ee(%rip), %rsi      # 0x10b1d
leaq 0x110(%rsp), %rbx
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x22d0
leaq 0x90(%rsp), %rdi
movq %rbx, %rsi
callq 0x2290
testl %eax, %eax
jne 0x8669
movl $0x0, 0xd6b1(%rip)      # 0x15d18
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq