// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/config.c
// Function: loadsetup
int loadsetup(const char *fn)
{
	scriptfile *cfg;
	char *token;
	int item;

	cfg = scriptfile_fromfile(fn);
	if (!cfg) {
		return -1;
	}

	scriptfile_clearsymbols();

	option[0] = 1;	// vesa all the way...
	option[1] = 1;	// sound all the way...
	option[4] = 0;	// no multiplayer
	option[5] = 0;

	while (1) {
		token = scriptfile_gettoken(cfg);
		if (!token) break;	//EOF

		for (item = 0; configspec[item].name; item++) {
			if (!Bstrcasecmp(token, configspec[item].name)) {
				// Seek past any = symbol.
				token = scriptfile_peektoken(cfg);
				if (!Bstrcasecmp("=", token)) {
					scriptfile_gettoken(cfg);
				}

				switch (configspec[item].type) {
					case type_bool: {
						int value = 0;
						if (scriptfile_getnumber(cfg, &value)) break;
						*(int*)configspec[item].store = (value != 0);
						break;
					}
					case type_int: {
						int value = 0;
						if (scriptfile_getnumber(cfg, &value)) break;
						*(int*)configspec[item].store = value;
						break;
					}
					case type_hex: {
						int value = 0;
						if (scriptfile_gethex(cfg, &value)) break;
						*(int*)configspec[item].store = value;
						break;
					}
					case type_fixed16: {
						double value = 0.0;
						if (scriptfile_getdouble(cfg, &value)) break;
						*(int*)configspec[item].store = (int)(value*65536.0);
						break;
					}
					case type_double: {
						double value = 0.0;
						if (scriptfile_getdouble(cfg, &value)) break;
						*(double*)configspec[item].store = value;
						break;
					}
					default: {
						buildputs("loadsetup: unhandled value type\n");
						break;
					}
				}
				break;
			}
		}
		if (!configspec[item].name) {
			buildprintf("loadsetup: error on line %d\n", scriptfile_getlinum(cfg, cfg->ltextptr));
			continue;
		}
	}

#if USE_POLYMOST
	if (tmprenderer >= 0) {
		setrendermode(tmprenderer);
	}
#endif
#ifdef RENDERTYPEWIN
	win_setmaxrefreshfreq(tmpmaxrefreshfreq);
#endif
	if (tmpbrightness >= 0) {
		brightness = min(max(tmpbrightness,0),15);
	}
	OSD_CaptureKey(keys[19]);

	scriptfile_close(cfg);
	scriptfile_clearsymbols();

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6fed0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x2c3bc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2c6f8
callq 0x70370
leaq 0xa3288(%rip), %rax     # 0xcf650
movb $0x1, (%rax)
leaq 0xa327e(%rip), %rax     # 0xcf650
movb $0x1, 0x1(%rax)
leaq 0xa3273(%rip), %rax     # 0xcf650
movb $0x0, 0x4(%rax)
leaq 0xa3268(%rip), %rax     # 0xcf650
movb $0x0, 0x5(%rax)
movq -0x18(%rbp), %rdi
callq 0x6efc0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x2c405
jmp 0x2c657
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rcx
leaq 0xb3ba9(%rip), %rax     # 0xdffc0
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x2c614
movq -0x20(%rbp), %rdi
movslq -0x24(%rbp), %rcx
leaq 0xb3b89(%rip), %rax     # 0xdffc0
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x67c0
cmpl $0x0, %eax
jne 0x2c604
movq -0x18(%rbp), %rdi
callq 0x6f0b0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq 0x83ac7(%rip), %rdi     # 0xaff2e
callq 0x67c0
cmpl $0x0, %eax
jne 0x2c47a
movq -0x18(%rbp), %rdi
callq 0x6efc0
movslq -0x24(%rbp), %rax
shlq $0x5, %rax
leaq 0xb3b37(%rip), %rcx     # 0xdffc0
movl 0x8(%rax,%rcx), %eax
movq %rax, -0x48(%rbp)
subq $0x4, %rax
ja 0x2c5f6
movq -0x48(%rbp), %rax
leaq 0x849f2(%rip), %rcx     # 0xb0e98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6f220
cmpl $0x0, %eax
je 0x2c4cd
jmp 0x2c602
cmpl $0x0, -0x28(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %ecx
movslq -0x24(%rbp), %rdx
leaq 0xb3adc(%rip), %rax     # 0xdffc0
shlq $0x5, %rdx
addq %rdx, %rax
movq 0x10(%rax), %rax
movl %ecx, (%rax)
jmp 0x2c602
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x6f220
cmpl $0x0, %eax
je 0x2c514
jmp 0x2c602
movl -0x2c(%rbp), %ecx
movslq -0x24(%rbp), %rdx
leaq 0xb3a9e(%rip), %rax     # 0xdffc0
shlq $0x5, %rdx
addq %rdx, %rax
movq 0x10(%rax), %rax
movl %ecx, (%rax)
jmp 0x2c602
movl $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x6f410
cmpl $0x0, %eax
je 0x2c552
jmp 0x2c602
movl -0x30(%rbp), %ecx
movslq -0x24(%rbp), %rdx
leaq 0xb3a60(%rip), %rax     # 0xdffc0
shlq $0x5, %rdx
addq %rdx, %rax
movq 0x10(%rax), %rax
movl %ecx, (%rax)
jmp 0x2c602
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x6f440
cmpl $0x0, %eax
je 0x2c58e
jmp 0x2c602
movsd 0x848fa(%rip), %xmm0    # 0xb0e90
mulsd -0x38(%rbp), %xmm0
cvttsd2si %xmm0, %ecx
movslq -0x24(%rbp), %rdx
leaq 0xb3a16(%rip), %rax     # 0xdffc0
shlq $0x5, %rdx
addq %rdx, %rax
movq 0x10(%rax), %rax
movl %ecx, (%rax)
jmp 0x2c602
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x6f440
cmpl $0x0, %eax
je 0x2c5d5
jmp 0x2c602
movsd -0x40(%rbp), %xmm0
movslq -0x24(%rbp), %rcx
leaq 0xb39db(%rip), %rax     # 0xdffc0
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movsd %xmm0, (%rax)
jmp 0x2c602
leaq 0x848c3(%rip), %rdi     # 0xb0ec0
callq 0x4a720
jmp 0x2c614
jmp 0x2c606
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2c40c
movslq -0x24(%rbp), %rcx
leaq 0xb39a1(%rip), %rax     # 0xdffc0
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x2c652
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x6f180
movl %eax, %esi
leaq 0x8489b(%rip), %rdi     # 0xb0ee1
movb $0x0, %al
callq 0x37c90
jmp 0x2c3ec
jmp 0x2c3ec
cmpl $0x0, 0xb3d82(%rip)     # 0xe03e0
jl 0x2c66b
movl 0xb3d7a(%rip), %edi     # 0xe03e0
callq 0x5a760
cmpl $0x0, 0xb3d72(%rip)     # 0xe03e4
jl 0x2c6d4
cmpl $0x0, 0xb3d69(%rip)     # 0xe03e4
jle 0x2c688
movl 0xb3d61(%rip), %eax     # 0xe03e4
movl %eax, -0x4c(%rbp)
jmp 0x2c68f
xorl %eax, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2c68f
movl -0x4c(%rbp), %eax
cmpl $0xf, %eax
jge 0x2c6ba
cmpl $0x0, 0xb3d46(%rip)     # 0xe03e4
jle 0x2c6ab
movl 0xb3d3e(%rip), %eax     # 0xe03e4
movl %eax, -0x50(%rbp)
jmp 0x2c6b2
xorl %eax, %eax
movl %eax, -0x50(%rbp)
jmp 0x2c6b2
movl -0x50(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x2c6c4
movl $0xf, %eax
movl %eax, -0x54(%rbp)
jmp 0x2c6c4
movl -0x54(%rbp), %eax
movw %ax, %cx
leaq 0x13d9ab(%rip), %rax    # 0x16a07c
movw %cx, (%rax)
leaq 0xa2f85(%rip), %rax     # 0xcf660
movl 0x4c(%rax), %edi
callq 0x6cc90
movq -0x18(%rbp), %rdi
callq 0x700b0
callq 0x70370
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)