// File: /workspace/github_cpp_makefile_star2_O3/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, 0x118(%rsp)
movl %edi, %ebp
imull $0x6d, 0x1244a(%rip), %edx # 0x1c454
xorl %edi, %edi
movl $0x1e0, %esi            # imm = 0x1E0
movl $0x8, %ecx
movl $0x13000801, %r8d       # imm = 0x13000801
callq 0x6090
movq %rax, %r14
movq %rax, %rdi
movl $0x1, %esi
callq 0x6270
movq %r14, %rdi
movl $0x1, %esi
movl $0xf9, %edx
callq 0x6420
movq 0x81629e(%rip), %rdi    # 0x8202e8
callq 0x6460
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
callq 0x6270
movl 0x10(%r14), %r15d
movl 0x14(%r14), %r12d
movq %rbx, 0x30(%rsp)
movq 0x8(%rbx), %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 0x64f0
xorl %edi, %edi
movl %r15d, %esi
movl %r12d, %edx
movl %r13d, %ecx
movl %eax, %r8d
callq 0x6090
testq %rax, %rax
je 0xa12b
movq %rax, 0x68(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x6270
leaq 0x148(%rsp), %rdi
callq 0xf16a
cmpl $0x2, %ebp
je 0xa1ac
cmpl $0x1, %ebp
je 0xa152
testl %ebp, %ebp
jne 0xa206
movq 0x12308(%rip), %r12     # 0x1c3e8
movq 0x12309(%rip), %rbx     # 0x1c3f0
movl $0x4, 0x2c(%rsp)
leaq 0xc8b0(%rip), %r15      # 0x169a6
leaq 0xca53(%rip), %rax      # 0x16b50
movq %rax, 0x40(%rsp)
cmpq %rbx, %r12
je 0xa3b4
movq %r12, %rdi
callq 0x6140
testb %al, %al
je 0xa125
movzbl %al, %eax
cmpl $0xff, %eax
jne 0xa349
addq $0x28, %r12
jmp 0xa102
callq 0x62b0
leaq 0xc511(%rip), %rdi      # 0x16648
movq %rax, %rsi
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6470
movq 0x122a7(%rip), %r12     # 0x1c400
movq 0x122a8(%rip), %rbx     # 0x1c408
movl $0x2, 0x18(%rsp)
movl $0x3, 0x2c(%rsp)
leaq 0xc842(%rip), %r15      # 0x169b9
leaq 0xc86d(%rip), %rax      # 0x169eb
movq %rax, 0x40(%rsp)
cmpq %rbx, %r12
je 0xa33f
movq %r12, %rdi
callq 0x6140
testb %al, %al
je 0xa1a6
movzbl %al, %eax
cmpl $0xff, %eax
jne 0xa2c2
addq $0x28, %r12
jmp 0xa183
movq 0x12265(%rip), %r12     # 0x1c418
movq 0x12266(%rip), %rbx     # 0x1c420
movl $0x6, 0x18(%rsp)
movl $0x5, 0x2c(%rsp)
leaq 0xc7fc(%rip), %r15      # 0x169cd
leaq 0xc81c(%rip), %rax      # 0x169f4
movq %rax, 0x40(%rsp)
cmpq %rbx, %r12
je 0xa33f
movq %r12, %rdi
callq 0x6140
testb %al, %al
je 0xa200
movzbl %al, %eax
cmpl $0xff, %eax
jne 0xa2d4
addq $0x28, %r12
jmp 0xa1dd
leaq 0xc49e(%rip), %rsi      # 0x166ab
leaq 0xc8(%rsp), %rdi
movl $0x2, %edx
callq 0xf192
leaq 0x190(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x6200
leaq 0x148(%rsp), %r15
leaq 0x190(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x6400
movq 0x20(%r12), %rax
movq $0x0, 0x20(%r12)
movq 0x20(%r15), %rsi
movq %rax, 0x20(%r15)
testq %rsi, %rsi
je 0xa277
leaq 0x168(%rsp), %rdi
callq 0x60e0
leaq 0x190(%rsp), %r15
movq %r15, %rdi
callq 0x10128
movq %r15, %rdi
callq 0xeeb0
leaq 0xc8(%rsp), %rdi
callq 0xeeb0
movl $0x4, 0x2c(%rsp)
leaq 0xc6ec(%rip), %r15      # 0x16997
leaq 0xc7ab(%rip), %rax      # 0x16a5d
movq %rax, 0x40(%rsp)
movb $0x1, %al
movl %eax, 0x14(%rsp)
jmp 0xa3bc
leaq 0x190(%rsp), %rdi
movq %r12, %rsi
callq 0x6200
jmp 0xa2e4
leaq 0x190(%rsp), %rdi
movq %r12, %rsi
callq 0x6200
leaq 0x148(%rsp), %r12
leaq 0x190(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x6400
movq 0x20(%r13), %rax
movq $0x0, 0x20(%r13)
movq 0x20(%r12), %rsi
movq %rax, 0x20(%r12)
testq %rsi, %rsi
je 0xa327
leaq 0x168(%rsp), %rdi
callq 0x60e0
leaq 0x190(%rsp), %r12
movq %r12, %rdi
callq 0x10128
movq %r12, %rdi
callq 0xeeb0
movl $0x0, 0x14(%rsp)
jmp 0xa3c4
leaq 0x190(%rsp), %rdi
movq %r12, %rsi
callq 0x6200
leaq 0x148(%rsp), %r12
leaq 0x190(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x6400
movq 0x20(%r13), %rax
movq $0x0, 0x20(%r13)
movq 0x20(%r12), %rsi
movq %rax, 0x20(%r12)
testq %rsi, %rsi
je 0xa39c
leaq 0x168(%rsp), %rdi
callq 0x60e0
leaq 0x190(%rsp), %r12
movq %r12, %rdi
callq 0x10128
movq %r12, %rdi
callq 0xeeb0
movl $0x0, 0x14(%rsp)
movl $0x4, 0x18(%rsp)
movq 0x815f1d(%rip), %rdi    # 0x8202e8
leaq 0x8c(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x6150
movl 0x10(%r14), %eax
movl %eax, 0x80(%rsp)
movl 0x14(%r14), %ecx
movl %ecx, 0x84(%rsp)
movl 0x8c(%rsp), %edx
subl %eax, %edx
imull 0x18(%rsp), %edx
sarl $0x3, %edx
movl %edx, 0x78(%rsp)
movl 0x88(%rsp), %eax
subl %ecx, %eax
imull 0x2c(%rsp), %eax
sarl $0x3, %eax
movl %eax, 0x7c(%rsp)
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
callq 0x731e
movq 0x815eb4(%rip), %rdi    # 0x8202e8
callq 0x63d0
leaq 0x78(%rsp), %rsi
movq 0x30(%rsp), %rdi
movq 0x68(%rsp), %rdx
xorl %ecx, %ecx
callq 0x62e0
movq %r14, %rdi
movl $0xff, %esi
movl $0x39, %edx
movq %r15, %rcx
movl $0xff, %r8d
callq 0x7ae5
movl $0xfffffe82, %eax       # imm = 0xFFFFFE82
leaq 0x78(%rsp), %r15
addl 0x8(%r15), %eax
sarl %eax
leaq 0x204(%rsp), %rsi
movl %eax, (%rsi)
movl 0xc(%r15), %edx
addl $-0x14, %edx
leaq 0xc56b(%rip), %rdi      # 0x169fd
movl $0x31, %ecx
movl $0xff, %r8d
movq %r14, %r9
callq 0x7d9f
movl 0x8(%r15), %eax
movl %eax, 0x3c(%rsp)
movl 0xc(%r15), %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, 0x128(%rsp)
addl %edx, %edx
leal (%rdx,%rdx,8), %edx
movq %rsi, 0x1f8(%rsp)
movl %edx, 0x74(%rsp)
subl %edx, %esi
addl $0x14, %esi
sarl %esi
addl %ecx, %eax
decl %eax
shrl %eax
leal (%rax,%rax,8), %eax
movq %rsi, 0x120(%rsp)
leal (%rsi,%rax,2), %edx
leaq 0x190(%rsp), %rsi
movl $0x10, (%rsi)
leaq 0xc524(%rip), %rdi      # 0x16a38
movl %edx, 0xbc(%rsp)
movl $0x7, %ecx
movl $0xff, %r8d
movq %r14, %r9
callq 0x7d9f
movups (%r15), %xmm0
leaq 0x100(%rsp), %r12
movaps %xmm0, (%r12)
leaq 0x1e8(%rsp), %r13
movq $0x0, (%r13)
movq 0x8(%r15), %rax
movq %rax, 0x8(%r13)
movl $0x1, %ebp
movb $0x1f, %bl
movzbl %bl, %esi
movq %r14, %rdi
callq 0x65b0
movl 0x80(%rsp), %eax
imull %ebp, %eax
leal 0x7(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x3, %ecx
movl %ecx, 0x108(%rsp)
movl %ecx, 0x1f0(%rsp)
movl 0x8c(%rsp), %eax
subl %ecx, %eax
imull 0x18(%rsp), %eax
sarl $0x3, %eax
movl %eax, 0x100(%rsp)
movq 0x68(%rsp), %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
movq %r15, %rcx
callq 0x62e0
movq %r14, %rdi
movq %r13, %rsi
movq 0x30(%rsp), %rdx
movq %r12, %rcx
callq 0x62e0
movq 0x815d16(%rip), %rdi    # 0x8202e8
callq 0x63d0
movl $0x10, %edi
callq 0x6290
incl %ebp
addb $0x1f, %bl
cmpl $0x9, %ebp
jne 0xa55e
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rax
movaps %xmm0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x10(%rax)
leaq 0x170(%rsp), %rax
movq $0x0, 0x8(%rsp)
movq %rcx, 0x10(%rax)
movaps %xmm0, (%rax)
leaq 0x58(%rsp), %r12
movq 0x120(%rsp), %rcx
leal -0x1(%rcx), %eax
movl %eax, 0xc4(%rsp)
movl 0x3c(%rsp), %eax
subl %ecx, %eax
addl $-0x47, %eax
movl %eax, 0x3c(%rsp)
addl $0x2, 0x74(%rsp)
movq 0x128(%rsp), %rax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movl %ecx, 0xc0(%rsp)
leaq 0xc8(%rsp), %rbp
movq $0x0, 0x20(%rsp)
movq %r14, 0x18(%rsp)
movq %rax, %r14
leaq 0x190(%rsp), %rdi
callq 0x6220
movl %eax, %r15d
testl %eax, %eax
je 0xa746
movl 0x190(%rsp), %eax
cmpl $0x300, %eax            # imm = 0x300
je 0xa6a9
cmpl $0x100, %eax            # imm = 0x100
jne 0xa677
jmp 0xaf4b
testb $-0x40, 0x1a8(%rsp)
je 0xa6d8
movl 0x1a4(%rsp), %eax
cmpl $0x65, %eax
je 0xa6c4
cmpl $0x64, %eax
jne 0xa677
movw $0x2274, 0x12159(%rip)  # imm = 0x2274
movw $0x37, 0x12152(%rip)    # 0x1c828
jmp 0xa677
movl 0x1a4(%rsp), %eax
leal -0x4000004a(%rax), %ecx
cmpl $0xe, %ecx
ja 0xa97c
movq 0xa8(%rsp), %rax
subq 0xa0(%rsp), %rax
shrq $0x5, %rax
leaq 0x8bab(%rip), %rdx      # 0x132b4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x0, 0x8(%rsp)
je 0xa9b4
movw $0x89d, 0x12100(%rip)   # imm = 0x89D
movw $0x1b8, 0x120f9(%rip)   # imm = 0x1B8
movq $0x0, 0x8(%rsp)
movq $0x0, 0x20(%rsp)
jmp 0xa677
movq 0xa0(%rsp), %rbx
movq 0xa8(%rsp), %r14
cmpq %rbx, %r14
je 0xa793
leaq 0x10(%rbx), %r12
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0xa775
movq (%r12), %rsi
incq %rsi
callq 0x6390
leaq 0x20(%r12), %rax
addq $0x10, %r12
cmpq %r14, %r12
movq %rax, %r12
jne 0xa75f
movq %rbx, 0xa8(%rsp)
leaq 0x58(%rsp), %r12
movq 0x170(%rsp), %rbx
movq 0x178(%rsp), %r14
cmpq %rbx, %r14
je 0xa7c4
movq %rbx, %r13
movq %r13, %rdi
callq 0xeeb0
addq $0x28, %r13
cmpq %r14, %r13
jne 0xa7ab
movq %rbx, 0x178(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x6210
movq 0x138(%rsp), %rax
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
movq 0x40(%rsp), %r14
je 0xa9d4
movq 0x117db(%rip), %rcx     # 0x1bfe0
cmpb $0x0, (%rcx)
je 0xa9ea
incl 0x8(%rdi)
movq %rax, 0x90(%rsp)
movq %rdi, 0x98(%rsp)
jmp 0xaa0e
movq 0x20(%rsp), %rcx
leal (%rcx,%r14), %edx
cmpl %eax, %edx
je 0xa993
movl %eax, %ecx
subl %r14d, %ecx
jle 0xa993
movw $0x89d, 0x11fdb(%rip)   # imm = 0x89D
movw $0x1b8, 0x11fd4(%rip)   # imm = 0x1B8
leal (%rdx,%r14), %esi
cmpl %eax, %esi
cmovlel %edx, %ecx
movq 0x8(%rsp), %rax
cmpl %ecx, %eax
cmovlel %ecx, %eax
movq %rax, 0x8(%rsp)
movl %ecx, %eax
movq %rax, 0x20(%rsp)
jmp 0xa677
cmpl $0x0, 0x20(%rsp)
je 0xa9a9
cmpl %r14d, %eax
jle 0xa9a9
movw $0x89d, 0x11f91(%rip)   # imm = 0x89D
movw $0x1b8, 0x11f8a(%rip)   # imm = 0x1B8
movq 0x20(%rsp), %rdx
subl %r14d, %edx
testl %edx, %edx
jg 0xa8ac
xorl %edx, %edx
leal (%rdx,%r14), %eax
movq 0x8(%rsp), %rcx
cmpl %eax, %ecx
movq %rdx, 0x20(%rsp)
leal -0x1(%rdx,%r14), %eax
cmovll %ecx, %eax
jmp 0xa972
movq 0x8(%rsp), %rax
testl %eax, %eax
je 0xa9b4
movw $0x89d, 0x11f47(%rip)   # imm = 0x89D
movw $0x1b8, 0x11f40(%rip)   # imm = 0x1B8
movq 0x20(%rsp), %rcx
cmpl %ecx, %eax
leal -0x1(%rax), %eax
cmovlel %eax, %ecx
jmp 0xa96d
movq 0x8(%rsp), %rcx
incl %ecx
movw $0x89d, 0x11f1f(%rip)   # imm = 0x89D
movw $0x1b8, 0x11f18(%rip)   # imm = 0x1B8
cmpl %eax, %ecx
je 0xa677
movl %eax, %ecx
subl %r14d, %ecx
movq %rcx, 0x20(%rsp)
testl %ecx, %ecx
jg 0xa92f
movq $0x0, 0x20(%rsp)
decl %eax
jmp 0xa99f
decl %eax
movq 0x8(%rsp), %rdx
cmpl %eax, %edx
je 0xa6c4
movw $0x89d, 0x11edb(%rip)   # imm = 0x89D
movw $0x1b8, 0x11ed4(%rip)   # imm = 0x1B8
leal 0x1(%rdx), %eax
movq 0x20(%rsp), %rsi
leal (%rsi,%r14), %ecx
subl %r14d, %edx
addl $0x2, %edx
cmpl %ecx, %eax
movl %edx, %ecx
cmovll %esi, %ecx
movq %rcx, 0x20(%rsp)
movq %rax, 0x8(%rsp)
jmp 0xa677
cmpl $0xd, %eax
je 0xb081
cmpl $0x1b, %eax
jne 0xa677
jmp 0xb0ec
decl %eax
cmpl %eax, 0x8(%rsp)
je 0xa6c4
movq %rax, 0x8(%rsp)
jmp 0xa677
cmpl $0x0, 0x8(%rsp)
jne 0xaf2b
movw $0x2274, 0x11e69(%rip)  # imm = 0x2274
movw $0x37, 0x11e62(%rip)    # 0x1c828
movq $0x0, 0x8(%rsp)
jmp 0xa677
movq %rax, 0x90(%rsp)
movq $0x0, 0x98(%rsp)
jmp 0xaa28
lock
incl 0x8(%rdi)
movq %rax, 0x90(%rsp)
movq %rdi, 0x98(%rsp)
movq 0x140(%rsp), %rax
movq %rax, %rdi
testq %rax, %rax
je 0xaa28
movq 0x115cb(%rip), %rax     # 0x1bfe0
cmpb $0x0, (%rax)
je 0xaa1f
incl 0x8(%rdi)
jmp 0xaa23
lock
incl 0x8(%rdi)
callq 0x10146
cmpq $0x0, 0x98(%rsp)
je 0xac78
leaq 0x90(%rsp), %rdi
callq 0x6580
movq %rax, %r13
movzbl 0x28(%rax), %eax
cmpl $0x3, %eax
je 0xaa54
testl %eax, %eax
jne 0xaa5c
movq %r13, %rdi
callq 0x6140
cmpb $0x1, %al
setne %cl
orb 0x14(%rsp), %cl
je 0xaa74
cmpb $0x1, %al
je 0xab9a
jmp 0xac66
movq %r13, %rdi
callq 0x6190
testq %rax, %rax
setne %cl
cmpq $-0x1, %rdx
setne %sil
andb %cl, %sil
cmpb $0x1, %sil
jne 0xaad3
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
movq $-0x1, %rcx
callq 0x63b0
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x2, %edx
callq 0x101b6
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xaadb
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6390
jmp 0xaadb
movq %rbp, %rdi
callq 0xf16a
movq 0xc8(%rsp), %rsi
leaq 0x1d8(%rsp), %rax
movq %rax, 0x1c8(%rsp)
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1c8(%rsp), %rdi
callq 0x10088
movq 0x1c8(%rsp), %rbp
movb $0x1, %bl
cmpq %r14, %rbp
je 0xab58
movb (%rbp), %al
movb (%r14), %r14b
movl %eax, %ecx
orb %r14b, %cl
je 0xab58
movl $0x1, %r12d
movsbl %al, %edi
callq 0x64a0
movsbl %r14b, %ecx
cmpl %ecx, %eax
sete %bl
jne 0xab58
movb (%rbp,%r12), %al
movq 0x40(%rsp), %rcx
movb (%rcx,%r12), %r14b
incq %r12
movl %r14d, %ecx
orb %al, %cl
jne 0xab2d
leaq 0x1d8(%rsp), %rax
cmpq %rax, %rbp
je 0xab78
movq 0x1d8(%rsp), %rsi
incq %rsi
movq %rbp, %rdi
callq 0x6390
leaq 0xc8(%rsp), %rbp
movq %rbp, %rdi
callq 0xeeb0
testb %bl, %bl
movq 0x40(%rsp), %r14
leaq 0x58(%rsp), %r12
je 0xac66
movq 0x8(%r13), %rcx
testq %rcx, %rcx
je 0xabfa
movq 0x20(%r13), %rax
movl %eax, %edx
notb %dl
movq %r13, %rsi
testb $0x3, %dl
je 0xabf0
movl %eax, %edx
andl $0x3, %edx
jne 0xabfa
movq (%r13), %rdx
cmpb $0x2f, -0x1(%rdx,%rcx)
je 0xabfa
movq %r13, %rsi
testb $0x3, %al
jne 0xabea
leaq 0x20(%r13), %rdi
callq 0x6240
movq %rax, %rsi
movq 0x20(%r13), %rax
addq $-0x30, %rsi
testb $0x3, %al
cmovneq %r13, %rsi
movq 0x20(%rsi), %rax
notl %eax
testb $0x3, %al
jne 0xabfa
movq %rbp, %rdi
callq 0x1025a
jmp 0xac02
movq %rbp, %rdi
callq 0xf16a
movq 0xc8(%rsp), %rsi
movq %r12, 0x48(%rsp)
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
callq 0x10088
leaq 0xa0(%rsp), %rdi
movq %rbx, %rsi
callq 0x1088e
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xac4e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6390
movq %rbp, %rdi
callq 0xeeb0
leaq 0x170(%rsp), %rdi
movq %r13, %rsi
callq 0xf21a
leaq 0x90(%rsp), %rdi
callq 0x6120
jmp 0xaa28
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0xac8a
callq 0x10146
movl $0x7, 0x48(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x4c(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0x74(%rsp), %eax
movl %eax, 0x54(%rsp)
movl $0x10, 0x1c8(%rsp)
leaq 0xbd94(%rip), %rdi      # 0x16a53
leaq 0x1c8(%rsp), %r12
movq %r12, %rsi
movl $0x17, %edx
movl $0x31, %ecx
movl $0xff, %r8d
movq 0x18(%rsp), %rbx
movq %rbx, %r9
callq 0x7d9f
movq 0x148(%rsp), %rsi
leaq 0xd8(%rsp), %r14
movq %r14, 0xc8(%rsp)
movq 0x150(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x10088
movq 0xc8(%rsp), %rdi
movq %r12, %rsi
movl $0x17, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
movq %rbx, %r9
callq 0x7d9f
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0xad4f
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x6390
movq %rbx, %rdi
leaq 0x48(%rsp), %rsi
movl $0xff, %edx
callq 0x6060
cmpl $0x4e, 0x1f8(%rsp)
jl 0xae8d
movslq 0x20(%rsp), %rbx
movslq 0x8(%rsp), %rax
movq %rax, 0x130(%rsp)
movq %rbx, %r12
shlq $0x5, %r12
movl 0xc0(%rsp), %r14d
movq 0x120(%rsp), %r13
movq 0xa0(%rsp), %rax
movq 0xa8(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rbx, %rcx
jbe 0xae8d
cmpq %rbx, 0x130(%rsp)
jne 0xae52
movl 0x48(%rsp), %eax
movl 0x50(%rsp), %ecx
movl %eax, 0xc8(%rsp)
leal -0x1(%r13), %eax
movl %eax, 0xcc(%rsp)
movl %ecx, 0xd0(%rsp)
movl $0x12, 0xd4(%rsp)
movq %rbp, %rsi
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movl $0x31, %edx
callq 0xb21f
movq 0xa0(%rsp), %rax
movq 0x130(%rsp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rdi
movl $0x10, 0x1c8(%rsp)
leaq 0x1c8(%rsp), %rsi
movl %r13d, %edx
movl $0xff, %ecx
movl $0x31, %r8d
movq %rbp, %r9
callq 0x7d9f
leaq 0xc8(%rsp), %rbp
jmp 0xae79
movq (%rax,%r12), %rdi
movl $0x10, 0xc8(%rsp)
movq %rbp, %rsi
movl %r13d, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
movq 0x18(%rsp), %r9
callq 0x7d9f
incq %rbx
addl $0x12, %r13d
addq $0x20, %r12
decl %r14d
jne 0xad98
movq 0xa8(%rsp), %rax
cmpq 0xa0(%rsp), %rax
movq 0x18(%rsp), %rbx
jne 0xaed3
movl $0x10, 0xc8(%rsp)
leaq 0xbba8(%rip), %rdi      # 0x16a5e
movq %rbp, %rsi
movl 0xbc(%rsp), %edx
movl $0x7, %ecx
movl $0xff, %r8d
movq %rbx, %r9
callq 0x7d9f
movq 0x68(%rsp), %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
leaq 0x78(%rsp), %rcx
callq 0x62e0
movq 0x128(%rsp), %r14
leaq 0x58(%rsp), %r12
movq %rbx, %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
leaq 0x78(%rsp), %rcx
callq 0x62e0
movq 0x8153d7(%rip), %rdi    # 0x8202e8
callq 0x63d0
movl $0x10, %edi
callq 0x6290
testl %r15d, %r15d
je 0xa677
jmp 0xaf5e
movw $0x89d, 0x118f2(%rip)   # imm = 0x89D
movw $0x1b8, 0x118eb(%rip)   # imm = 0x1B8
movq $0x0, 0x8(%rsp)
jmp 0xa677
leaq 0xc8(%rsp), %rdi
movl $0x100, (%rdi)          # imm = 0x100
callq 0x6540
movl $0x8, %ebp
movb $-0x27, %r14b
leaq 0x78(%rsp), %r15
leaq 0x1e8(%rsp), %r12
leaq 0x100(%rsp), %r13
movzbl %r14b, %esi
movq 0x18(%rsp), %rdi
callq 0x65b0
decl %ebp
movl 0x84(%rsp), %eax
movl %eax, %ecx
imull %ebp, %ecx
leal 0x7(%rcx), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
sarl $0x3, %edx
movl %edx, 0x10c(%rsp)
movl %edx, 0x1f4(%rsp)
subl %edx, %eax
movl %eax, 0x1ec(%rsp)
movl 0x88(%rsp), %eax
subl %edx, %eax
imull 0x2c(%rsp), %eax
sarl $0x3, %eax
movl %eax, 0x104(%rsp)
movq 0x68(%rsp), %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
movq %r15, %rcx
callq 0x62e0
movq 0x18(%rsp), %rdi
movq %r12, %rsi
movq 0x30(%rsp), %rdx
movq %r13, %rcx
callq 0x62e0
movq 0x8152e7(%rip), %rdi    # 0x8202e8
callq 0x63d0
movl $0x10, %edi
callq 0x6290
addb $-0x1f, %r14b
cmpl $0x1, %ebp
ja 0xaf7b
leaq 0x78(%rsp), %rcx
movq 0x68(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
callq 0x62e0
movq %rbx, %rdi
callq 0x6320
movq 0x18(%rsp), %rdi
callq 0x6320
leaq 0x170(%rsp), %rdi
callq 0xf246
leaq 0xa0(%rsp), %rdi
callq 0xf28e
leaq 0x148(%rsp), %rdi
callq 0xeeb0
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x8(%rsp), %rax
movq 0x170(%rsp), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %rsi
movq 0x8(%rcx,%rax,8), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
movq %r12, (%rdi)
callq 0x10088
leaq 0x48(%rsp), %r15
movq 0x118(%rsp), %rdi
movq %r15, %rsi
callq 0x6400
movq (%r15), %rdi
cmpq %r12, %rdi
je 0xb0d5
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6390
movw $0x89d, 0x11748(%rip)   # imm = 0x89D
movw $0x370, 0x11741(%rip)   # imm = 0x370
jmp 0xaf5e
movq 0x118(%rsp), %rax
movq $0x0, 0x8(%rax)
movq (%rax), %rax
movb $0x0, (%rax)
jmp 0xaf5e
jmp 0xb207
jmp 0xb207
jmp 0xb207
jmp 0xb1e8
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xeeb0
jmp 0xb20a
jmp 0xb207
jmp 0xb1e8
jmp 0xb207
jmp 0xb1e8
jmp 0xb1e8
jmp 0xb1e8
jmp 0xb1e8
jmp 0xb207
jmp 0xb207
jmp 0xb207
jmp 0xb207
jmp 0xb1e8
jmp 0xb1e8
jmp 0xb1bf
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xb1c2
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6390
jmp 0xb1c2
jmp 0xb1bf
jmp 0xb1a9
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xb1ac
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6390
jmp 0xb1ac
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xeeb0
jmp 0xb1c2
jmp 0xb1bf
jmp 0xb1e8
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0xb1d4
callq 0x10146
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0xb1eb
callq 0x10146
jmp 0xb1eb
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
callq 0xf246
leaq 0xa0(%rsp), %rdi
callq 0xf28e
jmp 0xb20a
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0xeeb0
movq %rbx, %rdi
callq 0x6550