// File: /workspace/github_cpp_makefile_star2_O2/mdpkh[P]retro6k/src/main.cpp
// Function: DoPickFile(filetype, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void DoPickFile(filetype ft, std::string &path)
{
	SDL_Surface* winbuffer = SDL_CreateRGBSurfaceWithFormat(
		0,
		480,
		config.screen.pixheight * 109,
		8,
		SDL_PIXELFORMAT_INDEX8);
	SDL_SetSurfaceBlendMode(winbuffer, SDL_BLENDMODE_BLEND);
	SDL_SetColorKey(winbuffer, true, 0xf9);
	SDL_Surface* mwsurface = SDL_GetWindowSurface(mainwindow);
	SDL_SetSurfaceBlendMode(mwsurface, SDL_BLENDMODE_NONE);
	SDL_Surface* restorescreen = SDL_CreateRGBSurfaceWithFormat(
		0,
		winbuffer->w,
		winbuffer->h,
		mwsurface->format->BitsPerPixel,
		SDL_MasksToPixelFormatEnum(
			mwsurface->format->BitsPerPixel,
			mwsurface->format->Rmask,
			mwsurface->format->Gmask,
			mwsurface->format->Bmask,
			mwsurface->format->Amask));
	if (!winbuffer || !restorescreen)
	{
		SDL_Log("Could not create menu display buffers: %s", SDL_GetError());
		return;
	}
	SDL_SetSurfaceBlendMode(restorescreen, SDL_BLENDMODE_NONE);
	int winmacrox, winmacroy;
	const char* titles[4] = {
		"Choose a File\x85",
		"Choose a ROM Chip\x85",
		"Choose a Cartridge\x85",
		"Choose a Cartridge Save File\x85",
	};
	const char* exts[4] = {
		"",
		".rom",
		".r6kcart",
		".r6ksave",
	};
	char* wintitle;
	char* filterext;
	bool ignoreext = false;
	std::filesystem::path browsedir;
	switch (ft)
	{
	case filetype::FT_ROM:
		wintitle = (char*)titles[1];
		filterext = (char*)exts[1];
		for (auto& path : config.sessionpath.rompath)
		{
			if (std::filesystem::exists(path))
			{
				browsedir = std::filesystem::canonical(path);
				break;
			}
		}
		winmacrox = 4;
		winmacroy = 4;
		break;
	case filetype::FT_CART:
		wintitle = (char*)titles[2];
		filterext = (char*)exts[2];
		for (auto& path : config.sessionpath.cartpath)
		{
			if (std::filesystem::exists(path))
			{
				browsedir = std::filesystem::canonical(path);
				break;
			}
		}
		winmacrox = 2;
		winmacroy = 3;
		break;
	case filetype::FT_CARTSAVE:
		wintitle = (char*)titles[3];
		filterext = (char*)exts[3];
		for (auto& path : config.sessionpath.savepath)
		{
			if (std::filesystem::exists(path))
			{
				browsedir = std::filesystem::canonical(path);
				break;
			}
		}
		winmacrox = 6;
		winmacroy = 5;
		break;
	default:
		wintitle = (char*)titles[0];
		filterext = (char*)exts[0];
		ignoreext = true;
		browsedir = std::filesystem::canonical(".");
		winmacrox = 4;
		winmacroy = 4;
	}
	int mww, mwh;
	SDL_GetWindowSize(mainwindow, &mww, &mwh);
	SDL_Rect winpos;
	winpos.w = winbuffer->w;
	winpos.h = winbuffer->h;
	winpos.x = (winmacrox * (mww - winpos.w)) >> 3;
	winpos.y = (winmacroy * (mwh - winpos.h)) >> 3;
	SetHWPalette(winbuffer->format->palette);
	SDL_UpdateWindowSurface(mainwindow);
	SDL_BlitSurface(mwsurface, &winpos, restorescreen, NULL);
	PaintWindow(winbuffer, 0xff, 0x39, wintitle, 0xff);
	const char* keyshint = "Ctrl+D: ChDir  \x97  Ctrl+E: ExtFilter on/off  \x97  Esc: Cancel";
	int tx0 = (winpos.w - TextWidth(keyshint)) >> 1;
	DrawText(keyshint, tx0, winpos.h - 20, 0x31, 0xff, winbuffer);
	int displaylines = (winpos.h - 60) / 18;
	int filey0;
	filey0 = (winpos.h - displaylines * 18 + 20) >> 1;
	const int filex0 = 16;
	const int prevx0 = winpos.w - 80;
	DrawTextCX("Loading directory listing\x85", filex0, filey0 + 18 * ((displaylines - 1) >> 1), 0x07, 0xff, winbuffer);
	SDL_Rect dstanimrect = winpos;
	SDL_Rect srcanimrect = { 0, 0, winpos.w, winpos.h };
	for (int t = 1; t <= 8; ++t)
	{
		SDL_SetSurfaceAlphaMod(winbuffer, t * 31);
		dstanimrect.w = winpos.w * t / 8;
		srcanimrect.w = dstanimrect.w;
		dstanimrect.x = (winmacrox * (mww - dstanimrect.w)) >> 3;
		SDL_BlitSurface(restorescreen, NULL, mwsurface, &winpos);
		SDL_BlitSurface(winbuffer, &srcanimrect, mwsurface, &dstanimrect);
		SDL_UpdateWindowSurface(mainwindow);
		SDL_Delay(16);
	}
	bool relistfiles = true;
	std::vector<std::string> filelist;
	std::vector<std::filesystem::path> pathlist;
	int filesel = 0;
	int displaystart = 0;
	while (true)
	{
		bool repaintfiles = false;
		SDL_Event event;
		while (SDL_PollEvent(&event))
		{
			SDL_Event newevent;
			switch (event.type)
			{
			case SDL_KEYDOWN:
				if (event.key.keysym.mod & KMOD_CTRL)
				{
					switch (event.key.keysym.sym)
					{
					case SDLK_d:
						UIBeepUnavailable();
						break;
					case SDLK_e:
						UIBeepUnavailable();
						break;
					}
				}
				else
				{
					int nfiles = (int)filelist.size();
					switch (event.key.keysym.sym)
					{
					case SDLK_HOME:
						if (filesel == 0)
						{
							UIBeepUnavailable();
						}
						else
						{
							UIBeepMoveSel();
							displaystart = 0;
							filesel = 0;
							repaintfiles = true;
						}
						break;
					case SDLK_END:
						if (filesel + 1 == nfiles)
						{
							UIBeepMoveSel();
						}
						else
						{
							UIBeepMoveSel();
							displaystart = nfiles - displaylines;
							filesel = nfiles - 1;
							if (displaystart < 0)
								displaystart = 0;
							repaintfiles = true;
						}
						break;
					case SDLK_PAGEUP:
						if (displaystart == 0 || displaylines >= nfiles)
						{
							if (filesel == 0)
							{
								UIBeepUnavailable();
							}
							else
							{
								UIBeepMoveSel();
								filesel = 0;
								repaintfiles = true;
							}
						}
						else
						{
							UIBeepMoveSel();
							displaystart -= displaylines;
							if (displaystart < 0)
								displaystart = 0;
							int lastvisible = displaystart + displaylines - 1;
							if (filesel > lastvisible)
								filesel = lastvisible;
							repaintfiles = true;
						}
						break;
					case SDLK_PAGEDOWN:
						if (displaystart + displaylines == nfiles || displaylines >= nfiles)
						{
							if (filesel == nfiles - 1)
							{
								UIBeepUnavailable();
							}
							else
							{
								filesel = nfiles - 1;
								repaintfiles = true;
							}
						}
						else
						{
							UIBeepMoveSel();
							displaystart += displaylines;
							if (displaystart + displaylines > nfiles)
								displaystart = nfiles - displaylines;
							if (filesel < displaystart)
								filesel = displaystart;
							repaintfiles = true;
						}
						break;
					case SDLK_UP:
						if (filesel == 0)
						{
							UIBeepUnavailable();
						}
						else
						{
							UIBeepMoveSel();
							--filesel;
							if (filesel < displaystart)
								displaystart = filesel;
							repaintfiles = true;
						}
						break;
					case SDLK_DOWN:
						if (filesel == nfiles - 1)
						{
							UIBeepUnavailable();
						}
						else
						{
							UIBeepMoveSel();
							++filesel;
							if (filesel >= displaystart + displaylines)
								displaystart = filesel - displaylines + 1;
							repaintfiles = true;
						}
						break;
					case SDLK_RETURN:
					case SDLK_KP_ENTER:
						path = pathlist[filesel].string();
						UIBeepTakeAction();
						goto exitpickfile;
					case SDLK_ESCAPE:
						path.clear();
						goto exitpickfile;
					}
				}
				break;
			case SDL_QUIT:
				newevent.type = SDL_QUIT;
				SDL_PushEvent(&newevent);
				goto exitpickfile;
			}
		}
		if (relistfiles)
		{
			filelist.clear();
			pathlist.clear();
			for (auto& entry: std::filesystem::directory_iterator(browsedir, std::filesystem::directory_options::skip_permission_denied))
			{
				if (entry.is_regular_file() && (ignoreext || cilstreq(entry.path().extension().string().c_str(), (const char*)filterext)))
				{
					filelist.push_back(entry.path().filename().string());
					pathlist.push_back(entry.path());
				}
			}
			repaintfiles = true;
		}
		if (repaintfiles)
		{
			SDL_Rect paintbox{filex0 - 9, filey0 - 1, prevx0 - filey0 + 9, 18 * displaylines + 2};
			{
				int x = filex0;
				DrawText("Location: ", x, 23, 0x31, 0xff, winbuffer);
				std::string loc = browsedir.string();
				DrawText(loc.c_str(), x, 23, 0x00, 0xff, winbuffer);
			}
			SDL_FillRect(winbuffer, &paintbox, 0xff);
			for (int i = 0, j = displaystart, ky = filey0; i < displaylines && j < filelist.size(); ++i, ++j, ky += 18)
			{
				if (filesel == j)
				{
					SDL_Rect selrect{ paintbox.x, ky - 1, paintbox.w, 18 };
					FillRoundedRect(winbuffer, selrect, 0x31);
					DrawTextCX(filelist[j].c_str(), filex0, ky, 0xff, 0x31, winbuffer);
				}
				else
				{
					DrawTextCX(filelist[j].c_str(), filex0, ky, 0x00, 0xff, winbuffer);
				}
			}
			if (filelist.size() == 0)
			{
				DrawTextCX("No files here!", filex0, filey0 + 18 * ((displaylines - 1) >> 1), 0x07, 0xff, winbuffer);
			}
			repaintfiles = false;
			SDL_BlitSurface(restorescreen, NULL, mwsurface, &winpos);
			SDL_BlitSurface(winbuffer, NULL, mwsurface, &winpos);
			SDL_UpdateWindowSurface(mainwindow);
		}
		SDL_Delay(16);
	}
exitpickfile:
	for (int t = 7; t > 0; --t)
	{
		SDL_SetSurfaceAlphaMod(winbuffer, t * 31);
		dstanimrect.h = winpos.h * t / 8;
		srcanimrect.h = dstanimrect.h;
		srcanimrect.y = winpos.h - dstanimrect.h;
		dstanimrect.y = (winmacroy * (mwh - dstanimrect.h)) >> 3;
		SDL_BlitSurface(restorescreen, NULL, mwsurface, &winpos);
		SDL_BlitSurface(winbuffer, &srcanimrect, mwsurface, &dstanimrect);
		SDL_UpdateWindowSurface(mainwindow);
		SDL_Delay(16);
	}
	SDL_BlitSurface(restorescreen, NULL, mwsurface, &winpos);
	SDL_FreeSurface(restorescreen);
	SDL_FreeSurface(winbuffer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rsi, 0xe0(%rsp)
movl %edi, %r14d
imull $0x6d, 0x123b9(%rip), %edx # 0x1b464
pushq $0x8
popq %rcx
xorl %edi, %edi
movl $0x1e0, %esi            # imm = 0x1E0
movl $0x13000801, %r8d       # imm = 0x13000801
callq 0x60a0
movq %rax, %rbx
pushq $0x1
popq %rbp
movq %rax, %rdi
movl %ebp, %esi
callq 0x6290
movq %rbx, %rdi
movl %ebp, %esi
movl $0xf9, %edx
callq 0x6420
movq 0x816212(%rip), %rdi    # 0x81f2f8
callq 0x6470
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
callq 0x6290
movl 0x10(%rbx), %r15d
movq %rbx, 0x10(%rsp)
movl 0x14(%rbx), %r12d
movq %r13, 0x20(%rsp)
movq 0x8(%r13), %rax
movzbl 0x10(%rax), %r13d
movl 0x14(%rax), %esi
movl 0x18(%rax), %edx
movl 0x1c(%rax), %ecx
movl 0x20(%rax), %r8d
movl %r13d, %edi
callq 0x6520
xorl %edi, %edi
movl %r15d, %esi
movl %r12d, %edx
movl %r13d, %ecx
movl %eax, %r8d
callq 0x60a0
testq %rax, %rax
je 0x91cb
movq %rax, 0x38(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x6290
leaq 0x1b8(%rsp), %rdi
callq 0xd354
cmpl $0x2, %r14d
je 0x9245
cmpl $0x1, %r14d
movq 0x10(%rsp), %r13
je 0x91f2
pushq $0x4
popq %rax
movl %eax, 0x18(%rsp)
testl %r14d, %r14d
jne 0x929d
movq 0x1226c(%rip), %r14     # 0x1b3f8
movq 0x1226d(%rip), %rbx     # 0x1b400
leaq 0xb73c(%rip), %r15      # 0x148d6
leaq 0xb8df(%rip), %rax      # 0x14a80
movq %rax, 0x60(%rsp)
movb $0x1, %al
movl %eax, 0x1c(%rsp)
cmpq %rbx, %r14
je 0x9387
movq %r14, %rdi
callq 0xd036
testb %al, %al
jne 0x9357
addq $0x28, %r14
jmp 0x91a6
callq 0x62d0
leaq 0xb3a1(%rip), %rdi      # 0x14578
movq %rax, %rsi
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6480
pushq $0x2
popq %rax
movl %eax, (%rsp)
movq 0x12211(%rip), %r14     # 0x1b410
movq 0x12212(%rip), %rbx     # 0x1b418
pushq $0x3
popq %rax
movl %eax, 0x18(%rsp)
leaq 0xb6d5(%rip), %r15      # 0x148e9
leaq 0xb700(%rip), %rax      # 0x1491b
movq %rax, 0x60(%rsp)
movb $0x1, %al
movl %eax, 0x1c(%rsp)
cmpq %rbx, %r14
je 0x938d
movq %r14, %rdi
callq 0xd036
testb %al, %al
jne 0x9313
addq $0x28, %r14
jmp 0x9220
movq 0x121dc(%rip), %r14     # 0x1b428
movq 0x121dd(%rip), %rbx     # 0x1b430
pushq $0x6
popq %rax
movl %eax, (%rsp)
pushq $0x5
popq %rax
movl %eax, 0x18(%rsp)
leaq 0xb696(%rip), %r15      # 0x148fd
leaq 0xb6b6(%rip), %rax      # 0x14924
movq %rax, 0x60(%rsp)
movq 0x10(%rsp), %r13
movb $0x1, %al
movl %eax, 0x1c(%rsp)
cmpq %rbx, %r14
je 0x938d
movq %r14, %rdi
callq 0xd036
testb %al, %al
jne 0x9325
addq $0x28, %r14
jmp 0x9278
leaq 0xb337(%rip), %rsi      # 0x145db
leaq 0x148(%rsp), %rdi
pushq $0x2
popq %rdx
callq 0xd378
leaq 0x180(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x6220
leaq 0x1b8(%rsp), %rdi
leaq 0x180(%rsp), %r14
movq %r14, %rsi
callq 0xd052
movq %r14, %rdi
callq 0xd08a
leaq 0x148(%rsp), %rdi
callq 0xd08a
leaq 0xb5ca(%rip), %r15      # 0x148c7
leaq 0xb689(%rip), %rax      # 0x1498d
movq %rax, 0x60(%rsp)
movl $0x0, 0x1c(%rsp)
jmp 0x9387
leaq 0x180(%rsp), %rdi
movq %r14, %rsi
callq 0x6220
jmp 0x9335
leaq 0x180(%rsp), %rdi
movq %r14, %rsi
callq 0x6220
leaq 0x1b8(%rsp), %rdi
leaq 0x180(%rsp), %r14
movq %r14, %rsi
callq 0xd052
movq %r14, %rdi
callq 0xd08a
jmp 0x938d
leaq 0x180(%rsp), %rdi
movq %r14, %rsi
callq 0x6220
leaq 0x1b8(%rsp), %rdi
leaq 0x180(%rsp), %r14
movq %r14, %rsi
callq 0xd052
movq %r14, %rdi
callq 0xd08a
pushq $0x4
popq %rax
movl %eax, (%rsp)
movq 0x815f64(%rip), %rdi    # 0x81f2f8
leaq 0x5c(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x6150
movl 0x10(%r13), %eax
movl %eax, 0x50(%rsp)
movl 0x14(%r13), %ecx
movl %ecx, 0x54(%rsp)
movl 0x5c(%rsp), %edx
subl %eax, %edx
imull (%rsp), %edx
sarl $0x3, %edx
movl %edx, 0x48(%rsp)
movl 0x58(%rsp), %eax
subl %ecx, %eax
imull 0x18(%rsp), %eax
sarl $0x3, %eax
movl %eax, 0x4c(%rsp)
movq 0x8(%r13), %rax
movq 0x8(%rax), %rdi
callq 0x6f17
movq 0x815f0e(%rip), %rdi    # 0x81f2f8
callq 0x63d0
leaq 0x48(%rsp), %rsi
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rdx
xorl %ecx, %ecx
callq 0x6300
pushq $0x39
popq %rdx
movq %r13, %rdi
movl $0xff, %esi
movq %r15, %rcx
movl $0xff, %r8d
callq 0x6fbf
leaq 0x48(%rsp), %r15
movl 0x8(%r15), %ebx
leaq 0xb4ff(%rip), %r14      # 0x1492d
movq %r14, %rdi
callq 0x7200
subl %eax, %ebx
sarl %ebx
leaq 0x144(%rsp), %rsi
movl %ebx, (%rsi)
movl 0xc(%r15), %edx
addl $-0x14, %edx
pushq $0x31
popq %rcx
movq %r14, %rdi
movl $0xff, %r8d
movq %r13, %r9
callq 0x7221
movl 0x8(%r15), %eax
movl %eax, 0x34(%rsp)
movl 0xc(%r15), %esi
leal -0x3c(%rsi), %eax
pushq $0x12
popq %rcx
cltd
idivl %ecx
imull $0x12, %eax, %ecx
movl %ecx, 0x44(%rsp)
subl %ecx, %esi
addl $0x14, %esi
sarl %esi
movq %rax, 0x28(%rsp)
decl %eax
shrl %eax
imull $0x12, %eax, %edx
movq %rsi, 0xe8(%rsp)
addl %esi, %edx
leaq 0xb4c9(%rip), %rdi      # 0x14968
pushq $0x10
popq %r12
pushq $0x7
popq %rcx
movl %r12d, %esi
movl %edx, 0x70(%rsp)
movl $0xff, %r8d
movq %r13, %r9
callq 0xd3e3
movups (%r15), %xmm0
leaq 0xd0(%rsp), %r14
leaq 0x100(%rsp), %r13
andq $0x0, (%r13)
movaps %xmm0, (%r14)
movq 0x8(%r15), %rax
movq %rax, 0x8(%r13)
movb $0x1f, %bl
cmpl $0x9, %ebp
je 0x956e
movzbl %bl, %esi
movq 0x10(%rsp), %rdi
callq 0x65d0
movl 0x50(%rsp), %eax
imull %ebp, %eax
cltd
pushq $0x8
popq %rcx
idivl %ecx
movl %eax, 0xd8(%rsp)
movl %eax, 0x108(%rsp)
movl 0x5c(%rsp), %ecx
subl %eax, %ecx
imull (%rsp), %ecx
sarl $0x3, %ecx
movl %ecx, 0xd0(%rsp)
movq 0x38(%rsp), %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
movq %r15, %rcx
callq 0x6300
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq 0x20(%rsp), %rdx
movq %r14, %rcx
callq 0x6300
movq 0x815da1(%rip), %rdi    # 0x81f2f8
callq 0x63d0
movl %r12d, %edi
callq 0x62b0
incl %ebp
addb $0x1f, %bl
jmp 0x94e2
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %r12
movaps %xmm0, (%r12)
andq $0x0, 0x10(%r12)
leaq 0x1e0(%rsp), %r13
movaps %xmm0, (%r13)
andq $0x0, 0x10(%r13)
movq 0xe8(%rsp), %rcx
leal -0x1(%rcx), %eax
movl %eax, 0x78(%rsp)
movl 0x34(%rsp), %eax
subl %ecx, %eax
addl $-0x47, %eax
movl %eax, 0x34(%rsp)
addl $0x2, 0x44(%rsp)
movq $0x0, (%rsp)
movq 0x28(%rsp), %rax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movl %ecx, 0x74(%rsp)
leaq 0xf0(%rsp), %rbp
pushq $0x17
popq %r14
leaq 0x148(%rsp), %r15
movq $0x0, 0x8(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x6240
movslq (%rsp), %rsi
testl %eax, %eax
je 0x969a
movl 0x180(%rsp), %eax
cmpl $0x300, %eax            # imm = 0x300
je 0x9622
cmpl $0x100, %eax            # imm = 0x100
jne 0x95ef
jmp 0x9c5f
testb $-0x40, 0x198(%rsp)
je 0x9651
movl 0x194(%rsp), %eax
cmpl $0x65, %eax
je 0x963d
cmpl $0x64, %eax
jne 0x95ef
movw $0x2274, 0x121f0(%rip)  # imm = 0x2274
movw $0x37, 0x121e9(%rip)    # 0x1b838
jmp 0x95ef
movl 0x194(%rsp), %eax
leal -0x4000004a(%rax), %ecx
cmpl $0xe, %ecx
ja 0x9bd1
movq 0xb8(%rsp), %rax
subq 0xb0(%rsp), %rax
shrq $0x5, %rax
leaq 0x7b62(%rip), %rdx      # 0x111e4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x0, (%rsp)
je 0x9c02
jmp 0x9c40
movq %rsi, 0x68(%rsp)
movl %eax, 0x7c(%rsp)
movq %r12, %rdi
callq 0xd412
movq %r13, %rdi
callq 0xd41a
movq %rbp, %rdi
leaq 0x1b8(%rsp), %rsi
pushq $0x2
popq %rdx
callq 0xd422
leaq 0x120(%rsp), %rdi
movq %rbp, %rsi
callq 0xe3d6
movaps 0x120(%rsp), %xmm0
movaps %xmm0, 0xa0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x120(%rsp)
leaq 0x128(%rsp), %rdi
callq 0xe40a
leaq 0x1f8(%rsp), %rdi
movq %rbp, %rsi
callq 0xe3d6
xorps %xmm0, %xmm0
movaps %xmm0, 0x110(%rsp)
leaq 0x200(%rsp), %rdi
callq 0xe40a
movq 0xa8(%rsp), %rax
cmpq 0x118(%rsp), %rax
je 0x980e
leaq 0xa0(%rsp), %rdi
callq 0x65b0
movq %rax, %r14
movq %rax, %rdi
callq 0xd42a
movl 0x1c(%rsp), %ecx
andb %al, %cl
cmpb $0x1, %cl
jne 0x97b0
movq %r15, %rdi
movq %r14, %rsi
callq 0xd482
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd3f6
movq 0x80(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0xd437
movl %eax, %ebp
movq %rbx, %rdi
callq 0x61c0
movq %r15, %rdi
callq 0xd08a
testb %bpl, %bpl
leaq 0xf0(%rsp), %rbp
jne 0x97b4
jmp 0x97f8
testb %al, %al
je 0x97f8
movq %r15, %rdi
movq %r14, %rsi
callq 0xd500
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd3f6
movq %r12, %rdi
movq %rbx, %rsi
callq 0xeb38
movq %rbx, %rdi
callq 0x61c0
movq %r15, %rdi
callq 0xd08a
movq %r13, %rdi
movq %r14, %rsi
callq 0xd572
leaq 0xa0(%rsp), %rdi
callq 0x6120
pushq $0x17
popq %r14
jmp 0x9726
leaq 0x118(%rsp), %rdi
callq 0xe40a
leaq 0xa8(%rsp), %rdi
callq 0xe40a
leaq 0xf8(%rsp), %rdi
callq 0xe40a
movl $0x7, 0x80(%rsp)
movl 0x78(%rsp), %eax
movl %eax, 0x84(%rsp)
movl 0x34(%rsp), %eax
movl %eax, 0x88(%rsp)
movl 0x44(%rsp), %eax
movl %eax, 0x8c(%rsp)
movl $0x10, 0xf0(%rsp)
leaq 0xb110(%rip), %rdi      # 0x14983
movq %rbp, %rsi
movl %r14d, %edx
pushq $0x31
popq %rcx
movl $0xff, %r8d
movq 0x10(%rsp), %rbx
movq %rbx, %r9
callq 0x7221
movq %r15, %rdi
leaq 0x1b8(%rsp), %rsi
callq 0xd3f6
movq 0x148(%rsp), %rdi
movq %rbp, %rsi
movl %r14d, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
movq %rbx, %r9
callq 0x7221
movq %r15, %rdi
callq 0x61c0
movq %rbx, %rdi
leaq 0x80(%rsp), %rsi
movl $0xff, %edx
callq 0x6060
movslq 0x8(%rsp), %rbp
movq %rbp, %rbx
shlq $0x5, %rbx
movl 0x74(%rsp), %r13d
movq 0xe8(%rsp), %r14
movq 0x68(%rsp), %rsi
movq 0xb0(%rsp), %rax
movq 0xb8(%rsp), %rcx
subl $0x1, %r13d
jb 0x99e6
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rbp, %rdx
jbe 0x99e6
cmpq %rbp, %rsi
jne 0x99ba
movq %rbx, 0x138(%rsp)
movl 0x80(%rsp), %eax
movl 0x88(%rsp), %ecx
movl %eax, 0x148(%rsp)
leal -0x1(%r14), %eax
movl %eax, 0x14c(%rsp)
movl %ecx, 0x150(%rsp)
movl $0x12, 0x154(%rsp)
movq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rbx
movq %r15, %rsi
pushq $0x31
popq %r15
movl %r15d, %edx
callq 0x9ed8
movq 0xb0(%rsp), %rax
movq 0x68(%rsp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rdi
pushq $0x10
popq %rsi
movl %r14d, %edx
movl $0xff, %ecx
movl %r15d, %r8d
movq %r12, %r9
callq 0xd3e3
movq %rbx, %r15
movq 0x138(%rsp), %rbx
jmp 0x99d6
movq (%rax,%rbx), %rdi
pushq $0x10
popq %rsi
movl %r14d, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
movq 0x10(%rsp), %r9
callq 0xd3e3
incq %rbp
addl $0x12, %r14d
addq $0x20, %rbx
jmp 0x98f3
cmpq %rax, %rcx
jne 0x9a0c
leaq 0xaf9c(%rip), %rdi      # 0x1498e
pushq $0x10
popq %rsi
movl 0x70(%rsp), %edx
pushq $0x7
popq %rcx
movl $0xff, %r8d
movq 0x10(%rsp), %r9
callq 0xd3e3
movq 0x38(%rsp), %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
leaq 0x48(%rsp), %rcx
callq 0x6300
leaq 0xb0(%rsp), %r12
leaq 0x1e0(%rsp), %r13
leaq 0xf0(%rsp), %rbp
pushq $0x17
popq %r14
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
leaq 0x48(%rsp), %rcx
callq 0x6300
movq 0x81589d(%rip), %rdi    # 0x81f2f8
callq 0x63d0
pushq $0x10
popq %rdi
callq 0x62b0
cmpl $0x0, 0x7c(%rsp)
je 0x95ef
jmp 0x9c72
movq 0x28(%rsp), %rsi
movq 0x8(%rsp), %rcx
leal (%rcx,%rsi), %edx
cmpl %eax, %edx
je 0x9be8
movl %eax, %ecx
subl %esi, %ecx
jle 0x9be8
movw $0x89d, 0x11d96(%rip)   # imm = 0x89D
movw $0x1b8, 0x11d8f(%rip)   # imm = 0x1B8
addl %edx, %esi
cmpl %eax, %esi
cmovlel %edx, %ecx
movq (%rsp), %rax
cmpl %ecx, %eax
cmovlel %ecx, %eax
movq %rax, (%rsp)
movl %ecx, %eax
movq %rax, 0x8(%rsp)
jmp 0x95ef
cmpl $0x0, 0x8(%rsp)
je 0x9bfc
cmpl 0x28(%rsp), %eax
jle 0x9bfc
movw $0x89d, 0x11d4f(%rip)   # imm = 0x89D
movw $0x1b8, 0x11d48(%rip)   # imm = 0x1B8
movq 0x8(%rsp), %rsi
subl 0x28(%rsp), %esi
testl %esi, %esi
jg 0x9aff
xorl %esi, %esi
movq 0x28(%rsp), %rcx
leal (%rsi,%rcx), %eax
movq (%rsp), %rdx
cmpl %eax, %edx
movq %rsi, 0x8(%rsp)
leal -0x1(%rsi,%rcx), %eax
cmovll %edx, %eax
jmp 0x9bc8
movq (%rsp), %rax
testl %eax, %eax
je 0x9c02
movw $0x89d, 0x11d03(%rip)   # imm = 0x89D
movw $0x1b8, 0x11cfc(%rip)   # imm = 0x1B8
movq 0x8(%rsp), %rcx
cmpl %ecx, %eax
leal -0x1(%rax), %eax
cmovlel %eax, %ecx
jmp 0x9bc3
movq (%rsp), %rcx
incl %ecx
movw $0x89d, 0x11cdc(%rip)   # imm = 0x89D
movw $0x1b8, 0x11cd5(%rip)   # imm = 0x1B8
cmpl %eax, %ecx
je 0x95ef
movl %eax, %ecx
subl 0x28(%rsp), %ecx
movq %rcx, 0x8(%rsp)
testl %ecx, %ecx
jg 0x9b83
movq $0x0, 0x8(%rsp)
decl %eax
jmp 0x9bf3
decl %eax
movq (%rsp), %rsi
cmpl %eax, %esi
je 0x963d
movw $0x89d, 0x11c98(%rip)   # imm = 0x89D
movw $0x1b8, 0x11c91(%rip)   # imm = 0x1B8
leal 0x1(%rsi), %eax
movq 0x28(%rsp), %rdx
movq 0x8(%rsp), %rdi
leal (%rdi,%rdx), %ecx
subl %edx, %esi
addl $0x2, %esi
cmpl %ecx, %eax
movl %esi, %ecx
cmovll %edi, %ecx
movq %rcx, 0x8(%rsp)
movq %rax, (%rsp)
jmp 0x95ef
cmpl $0xd, %eax
je 0x9d90
cmpl $0x1b, %eax
jne 0x95ef
jmp 0x9de0
decl %eax
cmpl %eax, (%rsp)
je 0x963d
movq %rax, (%rsp)
jmp 0x95ef
cmpl $0x0, (%rsp)
jne 0x9c21
movw $0x2274, 0x11c2b(%rip)  # imm = 0x2274
movw $0x37, 0x11c24(%rip)    # 0x1b838
movq $0x0, (%rsp)
jmp 0x95ef
movw $0x89d, 0x11c0c(%rip)   # imm = 0x89D
movw $0x1b8, 0x11c05(%rip)   # imm = 0x1B8
movq $0x0, (%rsp)
jmp 0x95ef
movw $0x89d, 0x11bed(%rip)   # imm = 0x89D
movw $0x1b8, 0x11be6(%rip)   # imm = 0x1B8
movq $0x0, (%rsp)
jmp 0x95e6
leaq 0x148(%rsp), %rdi
movl $0x100, (%rdi)          # imm = 0x100
callq 0x6570
movl $0xd9, %r12d
leaq 0x48(%rsp), %r14
leaq 0x100(%rsp), %r15
leaq 0xd0(%rsp), %r13
pushq $0x10
popq %rbp
pushq $0x7
popq %rbx
testl %r12d, %r12d
je 0x9d2c
movzbl %r12b, %esi
movq 0x10(%rsp), %rdi
callq 0x65d0
movl 0x54(%rsp), %ecx
movl %ecx, %eax
imull %ebx, %eax
cltd
pushq $0x8
popq %rsi
idivl %esi
movl %eax, 0xdc(%rsp)
movl %eax, 0x10c(%rsp)
subl %eax, %ecx
movl %ecx, 0x104(%rsp)
movl 0x58(%rsp), %ecx
subl %eax, %ecx
imull 0x18(%rsp), %ecx
sarl $0x3, %ecx
movl %ecx, 0xd4(%rsp)
movq 0x38(%rsp), %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
movq %r14, %rcx
callq 0x6300
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq 0x20(%rsp), %rdx
movq %r13, %rcx
callq 0x6300
movq 0x8155e3(%rip), %rdi    # 0x81f2f8
callq 0x63d0
movl %ebp, %edi
callq 0x62b0
decl %ebx
addl $-0x1f, %r12d
jmp 0x9c93
leaq 0x48(%rsp), %rcx
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
callq 0x6300
movq %rbx, %rdi
callq 0x6340
movq 0x10(%rsp), %rdi
callq 0x6340
leaq 0x1e0(%rsp), %rdi
callq 0xd59e
leaq 0xb0(%rsp), %rdi
callq 0xd5c0
leaq 0x1b8(%rsp), %rdi
callq 0xd08a
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
imulq $0x28, %rsi, %rsi
addq 0x1e0(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0xd3f6
leaq 0x80(%rsp), %r14
movq 0xe0(%rsp), %rdi
movq %r14, %rsi
callq 0x6400
movq %r14, %rdi
callq 0x61c0
movw $0x89d, 0x11a64(%rip)   # imm = 0x89D
movw $0x370, 0x11a5d(%rip)   # imm = 0x370
jmp 0x9c72
movq 0xe0(%rsp), %rax
andq $0x0, 0x8(%rax)
movq (%rax), %rax
movb $0x0, (%rax)
jmp 0x9c72
jmp 0x9ea1
jmp 0x9ec0
jmp 0x9ec0
jmp 0x9ec0
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0xd08a
jmp 0x9ec3
jmp 0x9ec0
jmp 0x9ea1
jmp 0x9ec0
jmp 0x9ea1
jmp 0x9ea1
jmp 0x9ea1
jmp 0x9ea1
jmp 0x9ec0
jmp 0x9ec0
jmp 0x9ec0
jmp 0x9ec0
jmp 0x9ea1
jmp 0x9ea1
jmp 0x9e75
jmp 0x9e75
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x61c0
jmp 0x9e62
jmp 0x9e5f
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0xd08a
jmp 0x9e78
jmp 0x9e75
jmp 0x9ea1
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0xe40a
leaq 0xa8(%rsp), %rdi
callq 0xe40a
leaq 0xf8(%rsp), %rdi
callq 0xe40a
jmp 0x9ea4
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
callq 0xd59e
leaq 0xb0(%rsp), %rdi
callq 0xd5c0
jmp 0x9ec3
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
callq 0xd08a
movq %rbx, %rdi
callq 0x6580