// File: daklqw[P]beepmania/core.cpp
// Function: gamecore::readbeatmap(_IO_FILE*)
void gamecore::readbeatmap(FILE * fin) {
	double tick, hi;
	fscanf(fin, "%lf%lf", &tick, &hi);
	tick /= 1000;
	kt.set(hi);
	static char buf[1024], opt[1024];
	double pre = 1;
	while (fscanf(fin, "%s", opt) == 1) {
		std::transform(opt, opt + strlen(opt), opt, ::toupper);
		if (strcmp(opt, "END") == 0) break;
		if (strcmp(opt, "SLEEP") == 0) {
			double tim;
			fscanf(fin, "%lf", &tim);
			pre += tim / 1000.;
			fgets(buf, 1024, fin);
			continue;
		}
		if (*opt == ';') { fgets(buf, 1024, fin); continue; }
		double tim, dta;
		fscanf(fin, "%lf%lf", &tim, &dta);
		tim *= tick;
		double hi = kt(*opt, dta);
		fgets(buf, 1024, fin);
		std::vector<std::vector<int> > vec;
		for (char * cur = buf; *cur; ++cur)
			if (*cur == '#') vec.push_back({});
			else if (isdigit(*cur))
				vec.back().push_back(*cur & 15);
		sd.push(pre * CLOCKS_PER_SEC, hi, tim);
		if (vec.empty()) {
			pre += tim;
		} else {
			double sm = tim / vec.size();
			for (auto t : vec) {
				for (auto c : t)
					tv[c - 1].push(note(pre * CLOCKS_PER_SEC));
				pre += sm;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xe4c3(%rip), %rsi      # 0x1106c
leaq -0x18(%rbp), %rdx
leaq -0x20(%rbp), %rcx
movb $0x0, %al
callq 0x2310
movq -0xf8(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
movsd 0xe444(%rip), %xmm1     # 0x11010
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
addq $0xa0, %rdi
movsd -0x20(%rbp), %xmm0
callq 0xc840
movsd 0xe41a(%rip), %xmm0     # 0x11008
movsd %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xe54d(%rip), %rsi      # 0x1114b
leaq 0x189eb(%rip), %rdx     # 0x1b5f0
movb $0x0, %al
callq 0x2310
cmpl $0x1, %eax
jne 0x308a
leaq 0x189d4(%rip), %rdi     # 0x1b5f0
callq 0x20b0
leaq 0x189c8(%rip), %rsi     # 0x1b5f0
addq %rax, %rsi
leaq 0x189be(%rip), %rdx     # 0x1b5f0
movq 0x1839f(%rip), %rcx     # 0x1afd8
movq %rdx, %rdi
callq 0x3980
leaq 0x189a8(%rip), %rdi     # 0x1b5f0
leaq 0xe424(%rip), %rsi      # 0x11073
callq 0x2220
cmpl $0x0, %eax
jne 0x2c5e
jmp 0x308a
leaq 0x1898b(%rip), %rdi     # 0x1b5f0
leaq 0xe40b(%rip), %rsi      # 0x11077
callq 0x2220
cmpl $0x0, %eax
jne 0x2cc1
movq -0x10(%rbp), %rdi
leaq 0xe3ee(%rip), %rsi      # 0x1106f
leaq -0x30(%rbp), %rdx
movb $0x0, %al
callq 0x2310
movsd -0x30(%rbp), %xmm0
movsd 0xe377(%rip), %xmm1     # 0x11010
divsd %xmm1, %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x1853e(%rip), %rdi     # 0x1b1f0
movl $0x400, %esi            # imm = 0x400
callq 0x22a0
jmp 0x2bf3
movsbl 0x18928(%rip), %eax     # 0x1b5f0
cmpl $0x3b, %eax
jne 0x2ce7
movq -0x10(%rbp), %rdx
leaq 0x18518(%rip), %rdi     # 0x1b1f0
movl $0x400, %esi            # imm = 0x400
callq 0x22a0
jmp 0x2bf3
movq -0x10(%rbp), %rdi
leaq 0xe37a(%rip), %rsi      # 0x1106c
leaq -0x38(%rbp), %rdx
leaq -0x40(%rbp), %rcx
movb $0x0, %al
callq 0x2310
movq -0xf8(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
addq $0xa0, %rdi
movb 0x188cc(%rip), %al      # 0x1b5f0
movsd -0x40(%rbp), %xmm0
movsbl %al, %esi
callq 0xc7e0
movsd %xmm0, -0x48(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x184af(%rip), %rdi     # 0x1b1f0
movl $0x400, %esi            # imm = 0x400
callq 0x22a0
leaq -0x60(%rbp), %rdi
callq 0x39e0
leaq 0x18495(%rip), %rax     # 0x1b1f0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpb $0x0, (%rax)
je 0x2e3d
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x2dd4
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x3a30
movq -0x100(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x3a00
jmp 0x2da9
leaq -0x80(%rbp), %rdi
callq 0x3a50
jmp 0x2e2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3a50
jmp 0x307f
movq -0x68(%rbp), %rax
movsbl (%rax), %edi
callq 0x2150
cmpl $0x0, %eax
je 0x2e28
leaq -0x60(%rbp), %rdi
callq 0x3ab0
movq %rax, %rdi
movq -0x68(%rbp), %rax
movzbl (%rax), %eax
andl $0xf, %eax
movl %eax, -0x90(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x3af0
jmp 0x2e0f
jmp 0x2e28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x307f
jmp 0x2e2a
jmp 0x2e2c
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x2d5f
movq -0xf8(%rbp), %rdi
addq $0x40, %rdi
movsd -0x28(%rbp), %xmm0
movsd 0xe1c3(%rip), %xmm1     # 0x11018
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %esi
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
callq 0xcfc0
jmp 0x2e6e
leaq -0x60(%rbp), %rdi
callq 0x3b20
testb $0x1, %al
jne 0x2e7d
jmp 0x2e91
movsd -0x38(%rbp), %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x3071
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3b60
movsd -0x108(%rbp), %xmm0
movq %rax, %xmm1
movaps 0xe175(%rip), %xmm2     # 0x11030
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xe179(%rip), %xmm2     # 0x11040
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x3b90
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x3bc0
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3bf0
testb $0x1, %al
jne 0x2f2f
jmp 0x306f
leaq -0xa8(%rbp), %rdi
callq 0x3c30
movq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x3c50
jmp 0x2f4c
leaq -0xc8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x3d40
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x3d70
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3da0
testb $0x1, %al
jne 0x2f9c
jmp 0x3040
leaq -0xd8(%rbp), %rdi
callq 0x3de0
movq -0xf8(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xe4(%rbp)
addq $0x4c8, %rdi            # imm = 0x4C8
movl -0xe4(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3e00
movq %rax, -0x110(%rbp)
movsd -0x28(%rbp), %xmm0
movsd 0xe036(%rip), %xmm1     # 0x11018
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %esi
leaq -0xec(%rbp), %rdi
callq 0xcc40
jmp 0x2ff8
movq -0x110(%rbp), %rdi
movq -0xec(%rbp), %rsi
callq 0xede0
jmp 0x300d
jmp 0x300f
leaq -0xd8(%rbp), %rdi
callq 0x3e20
jmp 0x2f80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x3a50
jmp 0x307f
movsd -0x98(%rbp), %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x3a50
leaq -0xa8(%rbp), %rdi
callq 0x3e40
jmp 0x2f13
jmp 0x3071
leaq -0x60(%rbp), %rdi
callq 0x3e60
jmp 0x2bf3
leaq -0x60(%rbp), %rdi
callq 0x3e60
jmp 0x3093
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x2300
nop