// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/src/config.c
// Function: writesetup
int writesetup(const char *fn)
{
	BFILE *fp;
	int item;

	fp = Bfopen(fn,"wt");
	if (!fp) return -1;

#if USE_POLYMOST
	tmprenderer = getrendermode();
#endif
#ifdef RENDERTYPEWIN
	tmpmaxrefreshfreq = win_getmaxrefreshfreq();
#endif
	tmpsamplerate = option[7]>>4;
	tmpmusic = option[2];
	tmpmouse = !!(option[3]&1);
	tmpjoystick = !!(option[3]&2);

	for (item = 0; configspec[item].name; item++) {
		if (configspec[item].doc) {
			if (item > 0) fputs("\n", fp);
			fputs(configspec[item].doc, fp);
		}
		fputs(configspec[item].name, fp);
		fputs(" = ", fp);
		switch (configspec[item].type) {
			case type_bool: {
				fprintf(fp, "%d\n", (*(int*)configspec[item].store != 0));
				break;
			}
			case type_int: {
				fprintf(fp, "%d\n", *(int*)configspec[item].store);
				break;
			}
			case type_hex: {
				fprintf(fp, "%X\n", *(int*)configspec[item].store);
				break;
			}
			case type_double: {
				fprintf(fp, "%g\n", *(double*)configspec[item].store);
				break;
			}
			default: {
				fputs("?\n", fp);
				break;
			}
		}
	}

	Bfclose(fp);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xce5ad(%rip), %rsi     # 0xd8064
callq 0x9100
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x9ad3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9d0a
callq 0x75150
movl %eax, 0x110402(%rip)    # 0x119ee0
leaq 0x110433(%rip), %rax    # 0x119f18
movzbl 0x7(%rax), %eax
sarl $0x4, %eax
movl %eax, 0x1103f2(%rip)    # 0x119ee4
leaq 0x11041f(%rip), %rax    # 0x119f18
movzbl 0x2(%rax), %eax
movl %eax, 0x1103e5(%rip)    # 0x119ee8
leaq 0x11040e(%rip), %rax    # 0x119f18
movzbl 0x3(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x1103c6(%rip)    # 0x119eec
leaq 0x1103eb(%rip), %rax    # 0x119f18
movzbl 0x3(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x1103a7(%rip)    # 0x119ef0
movl $0x0, -0x1c(%rbp)
movslq -0x1c(%rbp), %rcx
leaq 0x10fd85(%rip), %rax    # 0x1198e0
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x9cfa
movslq -0x1c(%rbp), %rcx
leaq 0x10fd69(%rip), %rax    # 0x1198e0
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, 0x18(%rax)
je 0x9bba
cmpl $0x0, -0x1c(%rbp)
jle 0x9b9b
movq -0x18(%rbp), %rsi
leaq 0xe63ea(%rip), %rdi     # 0xeff80
callq 0x8430
movslq -0x1c(%rbp), %rcx
leaq 0x10fd3a(%rip), %rax    # 0x1198e0
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x8430
movslq -0x1c(%rbp), %rax
shlq $0x5, %rax
leaq 0x10fd17(%rip), %rcx    # 0x1198e0
movq %rcx, -0x30(%rbp)
movq (%rax,%rcx), %rdi
movq -0x18(%rbp), %rsi
callq 0x8430
movq -0x18(%rbp), %rsi
leaq 0xce482(%rip), %rdi     # 0xd8067
callq 0x8430
movq -0x30(%rbp), %rcx
movslq -0x1c(%rbp), %rax
shlq $0x5, %rax
movl 0x8(%rax,%rcx), %eax
movq %rax, -0x28(%rbp)
subq $0x3, %rax
ja 0x9cda
movq -0x28(%rbp), %rax
leaq 0xce401(%rip), %rcx     # 0xd8014
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x10fcb5(%rip), %rax    # 0x1198e0
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
cmpl $0x0, (%rax)
setne %al
andb $0x1, %al
movzbl %al, %edx
leaq 0xe5f62(%rip), %rsi     # 0xefbaa
movb $0x0, %al
callq 0x8280
jmp 0x9cea
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x10fc7d(%rip), %rax    # 0x1198e0
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl (%rax), %edx
leaq 0xe5f33(%rip), %rsi     # 0xefbaa
movb $0x0, %al
callq 0x8280
jmp 0x9cea
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x10fc51(%rip), %rax    # 0x1198e0
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl (%rax), %edx
leaq 0xce3c8(%rip), %rsi     # 0xd806b
movb $0x0, %al
callq 0x8280
jmp 0x9cea
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x10fc25(%rip), %rax    # 0x1198e0
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movsd (%rax), %xmm0
leaq 0xce39e(%rip), %rsi     # 0xd806f
movb $0x1, %al
callq 0x8280
jmp 0x9cea
movq -0x18(%rbp), %rsi
leaq 0xce38e(%rip), %rdi     # 0xd8073
callq 0x8430
jmp 0x9cec
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x9b50
movq -0x18(%rbp), %rdi
callq 0x85d0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)