// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
leaq 0xe0(%rsp), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rcx
callq 0x2200
cmpq $0x4, %rax
jne 0x3428
cmpl $0x6468544d, 0xe0(%rsp) # imm = 0x6468544D
jne 0x3446
leaq 0xe0(%rsp), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rcx
callq 0x2200
cmpq $0x4, %rax
jne 0x3428
movq %rbx, 0x58(%rsp)
movl 0xe0(%rsp), %eax
bswapl %eax
cmpl $0x6, %eax
jne 0x3464
leaq 0x130(%rsp), %r12
movl $0x0, (%r12)
xorl %eax, %eax
movq %rax, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
movq %rax, 0x20(%r12)
leaq 0xe0(%rsp), %rdi
movl $0x1, %esi
movl $0x6, %edx
movq %r14, %rcx
callq 0x2200
movl $0x2, %r15d
cmpq $0x6, %rax
jne 0x335e
movl 0xe4(%rsp), %eax
shll $0x8, %eax
movl %eax, 0x10(%rsp)
testw %ax, %ax
js 0x3496
movzbl 0xe2(%rsp), %eax
shll $0x8, %eax
movzbl 0xe3(%rsp), %edx
movzbl 0xe5(%rsp), %ecx
movl %ecx, 0xa0(%rsp)
orl %eax, %edx
movl %edx, 0xa8(%rsp)
je 0x2d4b
xorl %ebx, %ebx
movl $0x1, %esi
movl $0x8, %edx
leaq 0xe0(%rsp), %rdi
movq %r14, %rcx
callq 0x2200
cmpq $0x8, %rax
jne 0x2d53
movl %ebx, 0x78(%rsp)
movl 0xe0(%rsp), %eax
movl 0xe4(%rsp), %ecx
bswapl %ecx
movq %rcx, 0xb0(%rsp)
cmpl $0x6b72544d, %eax       # imm = 0x6B72544D
jne 0x2cd4
xorl %ebx, %ebx
cmpq $0x0, 0xb0(%rsp)
je 0x2d2a
movq %r14, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x271c
movl %eax, %r13d
movq %r14, %rdi
callq 0x2210
movl $0x2, %r15d
cmpl $-0x1, %eax
je 0x2a83
movl %eax, %ebp
decq 0xb0(%rsp)
sarl $0x4, %eax
addl %ebx, %r13d
cmpl $0x9, %eax
je 0x2a8b
cmpl $0x8, %eax
jne 0x2b2d
movq %r14, %rdi
callq 0x2210
movl $0x2, %r15d
cmpl $-0x1, %eax
je 0x2c7b
movl %eax, %ebx
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x2c7b
addq $-0x2, 0xb0(%rsp)
andl $0xf, %ebp
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x1c(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
xorl %eax, %eax
movb %al, 0x38(%rsp)
movl %r13d, 0x18(%rsp)
movb %al, 0x50(%rsp)
movl %ebx, 0x48(%rsp)
movl %ebp, 0x4c(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2799
jmp 0x2b0c
movl %ebx, %r13d
jmp 0x2c84
movq %r14, %rdi
callq 0x2210
movl $0x2, %r15d
cmpl $-0x1, %eax
je 0x2c7b
movl %eax, %ebx
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x2c7b
addq $-0x2, 0xb0(%rsp)
andl $0xf, %ebp
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x1c(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movl %r13d, 0x18(%rsp)
movb $0x1, 0x50(%rsp)
movl %ebx, 0x48(%rsp)
movl %ebp, 0x4c(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2799
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x2b23
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
xorl %r15d, %r15d
movb $0x1, %al
jmp 0x2c7d
cmpl $0xf0, %ebp
je 0x2b49
cmpl $0xff, %ebp
je 0x2b7e
cmpl $0xf7, %ebp
jne 0x2c95
movq %r14, %rdi
callq 0x2210
cmpl $-0x1, %eax
je 0x2b6a
decq 0xb0(%rsp)
cmpl $0xf7, %eax
jne 0x2b49
xorl %r15d, %r15d
jmp 0x2b70
movl $0x2, %r15d
cmpl $-0x1, %eax
jne 0x2c81
jmp 0x2c84
movq %r14, %rdi
callq 0x2210
movl $0x2, %r15d
cmpl $-0x1, %eax
je 0x2c7b
movl %eax, %ebx
decq 0xb0(%rsp)
movq %r14, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x271c
movl %eax, %r12d
movq %r12, %rdi
callq 0x2030
movq %rax, %rbp
movl $0x1, %esi
movq %rax, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2200
cmpq %r12, %rax
jne 0x2cc0
subq %r12, 0xb0(%rsp)
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
movq %rbp, %rdx
addq %r12, %rdx
leaq 0x108(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x3ac4
leaq 0x18(%rsp), %rdi
movl %r13d, %esi
movl %ebx, %edx
movq %r15, %rcx
callq 0x3982
leaq 0x38(%rsp), %rbx
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
leaq 0x130(%rsp), %r12
je 0x2c4e
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x128(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2799
movq %rbp, %rdi
callq 0x21d0
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
jne 0x2b16
jmp 0x2b23
xorl %eax, %eax
testb %al, %al
je 0x2c84
xorl %r15d, %r15d
movl %r13d, %ebx
testl %r15d, %r15d
je 0x29a2
jmp 0x2d2d
movl $0x1, %esi
movl $0x2, %edx
leaq 0xe0(%rsp), %rdi
movq %r14, %rcx
callq 0x2200
cmpq $0x2, %rax
jne 0x2c84
addq $-0x2, 0xb0(%rsp)
jmp 0x2c81
movq %rbp, %rdi
callq 0x21d0
xorl %eax, %eax
leaq 0x130(%rsp), %r12
jmp 0x2c7d
movq 0xb0(%rsp), %rdx
testq %rdx, %rdx
je 0x2d22
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 0x2d15
subq %rax, 0xb0(%rsp)
xorl %r15d, %r15d
jmp 0x2d1b
movl $0x2, %r15d
testq %rax, %rax
jne 0x2cd4
jmp 0x2d2d
movl $0x5, %r15d
jmp 0x2d2d
xorl %r15d, %r15d
cmpl $0x5, %r15d
movl 0x78(%rsp), %ebx
je 0x2d3c
testl %r15d, %r15d
jne 0x2d59
incl %ebx
cmpl 0xa8(%rsp), %ebx
jne 0x2955
movl $0x3, %r15d
jmp 0x2d59
movl $0x2, %r15d
cmpl $0x3, %r15d
jne 0x335e
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x140(%rsp), %r14
xorl %ebx, %ebx
cmpq %r12, %r14
je 0x2df1
leaq 0x60(%rsp), %r15
movq %rbx, %rax
movl 0x20(%r14), %ebx
cmpq %rbx, %r13
cmovaeq %rbx, %r13
cmpq %rbx, %rax
cmovaq %rax, %rbx
movq 0x30(%r14), %rsi
cmpq 0x28(%r14), %rsi
je 0x2de1
addq $-0x40, %rsi
movq %r15, %rdi
callq 0x36de
movq 0x30(%r14), %rax
leaq -0x40(%rax), %rcx
movq %rcx, 0x30(%r14)
movq -0x30(%rax), %rdi
addq $-0x20, %rax
cmpq %rax, %rdi
je 0x2da5
movq (%rax), %rsi
incq %rsi
callq 0x2170
jmp 0x2da5
movq %r14, %rdi
callq 0x20f0
movq %rax, %r14
cmpq %r12, %rax
jne 0x2d90
movq %rbx, 0x100(%rsp)
movq 0x60(%rsp), %rbx
movq 0x68(%rsp), %r14
cmpq %r14, %rbx
je 0x2e35
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 0x4384
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4468
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
cmpq %rdx, %rcx
movq 0x58(%rsp), %r9
je 0x2e7f
movl $0x7f, %edi
xorl %esi, %esi
movl %edi, %ebx
movl 0x30(%rcx), %r8d
cmpl %r8d, %esi
movl %r8d, %eax
cmovgl %esi, %eax
cmpl %edi, %r8d
cmovll %r8d, %ebx
cmpl $-0x1, %r8d
cmovel %edi, %ebx
cmovel %esi, %eax
addq $0x40, %rcx
movl %eax, %esi
movl %ebx, %edi
cmpq %rdx, %rcx
jne 0x2e52
jmp 0x2e86
xorl %eax, %eax
movl $0x7f, %ebx
movl %eax, %ecx
subl %ebx, %ecx
cmpl $0x8, %ecx
jg 0x34ca
incl %ecx
movl %ecx, %esi
shrl $0x1f, %esi
addl %ecx, %esi
andl $-0x2, %esi
movl %ecx, %edx
subl %esi, %edx
je 0x34ca
cmpl $0x9, %ecx
sete %cl
cmpl $0x1, %edx
setne %dl
orb %cl, %dl
jne 0x2ec7
addl %ebx, %eax
movl %eax, %ebx
shrl $0x1f, %ebx
addl %eax, %ebx
sarl %ebx
addl $-0x4, %ebx
xorpd %xmm0, %xmm0
movupd %xmm0, (%r9)
xorl %eax, %eax
movq %rax, 0x10(%r9)
leaq 0xb8(%rsp), %r15
movl $0x0, (%r15)
movq %rax, 0x8(%r15)
movq %r15, 0x10(%r15)
movq %r15, 0x18(%r15)
movq %rax, 0x20(%r15)
cmpq 0x100(%rsp), %r13
ja 0x3303
movl 0x10(%rsp), %eax
addl 0xa0(%rsp), %eax
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x30e8(%rip), %xmm1     # 0x6008
divsd %xmm0, %xmm1
movsd %xmm1, 0xa8(%rsp)
divsd 0x30db(%rip), %xmm1     # 0x6010
movsd %xmm1, 0x78(%rsp)
leaq 0x28(%rsp), %r14
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x60(%rsp), %rbp
movq 0x60(%rsp), %r12
movq (%r12), %rax
movq %rax, 0x18(%rsp)
movl 0x8(%r12), %eax
movl %eax, 0x20(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x10(%r12), %rsi
movq 0x18(%r12), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x3b54
movb 0x38(%r12), %al
movb %al, 0x28(%r14)
movq 0x30(%r12), %rax
movq %rax, 0x20(%r14)
movl 0x18(%rsp), %eax
cmpq %rax, %r13
jb 0x32c0
movq 0x60(%rsp), %rsi
movq %rbp, %rdi
callq 0x51ce
cmpl $0x51, 0x20(%rsp)
jne 0x2ff9
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x30ac
movq 0x28(%rsp), %rcx
xorpd %xmm1, %xmm1
xorl %edx, %edx
movsd 0x303f(%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 0x2fd9
jmp 0x30b0
movl 0x48(%rsp), %eax
cmpl $-0x1, %eax
je 0x3283
subl %ebx, %eax
leal 0x1(%rax), %ebp
movl %ebp, 0xc(%rsp)
movl 0x4c(%rsp), %ecx
movl %ecx, %r12d
sarl $0x2, %r12d
testl %r12d, %r12d
jle 0x327e
andl $0x3, %ecx
incl %ecx
cmpb $0x1, 0x50(%rsp)
jne 0x30e1
cmpl $0x3, %ecx
jne 0x3206
movq 0xc0(%rsp), %rdx
movq %r15, %rcx
testq %rdx, %rdx
je 0x3066
movq %r15, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setle %sil
cmovgq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x304f
movq %r15, %rdx
movq %r15, %rax
cmpq %r15, %rcx
je 0x307b
cmpl 0x20(%rcx), %ebp
cmovlq %rdx, %rcx
movq %rcx, %rax
cmpq %rdx, %rax
jne 0x338c
leaq 0xb0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x39e6
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movl %r12d, 0x8(%rax)
movl %ebp, 0xc(%rax)
jmp 0x327e
xorpd %xmm1, %xmm1
movsd 0x2f68(%rip), %xmm0     # 0x6020
divsd %xmm1, %xmm0
callq 0x2240
divsd 0x2f5f(%rip), %xmm0     # 0x6028
movsd 0xa8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x78(%rsp)
jmp 0x3283
cmpl $0x3, %ecx
jne 0x327e
movq 0xc0(%rsp), %rdx
movq %r15, %rcx
testq %rdx, %rdx
je 0x3114
movq %r15, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setle %sil
cmovgq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x30fd
movq %r15, %rdx
movq %r15, %rax
cmpq %r15, %rcx
je 0x3129
cmpl 0x20(%rcx), %ebp
cmovlq %rdx, %rcx
movq %rcx, %rax
cmpq %rdx, %rax
je 0x33da
leaq 0xb0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x39e6
movq %r15, %r8
movq 0xc0(%rsp), %rdx
movq %r15, %rcx
testq %rdx, %rdx
je 0x3175
movl 0xc(%rsp), %esi
movq %r8, %rcx
xorl %edi, %edi
cmpl %esi, 0x20(%rdx)
setl %dil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x315e
movq %r8, %rsi
cmpq %r8, %rcx
je 0x318b
movl 0xc(%rsp), %edx
cmpl 0x20(%rcx), %edx
cmovlq %r8, %rcx
movq %rcx, %rsi
movsd (%rax), %xmm0
movsd %xmm0, 0xa0(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x55bc
movsd 0xa0(%rsp), %xmm1
movsd %xmm1, 0x80(%rsp)
movl %r12d, 0x88(%rsp)
movl $0x3, 0x8c(%rsp)
movsd 0x10(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x98(%rsp)
movq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
jne 0x324c
leaq 0x80(%rsp), %rdx
callq 0x5472
jmp 0x327e
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movl %r12d, 0x88(%rsp)
movl %ecx, 0x8c(%rsp)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0x90(%rsp)
movl %ebp, 0x98(%rsp)
movq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x3271
movupd 0x80(%rsp), %xmm0
movupd 0x90(%rsp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x327e
leaq 0x80(%rsp), %rdx
callq 0x5472
leaq 0x60(%rsp), %rbp
movq 0x60(%rsp), %r12
cmpq %r12, 0x68(%rsp)
jne 0x329c
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
jmp 0x2f97
movl 0x8(%r12), %eax
movl %eax, 0x20(%rsp)
movq (%r12), %rax
movq %rax, 0x18(%rsp)
leaq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x20d0
jmp 0x2f85
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x32dc
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
movsd 0x10(%rsp), %xmm0
addsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x1(%r13), %rax
cmpq 0x100(%rsp), %r13
movq %rax, %r13
jne 0x2f4f
movq 0x58(%rsp), %rax
movq (%rax), %rbx
movq 0x8(%rax), %r14
cmpq %r14, %rbx
je 0x3341
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 0x55f8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5726
leaq 0xb0(%rsp), %rdi
callq 0x3be4
leaq 0x60(%rsp), %rdi
callq 0x3926
movl $0x1, %r15d
leaq 0x128(%rsp), %rdi
callq 0x3c34
cmpl $0x2, %r15d
movq 0x58(%rsp), %rax
je 0x3428
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2d43(%rip), %rsi      # 0x60d6
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2050
movl $0x10, %edi
callq 0x20b0
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2080
movq 0x5c32(%rip), %rsi      # 0x8ff8
movq 0x5c03(%rip), %rdx      # 0x8fd0
movq %rbx, %rdi
callq 0x2250
jmp 0x34fc
leaq 0x2d18(%rip), %rsi      # 0x60f9
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2050
movl $0x10, %edi
callq 0x20b0
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2080
movq 0x5be4(%rip), %rsi      # 0x8ff8
movq 0x5bb5(%rip), %rdx      # 0x8fd0
movq %rbx, %rdi
callq 0x2250
jmp 0x34fc
movl $0x10, %edi
callq 0x20b0
movq %rax, %rbx
leaq 0x2bfc(%rip), %rsi      # 0x6038
movq %rax, %rdi
callq 0x2080
jmp 0x3480
movl $0x10, %edi
callq 0x20b0
movq %rax, %rbx
leaq 0x2bed(%rip), %rsi      # 0x6047
movq %rax, %rdi
callq 0x2080
jmp 0x3480
movl $0x10, %edi
callq 0x20b0
movq %rax, %rbx
leaq 0x2bd8(%rip), %rsi      # 0x6050
movq %rax, %rdi
callq 0x2080
movq 0x5b71(%rip), %rsi      # 0x8ff8
movq 0x5b42(%rip), %rdx      # 0x8fd0
movq %rbx, %rdi
callq 0x2250
movl $0x10, %edi
callq 0x20b0
movq %rax, %rbx
leaq 0x2bb8(%rip), %rsi      # 0x6062
movq %rax, %rdi
callq 0x2080
movq 0x5b3f(%rip), %rsi      # 0x8ff8
movq 0x5b10(%rip), %rdx      # 0x8fd0
movq %rbx, %rdi
callq 0x2250
jmp 0x34fc
movl $0x10, %edi
callq 0x20b0
movq %rax, %rbx
leaq 0x2b99(%rip), %rsi      # 0x6077
movq %rax, %rdi
callq 0x2080
movq 0x5b0b(%rip), %rsi      # 0x8ff8
movq 0x5adc(%rip), %rdx      # 0x8fd0
movq %rbx, %rdi
callq 0x2250
jmp 0x360e
movq %rax, %r14
movq %rbx, %rdi
callq 0x2110
jmp 0x3611
jmp 0x35c0
movq %rax, %r14
movq %rbx, %rdi
callq 0x2110
jmp 0x361b
jmp 0x35b9
jmp 0x360e
jmp 0x3576
jmp 0x3576
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
jne 0x35a8
jmp 0x361b
movq %rax, %r14
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x361b
movq 0x118(%rsp), %rsi
jmp 0x35ad
jmp 0x35c0
jmp 0x35c0
jmp 0x35c0
jmp 0x35c7
jmp 0x35c7
movq %rax, %r14
movq %rbx, %rdi
callq 0x2110
jmp 0x3628
jmp 0x35c7
jmp 0x358c
jmp 0x35c7
movq %rax, %r14
movq %rbx, %rdi
callq 0x2110
jmp 0x35ca
jmp 0x359b
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x361b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x361b
jmp 0x35c7
movq %rax, %r14
jmp 0x35e6
jmp 0x35c7
movq %rax, %r14
jmp 0x361b
jmp 0x35c7
movq %rax, %r14
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x35e6
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0xb0(%rsp), %rdi
callq 0x3be4
movq 0x58(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3611
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x3611
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0x3926
leaq 0x128(%rsp), %rdi
callq 0x3c34
movq %r14, %rdi
callq 0x2260