// File: /workspace/github_cpp_makefile_star2_O1/tjohnman[P]sfxr-sdl2/build/../src/main.cpp
// Function: LoadSettings(char*)
bool LoadSettings(char* filename)
{
	lastChanged = NULL;
	FILE* file=fopen(filename, "rb");
	if(!file)
		return false;
	
	size_t n;
	(void)n;
	int version=0;
	n = fread(&version, 1, sizeof(int), file);
	if(version!=100 && version!=101 && version!=102)
		return false;

	n = fread(&wave_type, 1, sizeof(int), file);

	sound_vol=0.5f;
	if(version==102)
		n = fread(&sound_vol, 1, sizeof(float), file);

	n = fread(&p_base_freq, 1, sizeof(float), file);
	n = fread(&p_freq_limit, 1, sizeof(float), file);
	n = fread(&p_freq_ramp, 1, sizeof(float), file);
	if(version>=101)
		n = fread(&p_freq_dramp, 1, sizeof(float), file);
	n = fread(&p_duty, 1, sizeof(float), file);
	n = fread(&p_duty_ramp, 1, sizeof(float), file);

	n = fread(&p_vib_strength, 1, sizeof(float), file);
	n = fread(&p_vib_speed, 1, sizeof(float), file);
	n = fread(&p_vib_delay, 1, sizeof(float), file);

	n = fread(&p_env_attack, 1, sizeof(float), file);
	n = fread(&p_env_sustain, 1, sizeof(float), file);
	n = fread(&p_env_decay, 1, sizeof(float), file);
	n = fread(&p_env_punch, 1, sizeof(float), file);

	n = fread(&filter_on, 1, sizeof(bool), file);
	n = fread(&p_lpf_resonance, 1, sizeof(float), file);
	n = fread(&p_lpf_freq, 1, sizeof(float), file);
	n = fread(&p_lpf_ramp, 1, sizeof(float), file);
	n = fread(&p_hpf_freq, 1, sizeof(float), file);
	n = fread(&p_hpf_ramp, 1, sizeof(float), file);
	
	n = fread(&p_pha_offset, 1, sizeof(float), file);
	n = fread(&p_pha_ramp, 1, sizeof(float), file);

	n = fread(&p_repeat_speed, 1, sizeof(float), file);

	if(version>=101)
	{
		n = fread(&p_arp_speed, 1, sizeof(float), file);
		n = fread(&p_arp_mod, 1, sizeof(float), file);
	}

	fclose(file);
	return true;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq $0x0, 0xbd6c(%rip) # 0xe5f0
leaq 0x78d1(%rip), %rsi      # 0xa15c
callq 0x2310
testq %rax, %rax
je 0x2b81
movq %rax, %rbx
leaq 0xc(%rsp), %r14
movl $0x0, (%r14)
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rdi
movq %rax, %rcx
callq 0x23c0
movl (%r14), %r14d
leal -0x64(%r14), %eax
cmpl $0x3, %eax
setb %bpl
jae 0x2b83
leaq 0xab68(%rip), %rdi      # 0xd440
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
movl $0x3f000000, 0xa998(%rip) # imm = 0x3F000000
cmpl $0x66, %r14d
jne 0x2913
leaq 0xa98b(%rip), %rdi      # 0xd28c
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xab2a(%rip), %rdi      # 0xd444
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xab15(%rip), %rdi      # 0xd448
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xab00(%rip), %rdi      # 0xd44c
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
cmpl $0x65, %r14d
jl 0x297d
leaq 0xaae5(%rip), %rdi      # 0xd450
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaad0(%rip), %rdi      # 0xd454
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaabb(%rip), %rdi      # 0xd458
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaaa6(%rip), %rdi      # 0xd45c
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaa91(%rip), %rdi      # 0xd460
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaa7c(%rip), %rdi      # 0xd464
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaa67(%rip), %rdi      # 0xd468
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaa52(%rip), %rdi      # 0xd46c
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaa3d(%rip), %rdi      # 0xd470
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaa28(%rip), %rdi      # 0xd474
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xaa13(%rip), %rdi      # 0xd478
movl $0x1, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xa9fe(%rip), %rdi      # 0xd47c
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xa9e9(%rip), %rdi      # 0xd480
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xa9d4(%rip), %rdi      # 0xd484
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xa9bf(%rip), %rdi      # 0xd488
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xa9aa(%rip), %rdi      # 0xd48c
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xa995(%rip), %rdi      # 0xd490
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xa980(%rip), %rdi      # 0xd494
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xa96b(%rip), %rdi      # 0xd498
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
cmpl $0x65, %r14d
jl 0x2b77
leaq 0xa950(%rip), %rdi      # 0xd49c
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
leaq 0xa93b(%rip), %rdi      # 0xd4a0
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23c0
movq %rbx, %rdi
callq 0x2280
jmp 0x2b83
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq