// File: /workspace/github_cpp_makefile_star2_O3/MikuAuahDark[P]midi2sif/src/midi2sif.cpp
// Function: midi2sif(_IO_FILE*)
std::vector<SIFBeatmap> midi2sif(FILE* midi_stream)
{
	char temp_buffer[32];

	if(fread(temp_buffer, 1, 4, midi_stream) != 4)
	{
		unexpected_eof:
		throw std::runtime_error("Unexpected EOF");
	}

	if(memcmp(temp_buffer, "MThd", 4))
		throw std::runtime_error("Not MIDI");

	if(fread(temp_buffer, 1, 4, midi_stream) != 4)
		goto unexpected_eof;

	if((STR2DWORD_BE(temp_buffer)) != 6)
		throw std::runtime_error("Header size not 6");

	uint32_t mtrk_count;
	uint32_t ppqn;
	double tempo = 120.0;
	std::map<uint32_t, std::vector<EventInformation> > raw_event_list;

	if(fread(temp_buffer, 1, 6, midi_stream) != 6)
		goto unexpected_eof;

	mtrk_count = STR2WORD_BE(temp_buffer + 2);
	ppqn = STR2WORD_BE(temp_buffer + 4);

	if(ppqn > 32767)
		throw std::runtime_error("MTC is not supported");

	for(uint32_t i = 0; i < mtrk_count; i++)
	{
		if(fread(temp_buffer, 1, 8, midi_stream) != 8)
			goto unexpected_eof;

		size_t mtrk_len = STR2DWORD_BE(temp_buffer + 4);
		uint32_t timing_total = 0;

		if(memcmp(temp_buffer, "MTrk", 4))
		{
			while(mtrk_len > 0)
			{
				size_t res = fread(temp_buffer, 1, std::min(mtrk_len, size_t(32)), midi_stream);

				if(res == 0)
					goto unexpected_eof;

				mtrk_len -= res;
			}

			continue;
		}

		while(mtrk_len > 0)
		{
			uint32_t timing = ReadVarInt(midi_stream, &mtrk_len);
			int32_t event_byte = fgetc(midi_stream);
			int32_t event_type = event_byte >> 4;

			if(event_byte == EOF)
				goto unexpected_eof;

			mtrk_len--;
			timing_total += timing;

			if(event_type == 8)
			{
				int32_t notepos = fgetc(midi_stream);

				if(notepos == EOF || fgetc(midi_stream) == EOF)
					goto unexpected_eof;

				mtrk_len -= 2;

				EventInformation temp(timing_total, false, notepos, event_byte & 0xF);
				InsertEvent(raw_event_list, temp);
			}
			else if(event_type == 9)
			{
				int32_t notepos = fgetc(midi_stream);

				if(notepos == EOF || fgetc(midi_stream) == EOF)
					goto unexpected_eof;
				
				mtrk_len -= 2;

				EventInformation temp(timing_total, true, notepos, event_byte & 0xF);
				InsertEvent(raw_event_list, temp);
			}
			else if(event_byte == 255)
			{
				int32_t meta_id = fgetc(midi_stream);

				if(meta_id == EOF)
					goto unexpected_eof;

				mtrk_len--;

				size_t data_size = ReadVarInt(midi_stream, &mtrk_len);
				char* data = new char[data_size];

				if(fread(data, 1, data_size, midi_stream) != data_size)
				{
					delete[] data;
					goto unexpected_eof;
				}

				mtrk_len -= data_size;

				EventInformation temp(timing_total, meta_id, std::string(data, data_size));
				InsertEvent(raw_event_list, temp);

				delete[] data;
			}
			else if(event_byte == 240 || event_byte == 247)
			{
				int32_t temp;

				do
				{
					temp = fgetc(midi_stream);

					if(temp == EOF)
						goto unexpected_eof;

					mtrk_len--;
				}
				while(temp != 247);
			}
			else if(fread(temp_buffer, 1, 2, midi_stream) != 2)
				goto unexpected_eof;
			else
				mtrk_len -= 2;
		}
	}

	size_t lowest_tick = 0xFFFFFFFFU;
	size_t highest_tick = 0;

	std::vector<EventInformation> event_list;

	for(std::map<uint32_t, std::vector<EventInformation> >::iterator i = raw_event_list.begin(); i != raw_event_list.end(); i++)
	{
		size_t tick = i->first;
		std::vector<EventInformation>& eis = i->second;

		lowest_tick = std::min(tick, lowest_tick);
		highest_tick = std::max(tick, highest_tick);

		while(eis.size() > 0)
		{
			event_list.push_back(eis.back());
			eis.pop_back();
		}
	}

	std::sort(event_list.begin(), event_list.end());

	int32_t top_index = 0;
	int32_t bottom_index = 127;

	for(std::vector<EventInformation>::iterator i = event_list.begin(); i != event_list.end(); i++)
	{
		EventInformation& x = *i;

		if(x.pos != (-1))
		{
			top_index = std::max(top_index, x.pos);
			bottom_index = std::min(bottom_index, x.pos);
		}
	}

	int32_t mid_index = top_index - bottom_index + 1;

	if(mid_index > 9 || mid_index % 2 == 0)
		throw std::runtime_error("Failed to analyze note position. Make sure you only use 9 note keys or odd amount of note keys");

	if(mid_index != 9 && mid_index % 2 == 1)
	{
		mid_index = (top_index + bottom_index) / 2;
		top_index = mid_index + 4;
		bottom_index = mid_index - 4;
	}

	std::vector<SIFBeatmap> sif_beatmap;
	std::map<SIFBeatmap::NotePos, TemporaryLNQueue> longnote_queue;
	double current_timing_sec = 0.0;
	double add_timing_sec = 60.0 / ppqn / tempo;

	for(size_t tick = lowest_tick; tick <= highest_tick; tick++)
	{
		EventInformation ei = *event_list.begin();

		while(tick >= ei.tick)
		{
			event_list.erase(event_list.begin());

			if(ei.meta == 81)
			{
				tempo = 0.0;

				for(std::string::iterator i = ei.data.begin(); i != ei.data.end(); i++)
					tempo = tempo * 256.0 + uint8_t(*i);

				tempo = floor(600000000 / tempo) / 10;
				add_timing_sec = 60.0 / ppqn / tempo;
			}
			else if(ei.pos != (-1))
			{
				SIFBeatmap::NotePos position = SIFBeatmap::NotePos(ei.pos - bottom_index + 1);
				SIFBeatmap::Attribute attri = SIFBeatmap::Attribute(ei.channel >> 2);
				SIFBeatmap::EffectType effect = SIFBeatmap::EffectType((ei.channel & 0x3) + 1);

				if(attri > 0)
				{
					if(ei.note_on)
					{
						if(effect == SIFBeatmap::LONG_NOTE)
						{
							if(longnote_queue.count(position))
							{
								char temp[32];

								sprintf(temp, "another note in pos %d is in queue", int(position));
								throw std::runtime_error(temp);
							}
							else
								longnote_queue[position] = TemporaryLNQueue(current_timing_sec, attri, position);
						}
						else
						{
							SIFBeatmap beatmap = {current_timing_sec, attri, effect, 2.0, position};
							sif_beatmap.push_back(beatmap);
						}
					}
					else if(ei.note_on == false && effect == SIFBeatmap::LONG_NOTE)
					{
						if(longnote_queue.count(position))
						{
							TemporaryLNQueue queue = longnote_queue[position];
							longnote_queue.erase(longnote_queue.find(position));

							SIFBeatmap beatmap = {queue.timing_sec, attri, SIFBeatmap::LONG_NOTE, current_timing_sec - queue.timing_sec, position};
							sif_beatmap.push_back(beatmap);
						}
						else
						{
							char temp[32];

							sprintf(temp, "queue for pos %d is empty", int(position));
							throw std::runtime_error(temp);
						}
					}
				}
			}

			if(event_list.size() > 0)
				ei = *event_list.begin();
			else
				ei.tick = 0xFFFFFFFFU;
		}

		current_timing_sec += add_timing_sec;
	}

	std::sort(sif_beatmap.begin(), sif_beatmap.end());

	return sif_beatmap;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
leaq 0xe0(%rsp), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rcx
callq 0x2200
cmpq $0x4, %rax
jne 0x32e3
cmpl $0x6468544d, 0xe0(%rsp) # imm = 0x6468544D
jne 0x3397
leaq 0xe0(%rsp), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rcx
callq 0x2200
cmpq $0x4, %rax
jne 0x32e3
movl 0xe0(%rsp), %eax
bswapl %eax
cmpl $0x6, %eax
jne 0x33b8
leaq 0x130(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0xe0(%rsp), %rdi
movl $0x1, %esi
movl $0x6, %edx
movq %r14, %rcx
callq 0x2200
cmpq $0x6, %rax
jne 0x32d6
movl 0xe4(%rsp), %eax
shll $0x8, %eax
movl %eax, 0x8(%rsp)
testw %ax, %ax
js 0x33d9
movzbl 0xe2(%rsp), %eax
shll $0x8, %eax
movzbl 0xe3(%rsp), %edx
movzbl 0xe5(%rsp), %ecx
movl %ecx, 0xd0(%rsp)
orl %eax, %edx
movl %edx, 0xd8(%rsp)
je 0x2c20
leaq 0x38(%rsp), %r12
leaq 0x18(%rsp), %r15
xorl %ebx, %ebx
movl $0x1, %esi
movl $0x8, %edx
leaq 0xe0(%rsp), %rdi
movq %r14, %rcx
callq 0x2200
cmpq $0x8, %rax
jne 0x32d6
movl %ebx, 0x58(%rsp)
movl 0xe0(%rsp), %eax
movl 0xe4(%rsp), %edx
bswapl %edx
movq %rdx, 0x60(%rsp)
cmpl $0x6b72544d, %eax       # imm = 0x6B72544D
jne 0x2bce
testq %rdx, %rdx
je 0x2c0d
xorl %ebx, %ebx
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq 0x26ac
movl %eax, %ebp
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x32d6
movl %eax, %r13d
decq 0x60(%rsp)
sarl $0x4, %eax
addl %ebp, %ebx
cmpl $0x9, %eax
je 0x29e2
cmpl $0x8, %eax
jne 0x2a7e
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x32d6
movl %eax, %ebp
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x32d6
addq $-0x2, 0x60(%rsp)
andl $0xf, %r13d
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x1c(%rsp)
movq %r12, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
xorl %eax, %eax
movb %al, 0x38(%rsp)
movl %ebx, 0x18(%rsp)
movb %al, 0x50(%rsp)
movl %ebp, 0x48(%rsp)
movl %r13d, 0x4c(%rsp)
leaq 0x128(%rsp), %rdi
movq %r15, %rsi
callq 0x2729
jmp 0x2a54
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x32d6
movl %eax, %ebp
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x32d6
addq $-0x2, 0x60(%rsp)
andl $0xf, %r13d
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x1c(%rsp)
movq %r12, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movl %ebx, 0x18(%rsp)
movb $0x1, 0x50(%rsp)
movl %ebp, 0x48(%rsp)
movl %r13d, 0x4c(%rsp)
leaq 0x128(%rsp), %rdi
movq %r15, %rsi
callq 0x2729
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x2a6b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x60(%rsp), %rcx
testq %rcx, %rcx
jne 0x2933
jmp 0x2c0d
cmpl $0xf0, %r13d
je 0x2a9d
cmpl $0xff, %r13d
je 0x2ac4
cmpl $0xf7, %r13d
jne 0x2b97
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x32d6
movq 0x60(%rsp), %rcx
decq %rcx
movq %rcx, 0x60(%rsp)
cmpl $0xf7, %eax
jne 0x2a9d
jmp 0x2a70
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x32d6
movl %eax, %ebp
decq 0x60(%rsp)
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq 0x26ac
movl %eax, %r12d
movq %r12, %rdi
callq 0x2030
movq %rax, %r13
movl $0x1, %esi
movq %rax, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2200
cmpq %r12, %rax
jne 0x32ce
subq %r12, 0x60(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, 0x100(%rsp)
movq %r13, %rdx
addq %r12, %rdx
leaq 0x100(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x39ea
movq %r15, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %r12, %rcx
callq 0x38a6
leaq 0x38(%rsp), %r12
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0x2b7a
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x128(%rsp), %rdi
movq %r15, %rsi
callq 0x2729
movq %r13, %rdi
callq 0x21d0
jmp 0x2a54
movl $0x1, %esi
movl $0x2, %edx
leaq 0xe0(%rsp), %rdi
movq %r14, %rcx
callq 0x2200
cmpq $0x2, %rax
jne 0x32d6
movq 0x60(%rsp), %rcx
addq $-0x2, %rcx
movq %rcx, 0x60(%rsp)
jmp 0x2a70
testq %rdx, %rdx
je 0x2c0d
cmpq $0x20, %rdx
movl $0x20, %eax
cmovaeq %rax, %rdx
movl $0x1, %esi
leaq 0xe0(%rsp), %rdi
movq %r14, %rcx
callq 0x2200
testq %rax, %rax
je 0x32d6
movq 0x60(%rsp), %rdx
subq %rax, %rdx
movq %rdx, 0x60(%rsp)
jne 0x2bd3
movl 0x58(%rsp), %ebx
incl %ebx
cmpl 0xd8(%rsp), %ebx
jne 0x28e0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movq 0x140(%rsp), %rbx
leaq 0x130(%rsp), %rax
xorl %r15d, %r15d
cmpq %rax, %rbx
je 0x2d55
leaq 0x90(%rsp), %r14
movq %r15, %rax
movl 0x20(%rbx), %r15d
cmpq %r15, %rbp
cmovaeq %r15, %rbp
cmpq %r15, %rax
cmovaq %rax, %r15
movq 0x30(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x2cb3
addq $-0x40, %rsi
movq %r14, %rdi
callq 0x35e0
movq 0x30(%rbx), %rax
leaq -0x40(%rax), %rsi
movq %rsi, 0x30(%rbx)
movq -0x30(%rax), %rdi
addq $-0x20, %rax
cmpq %rax, %rdi
je 0x2c7b
movq (%rax), %rsi
incq %rsi
callq 0x2170
jmp 0x2c77
movq %rbx, %rdi
callq 0x20f0
movq %rax, %rbx
leaq 0x130(%rsp), %rax
cmpq %rax, %rbx
jne 0x2c62
movq 0x90(%rsp), %rbx
movq 0x98(%rsp), %r14
cmpq %r14, %rbx
je 0x2d1d
movq %r14, %rax
subq %rbx, %rax
sarq $0x6, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x426c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4340
movq 0x90(%rsp), %rbx
movq 0x98(%rsp), %r14
cmpq %r14, %rbx
je 0x2d5f
movl $0x7f, %r12d
xorl %eax, %eax
movl %eax, %ecx
movl 0x30(%rbx), %edx
cmpl %edx, %eax
movl %edx, %eax
cmovgl %ecx, %eax
movl %r12d, %esi
cmpl %r12d, %edx
cmovll %edx, %r12d
cmpl $-0x1, %edx
cmovel %esi, %r12d
cmovel %ecx, %eax
addq $0x40, %rbx
cmpq %r14, %rbx
jne 0x2d2a
jmp 0x2d67
movl $0x7f, %r12d
xorl %eax, %eax
jmp 0x2d67
xorl %eax, %eax
movl $0x7f, %r12d
movl %eax, %ecx
subl %r12d, %ecx
cmpl $0x8, %ecx
jg 0x3363
incl %ecx
movl %ecx, %esi
shrl $0x1f, %esi
addl %ecx, %esi
andl $-0x2, %esi
movl %ecx, %edx
subl %esi, %edx
je 0x3363
cmpl $0x9, %ecx
sete %cl
cmpl $0x1, %edx
setne %dl
orb %cl, %dl
jne 0x2daf
addl %r12d, %eax
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
addl $-0x4, %r12d
xorpd %xmm0, %xmm0
movq 0x10(%rsp), %rcx
movupd %xmm0, (%rcx)
xorl %eax, %eax
movq %rax, 0x10(%rcx)
leaq 0x68(%rsp), %rcx
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
cmpq %r15, %rbp
ja 0x3245
movq %r15, 0x120(%rsp)
movl 0x8(%rsp), %eax
addl 0xd0(%rsp), %eax
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x31fd(%rip), %xmm1     # 0x6008
divsd %xmm0, %xmm1
movsd %xmm1, 0xd8(%rsp)
divsd 0x31f0(%rip), %xmm1     # 0x6010
movsd %xmm1, 0x58(%rsp)
leaq 0x28(%rsp), %r14
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x90(%rsp), %r15
movq 0x90(%rsp), %rbx
movq (%rbx), %rax
movq %rax, 0x18(%rsp)
movl 0x8(%rbx), %eax
movl %eax, 0x20(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x3a80
movb 0x38(%rbx), %al
movb %al, 0x28(%r14)
movq 0x30(%rbx), %rax
movq %rax, 0x20(%r14)
movl 0x18(%rsp), %eax
cmpq %rax, %rbp
jb 0x31c4
movq 0x90(%rsp), %rsi
movq %r15, %rdi
callq 0x5088
cmpl $0x51, 0x20(%rsp)
jne 0x2ee5
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x2f94
movq 0x28(%rsp), %rcx
xorpd %xmm1, %xmm1
xorl %edx, %edx
movsd 0x3153(%rip), %xmm2     # 0x6018
movzbl (%rcx,%rdx), %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
incq %rdx
cmpq %rdx, %rax
jne 0x2ec5
jmp 0x2f98
movl 0x48(%rsp), %eax
cmpl $-0x1, %eax
je 0x2fc4
subl %r12d, %eax
leal 0x1(%rax), %ebx
movl %ebx, 0x4(%rsp)
movl 0x4c(%rsp), %ecx
movl %ecx, %r13d
sarl $0x2, %r13d
testl %r13d, %r13d
jle 0x2fc4
andl $0x3, %ecx
incl %ecx
cmpb $0x1, 0x50(%rsp)
jne 0x2fec
cmpl $0x3, %ecx
jne 0x3124
movq 0x70(%rsp), %r8
testq %r8, %r8
je 0x2f72
leaq 0x68(%rsp), %rdi
movq %rdi, %rcx
movq %r8, %rdx
movl 0x20(%r8), %esi
xorl %r8d, %r8d
cmpl %eax, %esi
setle %r8b
cmovgq %rdx, %rdi
movq 0x10(%rdx,%r8,8), %r8
testq %r8, %r8
jne 0x2f38
leaq 0x68(%rsp), %r8
cmpq %r8, %rdi
je 0x2f72
cmpl %eax, %esi
cmovgq %rdx, %rcx
cmpl 0x20(%rcx), %ebx
jge 0x3315
leaq 0x60(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x390a
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movl %r13d, 0x8(%rax)
movl %ebx, 0xc(%rax)
jmp 0x2fc4
xorpd %xmm1, %xmm1
movsd 0x3080(%rip), %xmm0     # 0x6020
divsd %xmm1, %xmm0
callq 0x2240
divsd 0x3077(%rip), %xmm0     # 0x6028
movsd 0xd8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x58(%rsp)
movq 0x90(%rsp), %rbx
cmpq %rbx, 0x98(%rsp)
jne 0x31a4
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x2e84
cmpl $0x3, %ecx
jne 0x2fc4
movq 0x70(%rsp), %r8
testq %r8, %r8
je 0x3280
leaq 0x68(%rsp), %rdi
movq %rdi, %rcx
movq %r8, %rdx
movl 0x20(%r8), %esi
xorl %r8d, %r8d
cmpl %eax, %esi
setle %r8b
cmovgq %rdx, %rdi
movq 0x10(%rdx,%r8,8), %r8
testq %r8, %r8
jne 0x3004
leaq 0x68(%rsp), %r8
cmpq %r8, %rdi
je 0x3280
cmpl %eax, %esi
cmovgq %rdx, %rcx
cmpl 0x20(%rcx), %ebx
jl 0x3280
leaq 0x60(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x390a
movq 0x70(%rsp), %r10
leaq 0x68(%rsp), %r8
movq %r8, %rsi
testq %r10, %r10
je 0x30a9
movl 0x4(%rsp), %ecx
movq %r8, %rdx
movq %r10, %rdi
movl 0x20(%r10), %r9d
xorl %esi, %esi
cmpl %ecx, %r9d
setl %sil
movq %r10, %r8
cmovlq %rdx, %r8
movq 0x10(%r10,%rsi,8), %r10
testq %r10, %r10
jne 0x3067
leaq 0x68(%rsp), %r10
movq %r10, %rsi
cmpq %r10, %r8
je 0x30a9
cmpl %ecx, %r9d
cmovlq %rdx, %rdi
cmpl 0x20(%rdi), %ecx
cmovlq %r10, %r8
movq %r8, %rsi
movsd (%rax), %xmm0
movsd %xmm0, 0xd0(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x5478
movsd 0xd0(%rsp), %xmm1
movsd %xmm1, 0xb0(%rsp)
movl %r13d, 0xb8(%rsp)
movl $0x3, 0xbc(%rsp)
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0xc0(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0xc8(%rsp)
movq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
jne 0x316a
leaq 0xb0(%rsp), %rdx
callq 0x532e
jmp 0x2fc4
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movl %r13d, 0xb8(%rsp)
movl %ecx, 0xbc(%rsp)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0xc0(%rsp)
movl %ebx, 0xc8(%rsp)
movq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x3192
movupd 0xb0(%rsp), %xmm0
movupd 0xc0(%rsp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x2fc4
leaq 0xb0(%rsp), %rdx
callq 0x532e
jmp 0x2fc4
movl 0x8(%rbx), %eax
movl %eax, 0x20(%rsp)
movq (%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x20d0
jmp 0x2e71
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x31e0
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
movsd 0x8(%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x1(%rbp), %rax
cmpq 0x120(%rsp), %rbp
movq %rax, %rbp
jne 0x2e3d
movq 0x10(%rsp), %rax
movq (%rax), %rbx
movq 0x8(%rax), %r14
cmpq %r14, %rbx
je 0x3245
movq %r14, %rax
subq %rbx, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x54b4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x55e2
leaq 0x60(%rsp), %rdi
callq 0x3b16
leaq 0x90(%rsp), %rdi
callq 0x3848
leaq 0x128(%rsp), %rdi
callq 0x3b66
movq 0x10(%rsp), %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e72(%rip), %rsi      # 0x60f9
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2050
movl $0x10, %edi
callq 0x20b0
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x2080
movq 0x5d3e(%rip), %rsi      # 0x8ff8
movq 0x5d0f(%rip), %rdx      # 0x8fd0
movq %r14, %rdi
callq 0x2250
jmp 0x340b
movq %r13, %rdi
callq 0x21d0
leaq 0x128(%rsp), %rdi
callq 0x3b66
movl $0x10, %edi
callq 0x20b0
movq %rax, %r14
leaq 0x2d41(%rip), %rsi      # 0x6038
movq %rax, %rdi
callq 0x2080
movq 0x5cf2(%rip), %rsi      # 0x8ff8
movq 0x5cc3(%rip), %rdx      # 0x8fd0
movq %r14, %rdi
callq 0x2250
leaq 0x2dba(%rip), %rsi      # 0x60d6
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2050
movl $0x10, %edi
callq 0x20b0
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x2080
movq 0x5ca9(%rip), %rsi      # 0x8ff8
movq 0x5c7a(%rip), %rdx      # 0x8fd0
movq %r14, %rdi
callq 0x2250
jmp 0x340b
movl $0x10, %edi
callq 0x20b0
movq %rax, %r14
leaq 0x2d00(%rip), %rsi      # 0x6077
movq %rax, %rdi
callq 0x2080
movq 0x5c72(%rip), %rsi      # 0x8ff8
movq 0x5c43(%rip), %rdx      # 0x8fd0
movq %r14, %rdi
callq 0x2250
jmp 0x340b
movl $0x10, %edi
callq 0x20b0
movq %rax, %r14
leaq 0x2c9c(%rip), %rsi      # 0x6047
movq %rax, %rdi
callq 0x2080
jmp 0x32ff
movl $0x10, %edi
callq 0x20b0
movq %rax, %r14
leaq 0x2c84(%rip), %rsi      # 0x6050
movq %rax, %rdi
callq 0x2080
jmp 0x32ff
movl $0x10, %edi
callq 0x20b0
movq %rax, %r14
leaq 0x2c75(%rip), %rsi      # 0x6062
movq %rax, %rdi
callq 0x2080
movq 0x5bfc(%rip), %rsi      # 0x8ff8
movq 0x5bcd(%rip), %rdx      # 0x8fd0
movq %r14, %rdi
callq 0x2250
jmp 0x34b7
movq %rax, %rbx
movq %r14, %rdi
callq 0x2110
jmp 0x3510
jmp 0x351f
jmp 0x351f
jmp 0x3450
jmp 0x3500
jmp 0x3500
movq %rax, %rbx
movq %r14, %rdi
callq 0x2110
jmp 0x3503
jmp 0x34bc
jmp 0x3488
jmp 0x34bc
jmp 0x34bc
jmp 0x34bc
movq %rax, %rbx
jmp 0x34db
jmp 0x34b7
jmp 0x34b7
jmp 0x34b7
jmp 0x3499
movq %rax, %rbx
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0x3510
movq 0x110(%rsp), %rsi
jmp 0x34ab
jmp 0x34bc
movq %rax, %rbx
movq %r14, %rdi
callq 0x2110
jmp 0x34bf
jmp 0x34bc
jmp 0x3499
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x3510
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x3510
jmp 0x34bc
movq %rax, %rbx
jmp 0x3510
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x34db
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x60(%rsp), %rdi
callq 0x3b16
movq 0x10(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3503
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x3503
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x3848
leaq 0x128(%rsp), %rdi
callq 0x3b66
jmp 0x352a
movq %rax, %rbx
movq %r14, %rdi
callq 0x2110
movq %rbx, %rdi
callq 0x2260