// File: /workspace/github_cpp_makefile_star2_O1/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 $0x228, %rsp            # imm = 0x228
movq %rsi, 0x138(%rsp)
movl %edi, %ebx
imull $0x6d, 0x12a96(%rip), %edx # 0x1c454
xorl %edi, %edi
movl $0x1e0, %esi            # imm = 0x1E0
movl $0x8, %ecx
movl $0x13000801, %r8d       # imm = 0x13000801
callq 0x6090
movq %rax, %r13
movq %rax, %rdi
movl $0x1, %esi
callq 0x6270
movq %r13, %rdi
movl $0x1, %esi
movl $0xf9, %edx
callq 0x6420
movq 0x8168ea(%rip), %rdi    # 0x8202e8
callq 0x6460
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
callq 0x6270
movl 0x10(%r13), %ebp
movl 0x14(%r13), %r14d
movq %r15, 0x30(%rsp)
movq 0x8(%r15), %rax
movzbl 0x10(%rax), %r15d
movl 0x14(%rax), %esi
movl 0x18(%rax), %edx
movl 0x1c(%rax), %ecx
movl 0x20(%rax), %r8d
movl %r15d, %edi
callq 0x64f0
xorl %edi, %edi
movl %ebp, %esi
movl %r14d, %edx
movl %r15d, %ecx
movl %eax, %r8d
callq 0x6090
testq %r13, %r13
je 0x9ae8
testq %rax, %rax
je 0x9ae8
movq %rax, 0x40(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x6270
leaq 0x140(%rsp), %rdi
callq 0xeb8a
cmpl $0x2, %ebx
je 0x9b6a
cmpl $0x1, %ebx
je 0x9b0f
testl %ebx, %ebx
jne 0x9bc5
movq 0x1294c(%rip), %r14     # 0x1c3e8
movq 0x1294d(%rip), %r15     # 0x1c3f0
movl $0x4, 0x1c(%rsp)
leaq 0xce04(%rip), %rbx      # 0x168b6
leaq 0xcfa7(%rip), %r12      # 0x16a60
movb $0x1, %al
movl %eax, 0x2c(%rsp)
cmpq %r15, %r14
je 0x9c77
movq %r14, %rdi
callq 0x6140
testb %al, %al
je 0x9ae2
movzbl %al, %eax
cmpl $0xff, %eax
jne 0xaa41
addq $0x28, %r14
jmp 0x9abf
callq 0x62b0
leaq 0xca64(%rip), %rdi      # 0x16558
movq %rax, %rsi
xorl %eax, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6470
movq 0x128ea(%rip), %r14     # 0x1c400
movq 0x128eb(%rip), %r15     # 0x1c408
movl $0x2, 0xc(%rsp)
movl $0x3, 0x1c(%rsp)
leaq 0xcd95(%rip), %rbx      # 0x168c9
leaq 0xcdc0(%rip), %r12      # 0x168fb
movb $0x1, %al
movl %eax, 0x2c(%rsp)
cmpq %r15, %r14
je 0x9c7f
movq %r14, %rdi
callq 0x6140
testb %al, %al
je 0x9b64
movzbl %al, %eax
cmpl $0xff, %eax
jne 0xa9c1
addq $0x28, %r14
jmp 0x9b41
movq 0x128a7(%rip), %r14     # 0x1c418
movq 0x128a8(%rip), %r15     # 0x1c420
movl $0x6, 0xc(%rsp)
movl $0x5, 0x1c(%rsp)
leaq 0xcd4e(%rip), %rbx      # 0x168dd
leaq 0xcd6e(%rip), %r12      # 0x16904
movb $0x1, %al
movl %eax, 0x2c(%rsp)
cmpq %r15, %r14
je 0x9c7f
movq %r14, %rdi
callq 0x6140
testb %al, %al
je 0x9bbf
movzbl %al, %eax
cmpl $0xff, %eax
jne 0xa9d3
addq $0x28, %r14
jmp 0x9b9c
leaq 0xc9ef(%rip), %rsi      # 0x165bb
leaq 0x98(%rsp), %rdi
movl $0x2, %edx
callq 0xebb2
leaq 0x168(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x6200
leaq 0x140(%rsp), %rbx
leaq 0x168(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6400
movq 0x20(%r14), %rax
movq $0x0, 0x20(%r14)
movq 0x20(%rbx), %rsi
movq %rax, 0x20(%rbx)
testq %rsi, %rsi
je 0x9c34
leaq 0x160(%rsp), %rdi
callq 0x60e0
leaq 0x168(%rsp), %rbx
movq %rbx, %rdi
callq 0xfbcc
movq %rbx, %rdi
callq 0xe8d0
leaq 0x98(%rsp), %rdi
callq 0xe8d0
movl $0x4, 0x1c(%rsp)
leaq 0xcc3f(%rip), %rbx      # 0x168a7
leaq 0xccfe(%rip), %r12      # 0x1696d
movl $0x0, 0x2c(%rsp)
movl $0x4, 0xc(%rsp)
movq 0x816662(%rip), %rdi    # 0x8202e8
leaq 0x74(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x6150
movl 0x10(%r13), %eax
movl %eax, 0x68(%rsp)
movl 0x14(%r13), %ecx
movl %ecx, 0x6c(%rsp)
movl 0x74(%rsp), %edx
subl %eax, %edx
imull 0xc(%rsp), %edx
sarl $0x3, %edx
movl %edx, 0x60(%rsp)
movl 0x70(%rsp), %eax
subl %ecx, %eax
imull 0x1c(%rsp), %eax
sarl $0x3, %eax
movl %eax, 0x64(%rsp)
movq 0x8(%r13), %rax
movq 0x8(%rax), %rdi
callq 0x732e
movq 0x81660b(%rip), %rdi    # 0x8202e8
callq 0x63d0
leaq 0x60(%rsp), %rsi
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rdx
xorl %ecx, %ecx
callq 0x62e0
movq %r13, %rdi
movl $0xff, %esi
movl $0x39, %edx
movq %rbx, %rcx
movl $0xff, %r8d
callq 0x73eb
movl $0xfffffe82, %eax       # imm = 0xFFFFFE82
leaq 0x60(%rsp), %rbx
addl 0x8(%rbx), %eax
sarl %eax
leaq 0x1dc(%rsp), %rsi
movl %eax, (%rsi)
movl 0xc(%rbx), %edx
addl $-0x14, %edx
leaq 0xcbd4(%rip), %rdi      # 0x1690d
movl $0x31, %ecx
movl $0xff, %r8d
movq %r13, %r9
callq 0x76a4
movl 0x8(%rbx), %eax
movl %eax, 0x3c(%rsp)
movl 0xc(%rbx), %esi
leal -0x3c(%rsi), %eax
cltq
imulq $0x38e38e39, %rax, %rax # imm = 0x38E38E39
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rax
leal (%rax,%rcx), %edx
movq %rdx, 0x130(%rsp)
addl %edx, %edx
leal (%rdx,%rdx,8), %edx
movq %rsi, 0x1c8(%rsp)
movl %edx, 0x5c(%rsp)
subl %edx, %esi
addl $0x14, %esi
sarl %esi
addl %ecx, %eax
decl %eax
shrl %eax
leal (%rax,%rax,8), %eax
movq %rsi, 0x128(%rsp)
leal (%rsi,%rax,2), %edx
leaq 0x168(%rsp), %rsi
movl $0x10, (%rsi)
leaq 0xcb8f(%rip), %rdi      # 0x16948
movl %edx, 0xf4(%rsp)
movl $0x7, %ecx
movl $0xff, %r8d
movq %r13, 0x20(%rsp)
movq %r13, %r9
callq 0x76a4
movups (%rbx), %xmm0
leaq 0x110(%rsp), %r14
movaps %xmm0, (%r14)
leaq 0x1b8(%rsp), %r15
movq $0x0, (%r15)
movq 0x8(%rbx), %rax
movq %rax, 0x8(%r15)
movl $0x1, %r13d
movb $0x1f, %bpl
movzbl %bpl, %esi
movq 0x20(%rsp), %rdi
callq 0x65b0
movl 0x68(%rsp), %eax
imull %r13d, %eax
leal 0x7(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x3, %ecx
movl %ecx, 0x118(%rsp)
movl %ecx, 0x1c0(%rsp)
movl 0x74(%rsp), %eax
subl %ecx, %eax
imull 0xc(%rsp), %eax
sarl $0x3, %eax
movl %eax, 0x110(%rsp)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
movq %rbx, %rcx
callq 0x62e0
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rdx
movq %r14, %rcx
callq 0x62e0
movq 0x81646d(%rip), %rdi    # 0x8202e8
callq 0x63d0
movl $0x10, %edi
callq 0x6290
incl %r13d
addb $0x1f, %bpl
cmpl $0x9, %r13d
jne 0x9e07
xorps %xmm0, %xmm0
leaq 0xd0(%rsp), %rax
movaps %xmm0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x10(%rax)
leaq 0x1a0(%rsp), %rax
movq %rcx, 0x10(%rax)
movaps %xmm0, (%rax)
leaq 0x88(%rsp), %r13
movl 0x3c(%rsp), %eax
movq 0x128(%rsp), %rcx
subl %ecx, %eax
addl $-0x47, %eax
movl %eax, 0x3c(%rsp)
addl $0x2, 0x5c(%rsp)
movq 0x130(%rsp), %r14
cmpl $0x2, %r14d
movl $0x1, %eax
cmovgel %r14d, %eax
movl %eax, 0xf8(%rsp)
leal -0x1(%rcx), %eax
movl %eax, 0xfc(%rsp)
leaq 0x168(%rsp), %rbx
leaq 0x48(%rsp), %rbp
leaq 0x98(%rsp), %r15
movq $0x0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %r12, 0x1d0(%rsp)
movq %rbx, %rdi
callq 0x6220
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0xa017
movl 0x168(%rsp), %ecx
cmpl $0x100, %ecx            # imm = 0x100
je 0x9f90
movb $0x1, %al
cmpl $0x300, %ecx            # imm = 0x300
jne 0x9fa5
testb $-0x40, 0x180(%rsp)
je 0x9fae
movl 0x17c(%rsp), %ecx
cmpl $0x65, %ecx
je 0x9f7c
cmpl $0x64, %ecx
jne 0x9fa5
movw $0x2274, 0x128a1(%rip)  # imm = 0x2274
movw $0x37, 0x1289a(%rip)    # 0x1c828
jmp 0x9fa5
movl $0x100, 0x98(%rsp) # imm = 0x100
movq %r15, %rdi
callq 0x6540
xorl %eax, %eax
testb %al, %al
jne 0x9f34
jmp 0xa84a
movl 0x17c(%rsp), %ecx
leal -0x4000004a(%rcx), %edx
cmpl $0xe, %edx
ja 0xa0dc
movq 0xd8(%rsp), %rcx
subq 0xd0(%rsp), %rcx
shrq $0x5, %rcx
leaq 0x9165(%rip), %rsi      # 0x13144
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
cmpl $0x0, (%rsp)
je 0xa85d
movw $0x89d, 0x1282b(%rip)   # imm = 0x89D
movw $0x1b8, 0x12824(%rip)   # imm = 0x1B8
movq $0x0, (%rsp)
movq $0x0, 0x10(%rsp)
jmp 0x9fa5
movq 0xd0(%rsp), %r14
movq 0xd8(%rsp), %r15
cmpq %r14, %r15
je 0xa05c
leaq 0x10(%r14), %rbx
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0xa044
movq (%rbx), %rsi
incq %rsi
callq 0x6390
leaq 0x20(%rbx), %rax
addq $0x10, %rbx
cmpq %r15, %rbx
movq %rax, %rbx
jne 0xa030
movq %r14, 0xd8(%rsp)
movq 0x1a0(%rsp), %rbx
movq 0x1a8(%rsp), %r14
cmpq %rbx, %r14
leaq 0xa8(%rsp), %r15
je 0xa09a
movq %rbx, %rbp
movq %rbp, %rdi
callq 0xe8d0
addq $0x28, %rbp
cmpq %r14, %rbp
jne 0xa07c
movq %rbx, 0x1a8(%rsp)
leaq 0x48(%rsp), %rbp
movq %rbp, %rdi
leaq 0x140(%rsp), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x6210
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
testq %rcx, %rcx
je 0xa2da
movq 0x11f15(%rip), %rdx     # 0x1bfe0
cmpb $0x0, (%rdx)
je 0xa2d6
incl 0x8(%rcx)
jmp 0xa2da
cmpl $0xd, %ecx
je 0xa105
cmpl $0x1b, %ecx
jne 0x9fa5
movq 0x138(%rsp), %rax
movq $0x0, 0x8(%rax)
movq (%rax), %rax
movb $0x0, (%rax)
jmp 0x9fa3
movq %r14, %r15
movq %rbp, %r14
movslq (%rsp), %rax
movq 0x1a0(%rsp), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %rsi
movq 0x8(%rcx,%rax,8), %rdx
addq %rsi, %rdx
movq %r13, 0x78(%rsp)
leaq 0x78(%rsp), %rbp
movq %rbp, %rdi
callq 0xfb30
movq 0x138(%rsp), %rdi
movq %rbp, %rsi
callq 0x6400
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0xa163
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6390
movw $0x89d, 0x126ba(%rip)   # imm = 0x89D
movw $0x370, 0x126b3(%rip)   # imm = 0x370
xorl %eax, %eax
movq %r14, %rbp
movq %r15, %r14
leaq 0x98(%rsp), %r15
jmp 0x9fa5
movq (%rsp), %rdx
incl %edx
movw $0x89d, 0x1268d(%rip)   # imm = 0x89D
movw $0x1b8, 0x12686(%rip)   # imm = 0x1B8
cmpl %ecx, %edx
je 0x9fa5
movl %ecx, %esi
subl %r14d, %esi
decl %ecx
testl %esi, %esi
movl $0x0, %edx
cmovlel %edx, %esi
movq %rsi, 0x10(%rsp)
jmp 0xa887
cmpl $0x0, 0x10(%rsp)
je 0xa857
cmpl %r14d, %ecx
jle 0xa857
movw $0x89d, 0x12644(%rip)   # imm = 0x89D
movw $0x1b8, 0x1263d(%rip)   # imm = 0x1B8
movq 0x10(%rsp), %rdx
subl %r14d, %edx
testl %edx, %edx
movl $0x0, %ecx
cmovlel %ecx, %edx
leal (%rdx,%r14), %ecx
movq (%rsp), %rsi
cmpl %ecx, %esi
movq %rdx, 0x10(%rsp)
leal -0x1(%rdx,%r14), %ecx
cmovll %esi, %ecx
jmp 0xa281
movq (%rsp), %rcx
testl %ecx, %ecx
je 0xa85d
movw $0x89d, 0x125fb(%rip)   # imm = 0x89D
movw $0x1b8, 0x125f4(%rip)   # imm = 0x1B8
movq 0x10(%rsp), %rdx
cmpl %edx, %ecx
leal -0x1(%rcx), %ecx
cmovlel %ecx, %edx
jmp 0xa27c
decl %ecx
movq (%rsp), %rdi
cmpl %ecx, %edi
je 0x9f7c
movw $0x89d, 0x125cc(%rip)   # imm = 0x89D
movw $0x1b8, 0x125c5(%rip)   # imm = 0x1B8
leal 0x1(%rdi), %ecx
movq 0x10(%rsp), %rsi
leal (%rsi,%r14), %edx
subl %r14d, %edi
addl $0x2, %edi
cmpl %edx, %ecx
movl %edi, %edx
cmovll %esi, %edx
movq %rdx, 0x10(%rsp)
jmp 0xa887
movq 0x10(%rsp), %rdx
leal (%rdx,%r14), %esi
cmpl %ecx, %esi
je 0xa87c
movl %ecx, %edx
subl %r14d, %edx
jle 0xa87c
movw $0x89d, 0x1257b(%rip)   # imm = 0x89D
movw $0x1b8, 0x12574(%rip)   # imm = 0x1B8
leal (%rsi,%r14), %edi
cmpl %ecx, %edi
cmovlel %esi, %edx
movq (%rsp), %rcx
cmpl %edx, %ecx
cmovlel %edx, %ecx
movq %rcx, (%rsp)
movl %edx, %ecx
movq %rcx, 0x10(%rsp)
jmp 0x9fa5
lock
incl 0x8(%rcx)
movq %rax, 0x100(%rsp)
movq %rcx, 0x108(%rsp)
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xa313
movq 0x11ce5(%rip), %rax     # 0x1bfe0
cmpb $0x0, (%rax)
je 0xa305
incl 0x8(%rdi)
jmp 0xa309
lock
incl 0x8(%rdi)
testq %rdi, %rdi
je 0xa313
callq 0xfbea
cmpq $0x0, 0x108(%rsp)
je 0xa58f
leaq 0x100(%rsp), %rdi
callq 0x6580
movq %rax, %rbp
movzbl 0x28(%rax), %eax
cmpl $0x3, %eax
je 0xa33f
testl %eax, %eax
jne 0xa347
movq %rbp, %rdi
callq 0x6140
cmpb $0x1, %al
sete %r15b
movl 0x2c(%rsp), %eax
movl %eax, %r14d
andb %r15b, %r14b
cmpb $0x1, %r14b
jne 0xa454
movq %rbp, %rdi
callq 0x6190
testq %rax, %rax
setne %cl
cmpq $-0x1, %rdx
setne %sil
andb %cl, %sil
cmpb $0x1, %sil
jne 0xa3d6
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
movq $-0x1, %rcx
callq 0x63b0
leaq 0xa8(%rsp), %r15
leaq 0x200(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
callq 0xfc5a
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0xa3e3
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6390
jmp 0xa3e3
leaq 0x200(%rsp), %rdi
callq 0xeb8a
movq 0x200(%rsp), %rsi
leaq 0x1f0(%rsp), %rax
movq %rax, 0x1e0(%rsp)
movq 0x208(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1e0(%rsp), %rdi
callq 0xfb30
movq 0x1e0(%rsp), %r13
movb $0x1, %r15b
cmpq %r12, %r13
je 0xa44c
xorl %ebx, %ebx
movsbl (%r13,%rbx), %edi
testl %edi, %edi
jne 0xa436
cmpb $0x0, (%r12,%rbx)
je 0xa44c
callq 0x64a0
movsbl (%r12,%rbx), %ecx
cmpl %ecx, %eax
jne 0xa449
incq %rbx
jmp 0xa425
xorl %r15d, %r15d
leaq 0x88(%rsp), %r13
testb %r14b, %r14b
je 0xa48b
movq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %rax
cmpq %rax, %rdi
je 0xa47e
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x6390
leaq 0x200(%rsp), %rdi
callq 0xe8d0
testb %r15b, %r15b
leaq 0xa8(%rsp), %r15
je 0xa57d
movq 0x8(%rbp), %rax
testq %rax, %rax
je 0xa504
movq 0x20(%rbp), %rcx
movl %ecx, %edx
notb %dl
movq %rbp, %rsi
testb $0x3, %dl
je 0xa4f5
movl %ecx, %edx
andl $0x3, %edx
jne 0xa504
movq (%rbp), %rdx
cmpb $0x2f, -0x1(%rdx,%rax)
je 0xa504
testb $0x3, %cl
je 0xa4d0
xorl %eax, %eax
jmp 0xa4d9
leaq 0x20(%rbp), %rdi
callq 0x6240
leaq -0x30(%rax), %rcx
testb $0x3, 0x20(%rbp)
cmovneq %rax, %rcx
movq %rbp, %rsi
cmoveq %rcx, %rsi
movl 0x20(%rsi), %eax
notl %eax
testb $0x3, %al
jne 0xa504
leaq 0x98(%rsp), %rdi
callq 0xfcfe
jmp 0xa511
leaq 0x98(%rsp), %rdi
callq 0xeb8a
movq 0x98(%rsp), %rsi
movq %r13, 0x78(%rsp)
movq 0xa0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rbx
movq %rbx, %rdi
callq 0xfb30
leaq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x10318
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0xa560
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6390
leaq 0x98(%rsp), %rdi
callq 0xe8d0
leaq 0x1a0(%rsp), %rdi
movq %rbp, %rsi
callq 0xec3a
leaq 0x100(%rsp), %rdi
callq 0x6120
jmp 0xa313
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0xa5a1
callq 0xfbea
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
movq 0x20(%rsp), %rbx
leaq 0x48(%rsp), %r14
je 0xa5ba
callq 0xfbea
movl $0x7, 0x78(%rsp)
movl 0xfc(%rsp), %eax
movl %eax, 0x7c(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0x80(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x84(%rsp)
movl $0x10, 0x48(%rsp)
leaq 0xc371(%rip), %rdi      # 0x16963
movq %r14, %rsi
movl $0x17, %edx
movl $0x31, %ecx
movl $0xff, %r8d
movq %rbx, %r9
callq 0x76a4
movq 0x140(%rsp), %rsi
movq %r15, 0x98(%rsp)
movq 0x148(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0xfb30
movq 0x98(%rsp), %rdi
movq %r14, %rsi
movl $0x17, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
movq %rbx, %r9
callq 0x76a4
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0xa672
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6390
movq %rbx, %rdi
leaq 0x78(%rsp), %rsi
movl $0xff, %edx
callq 0x6060
cmpl $0x4e, 0x1c8(%rsp)
jl 0xa79f
movslq 0x10(%rsp), %r14
movslq (%rsp), %rbx
movq %r14, %r15
shlq $0x5, %r15
movl 0xf8(%rsp), %r13d
movq 0x128(%rsp), %rbp
movq 0xd0(%rsp), %rax
movq 0xd8(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %r14, %rcx
jbe 0xa79f
cmpq %r14, %rbx
jne 0xa761
movq %rbx, %r12
movl 0x78(%rsp), %eax
movl 0x80(%rsp), %ecx
movl %eax, 0x98(%rsp)
leal -0x1(%rbp), %eax
movl %eax, 0x9c(%rsp)
movl %ecx, 0xa0(%rsp)
movl $0x12, 0xa4(%rsp)
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
leaq 0x98(%rsp), %rsi
movl $0x31, %edx
callq 0xabb1
movq 0xd0(%rsp), %rax
movq (%rax,%r15), %rdi
movl $0x10, 0x48(%rsp)
leaq 0x48(%rsp), %rsi
movl %ebp, %edx
movl $0xff, %ecx
movl $0x31, %r8d
movq %rbx, %r9
callq 0x76a4
movq %r12, %rbx
movq 0x1d0(%rsp), %r12
jmp 0xa78c
movq (%rax,%r15), %rdi
movl $0x10, 0x98(%rsp)
leaq 0x98(%rsp), %rsi
movl %ebp, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
movq 0x20(%rsp), %r9
callq 0x76a4
incq %r14
addl $0x12, %ebp
addq $0x20, %r15
decl %r13d
jne 0xa6b2
movq 0xd8(%rsp), %rax
cmpq 0xd0(%rsp), %rax
movq 0x20(%rsp), %rbx
leaq 0x98(%rsp), %r15
jne 0xa7ed
movl $0x10, 0x98(%rsp)
leaq 0xc19e(%rip), %rdi      # 0x1696e
movq %r15, %rsi
movl 0xf4(%rsp), %edx
movl $0x7, %ecx
movl $0xff, %r8d
movq %rbx, %r9
callq 0x76a4
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0x62e0
movq 0x130(%rsp), %r14
leaq 0x88(%rsp), %r13
leaq 0x48(%rsp), %rbp
movq %rbx, %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0x62e0
movq 0x815ab5(%rip), %rdi    # 0x8202e8
callq 0x63d0
movl $0x10, %edi
callq 0x6290
leaq 0x168(%rsp), %rbx
cmpl $0x0, 0xc(%rsp)
je 0x9f34
jmp 0xa8a4
cmpl $0x0, (%rsp)
jne 0xa890
movw $0x2274, 0x11fc0(%rip)  # imm = 0x2274
movw $0x37, 0x11fb9(%rip)    # 0x1c828
movq $0x0, (%rsp)
jmp 0x9fa5
decl %ecx
cmpl %ecx, (%rsp)
je 0x9f7c
movq %rcx, (%rsp)
jmp 0x9fa5
movw $0x89d, 0x11f8d(%rip)   # imm = 0x89D
movw $0x1b8, 0x11f86(%rip)   # imm = 0x1B8
jmp 0xa86f
movl $0x8, %ebp
movb $-0x27, %r12b
leaq 0x60(%rsp), %rbx
leaq 0x1b8(%rsp), %r14
leaq 0x110(%rsp), %r15
movzbl %r12b, %esi
movq 0x20(%rsp), %rdi
callq 0x65b0
decl %ebp
movl 0x6c(%rsp), %eax
movl %eax, %ecx
imull %ebp, %ecx
leal 0x7(%rcx), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
sarl $0x3, %edx
movl %edx, 0x11c(%rsp)
movl %edx, 0x1c4(%rsp)
subl %edx, %eax
movl %eax, 0x1bc(%rsp)
movl 0x70(%rsp), %eax
subl %edx, %eax
imull 0x1c(%rsp), %eax
sarl $0x3, %eax
movl %eax, 0x114(%rsp)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
movq %rbx, %rcx
callq 0x62e0
movq 0x20(%rsp), %rdi
movq %r14, %rsi
movq 0x30(%rsp), %rdx
movq %r15, %rcx
callq 0x62e0
movq 0x8159a7(%rip), %rdi    # 0x8202e8
callq 0x63d0
movl $0x10, %edi
callq 0x6290
addb $-0x1f, %r12b
cmpl $0x1, %ebp
ja 0xa8c1
leaq 0x60(%rsp), %rcx
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
callq 0x62e0
movq %rbx, %rdi
callq 0x6320
movq 0x20(%rsp), %rdi
callq 0x6320
leaq 0x1a0(%rsp), %rdi
callq 0xec66
leaq 0xd0(%rsp), %rdi
callq 0xeca8
leaq 0x140(%rsp), %rdi
callq 0xe8d0
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x168(%rsp), %rdi
movq %r14, %rsi
callq 0x6200
jmp 0xa9e3
leaq 0x168(%rsp), %rdi
movq %r14, %rsi
callq 0x6200
leaq 0x140(%rsp), %r14
leaq 0x168(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x6400
movq 0x20(%r15), %rax
movq $0x0, 0x20(%r15)
movq 0x20(%r14), %rsi
movq %rax, 0x20(%r14)
testq %rsi, %rsi
je 0xaa24
leaq 0x160(%rsp), %rdi
callq 0x60e0
leaq 0x168(%rsp), %r14
movq %r14, %rdi
callq 0xfbcc
movq %r14, %rdi
callq 0xe8d0
jmp 0x9c7f
leaq 0x168(%rsp), %rdi
movq %r14, %rsi
callq 0x6200
leaq 0x140(%rsp), %r14
leaq 0x168(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x6400
movq 0x20(%r15), %rax
movq $0x0, 0x20(%r15)
movq 0x20(%r14), %rsi
movq %rax, 0x20(%r14)
testq %rsi, %rsi
je 0xaa92
leaq 0x160(%rsp), %rdi
callq 0x60e0
leaq 0x168(%rsp), %r14
movq %r14, %rdi
callq 0xfbcc
movq %r14, %rdi
callq 0xe8d0
jmp 0x9c77
jmp 0xab0f
jmp 0xab0f
jmp 0xab0f
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0xe8d0
jmp 0xab9c
jmp 0xab0f
jmp 0xab0f
jmp 0xab59
jmp 0xab0f
jmp 0xab0f
jmp 0xab0f
jmp 0xab0f
jmp 0xab59
jmp 0xab59
jmp 0xab59
jmp 0xab59
jmp 0xab59
jmp 0xab59
jmp 0xab5e
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0xab61
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6390
jmp 0xab61
jmp 0xab5e
jmp 0xab59
movq %rax, %rbx
jmp 0xab9c
jmp 0xab59
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0xab48
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6390
jmp 0xab48
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
jmp 0xab50
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0xe8d0
jmp 0xab61
jmp 0xab5e
movq %rax, %rbx
jmp 0xab82
movq %rax, %rbx
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0xab73
callq 0xfbea
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xab82
callq 0xfbea
leaq 0x1a0(%rsp), %rdi
callq 0xec66
leaq 0xd0(%rsp), %rdi
callq 0xeca8
leaq 0x140(%rsp), %rdi
callq 0xe8d0
movq %rbx, %rdi
callq 0x6550