// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: dorotatesprite
static void dorotatesprite(int sx, int sy, int z, short a, short picnum, signed char dashade,
	unsigned char dapalnum, unsigned char dastat, int cx1, int cy1, int cx2, int cy2, int uniqid)
{
	int cosang, sinang, v, nextv, dax1, dax2, oy, bx, by;
	int x, y, x1, y1, x2, y2, gx1, gy1, iv;
	intptr_t i, p, bufplc, palookupoffs;
	int xsiz, ysiz, xoff, yoff, npoints, yplc, yinc, lx, rx;
	int xv, yv, xv2, yv2;

	//============================================================================= //POLYMOST BEGINS
#if USE_POLYMOST
	if (rendmode) { polymost_dorotatesprite(sx,sy,z,a,picnum,dashade,dapalnum,dastat,cx1,cy1,cx2,cy2,uniqid); return; }
#else
	(void)uniqid;
#endif
	//============================================================================= //POLYMOST ENDS

	if (cx1 < 0) cx1 = 0;
	if (cy1 < 0) cy1 = 0;
	if (cx2 > xres-1) cx2 = xres-1;
	if (cy2 > yres-1) cy2 = yres-1;

	xsiz = tilesizx[picnum]; ysiz = tilesizy[picnum];
	if (dastat&16) { xoff = 0; yoff = 0; }
	else
	{
		xoff = (int)((signed char)((picanm[picnum]>>8)&255))+(xsiz>>1);
		yoff = (int)((signed char)((picanm[picnum]>>16)&255))+(ysiz>>1);
	}

	if (dastat&4) yoff = ysiz-yoff;

	cosang = sintable[(a+512)&2047]; sinang = sintable[a&2047];

	if ((dastat&2) != 0)  //Auto window size scaling
	{
		if ((dastat&8) == 0)
		{
			if (widescreen) {
				x = ydimenscale;   //= scale(xdimen,yxaspect,320);
				sx = ((cx1+cx2+2)<<15)+scale(sx-(320<<15),ydimen<<16,200*pixelaspect);
			} else {
				x = xdimenscale;   //= scale(xdimen,yxaspect,320);
				sx = ((cx1+cx2+2)<<15)+scale(sx-(320<<15),xdimen,320);
			}
			sy = ((cy1+cy2+2)<<15)+mulscale16(sy-(200<<15),x);
		}
		else
		{
			  //If not clipping to startmosts, & auto-scaling on, as a
			  //hard-coded bonus, scale to full screen instead
			if (widescreen) {
				x = scale(ydim<<16,yxaspect,200*pixelaspect);
				sx = (xdim<<15)+32768+scale(sx-(320<<15),ydim<<16,200*pixelaspect);
			} else {
				x = scale(xdim,yxaspect,320);
				sx = (xdim<<15)+32768+scale(sx-(320<<15),xdim,320);
			}
			sy = (ydim<<15)+32768+mulscale16(sy-(200<<15),x);
		}
		z = mulscale16(z,x);
	}

	xv = mulscale14(cosang,z);
	yv = mulscale14(sinang,z);
	if (((dastat&2) != 0) || ((dastat&8) == 0)) //Don't aspect unscaled perms
	{
		xv2 = mulscale16(xv,xyaspect);
		yv2 = mulscale16(yv,xyaspect);
	}
	else
	{
		xv2 = xv;
		yv2 = yv;
	}

	nry1[0] = sy - (yv*xoff + xv*yoff);
	nry1[1] = nry1[0] + yv*xsiz;
	nry1[3] = nry1[0] + xv*ysiz;
	nry1[2] = nry1[1]+nry1[3]-nry1[0];
	i = (cy1<<16); if ((nry1[0]<i) && (nry1[1]<i) && (nry1[2]<i) && (nry1[3]<i)) return;
	i = (cy2<<16); if ((nry1[0]>i) && (nry1[1]>i) && (nry1[2]>i) && (nry1[3]>i)) return;

	nrx1[0] = sx - (xv2*xoff - yv2*yoff);
	nrx1[1] = nrx1[0] + xv2*xsiz;
	nrx1[3] = nrx1[0] - yv2*ysiz;
	nrx1[2] = nrx1[1]+nrx1[3]-nrx1[0];
	i = (cx1<<16); if ((nrx1[0]<i) && (nrx1[1]<i) && (nrx1[2]<i) && (nrx1[3]<i)) return;
	i = (cx2<<16); if ((nrx1[0]>i) && (nrx1[1]>i) && (nrx1[2]>i) && (nrx1[3]>i)) return;

	gx1 = nrx1[0]; gy1 = nry1[0];   //back up these before clipping

	if ((npoints = clippoly4(cx1<<16,cy1<<16,(cx2+1)<<16,(cy2+1)<<16)) < 3) return;

	lx = nrx1[0]; rx = nrx1[0];

	nextv = 0;
	for(v=npoints-1;v>=0;v--)
	{
		x1 = nrx1[v]; x2 = nrx1[nextv];
		dax1 = (x1>>16); if (x1 < lx) lx = x1;
		dax2 = (x2>>16); if (x1 > rx) rx = x1;
		if (dax1 != dax2)
		{
			y1 = nry1[v]; y2 = nry1[nextv];
			yinc = divscale16(y2-y1,x2-x1);
			if (dax2 > dax1)
			{
				yplc = y1 + mulscale16((dax1<<16)+65535-x1,yinc);
				qinterpolatedown16short(&uplc[dax1],dax2-dax1,yplc,yinc);
			}
			else
			{
				yplc = y2 + mulscale16((dax2<<16)+65535-x2,yinc);
				qinterpolatedown16short(&dplc[dax2],dax1-dax2,yplc,yinc);
			}
		}
		nextv = v;
	}

	if (waloff[picnum] == 0) loadtile(picnum);
	setgotpic(picnum);
	bufplc = waloff[picnum];

	palookupoffs = (intptr_t)palookup[dapalnum] + (getpalookup(0L,(int)dashade)<<8);

	iv = divscale32(1L,z);
	xv = mulscale14(sinang,iv);
	yv = mulscale14(cosang,iv);
	if (((dastat&2) != 0) || ((dastat&8) == 0)) //Don't aspect unscaled perms
	{
		yv2 = mulscale16(-xv,yxaspect);
		xv2 = mulscale16(yv,yxaspect);
	}
	else
	{
		yv2 = -xv;
		xv2 = yv;
	}

	x1 = (lx>>16); x2 = (rx>>16);

	oy = 0;
	x = (x1<<16)-1-gx1; y = (oy<<16)+65535-gy1;
	bx = dmulscale16(x,xv2,y,xv);
	by = dmulscale16(x,yv2,y,yv);
	if (dastat&4) { yv = -yv; yv2 = -yv2; by = (ysiz<<16)-1-by; }

#ifndef USING_A_C
	int ny1, ny2, xx, xend, qlinemode=0, y1ve[4], y2ve[4], u4, d4;
	char bad;

	if ((dastat&1) == 0)
	{
		if (((a&1023) == 0) && (ysiz <= 256))  //vlineasm4 has 256 high limit!
		{
			if (dastat&64) setupvlineasm(24L); else setupmvlineasm(24L);
			by <<= 8; yv <<= 8; yv2 <<= 8;

			palookupoffse[0] = palookupoffse[1] = palookupoffse[2] = palookupoffse[3] = palookupoffs;
			vince[0] = vince[1] = vince[2] = vince[3] = yv;

			for(x=x1;x<x2;x+=4)
			{
				bad = 15; xend = min(x2-x,4);
				for(xx=0;xx<xend;xx++)
				{
					bx += xv2;

					y1 = uplc[x+xx]; y2 = dplc[x+xx];
					if ((dastat&8) == 0)
					{
						if (startumost[x+xx] > y1) y1 = startumost[x+xx];
						if (startdmost[x+xx] < y2) y2 = startdmost[x+xx];
					}
					if (y2 <= y1) continue;

					by += yv*(y1-oy); oy = y1;

					bufplce[xx] = (bx>>16)*ysiz+bufplc;
					vplce[xx] = by;
					y1ve[xx] = y1;
					y2ve[xx] = y2-1;
					bad &= ~pow2char[xx];
				}

				p = x+frameplace;

				u4 = max(max(y1ve[0],y1ve[1]),max(y1ve[2],y1ve[3]));
				d4 = min(min(y2ve[0],y2ve[1]),min(y2ve[2],y2ve[3]));

				if (dastat&64)
				{
					if ((bad != 0) || (u4 >= d4))
					{
						if (!(bad&1)) prevlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-y1ve[0],vplce[0],(void *)bufplce[0],(void *)(ylookup[y1ve[0]]+p+0));
						if (!(bad&2)) prevlineasm1(vince[1],(void *)palookupoffse[1],y2ve[1]-y1ve[1],vplce[1],(void *)bufplce[1],(void *)(ylookup[y1ve[1]]+p+1));
						if (!(bad&4)) prevlineasm1(vince[2],(void *)palookupoffse[2],y2ve[2]-y1ve[2],vplce[2],(void *)bufplce[2],(void *)(ylookup[y1ve[2]]+p+2));
						if (!(bad&8)) prevlineasm1(vince[3],(void *)palookupoffse[3],y2ve[3]-y1ve[3],vplce[3],(void *)bufplce[3],(void *)(ylookup[y1ve[3]]+p+3));
						continue;
					}

					if (u4 > y1ve[0]) vplce[0] = prevlineasm1(vince[0],(void *)palookupoffse[0],u4-y1ve[0]-1,vplce[0],(void *)bufplce[0],(void *)(ylookup[y1ve[0]]+p+0));
					if (u4 > y1ve[1]) vplce[1] = prevlineasm1(vince[1],(void *)palookupoffse[1],u4-y1ve[1]-1,vplce[1],(void *)bufplce[1],(void *)(ylookup[y1ve[1]]+p+1));
					if (u4 > y1ve[2]) vplce[2] = prevlineasm1(vince[2],(void *)palookupoffse[2],u4-y1ve[2]-1,vplce[2],(void *)bufplce[2],(void *)(ylookup[y1ve[2]]+p+2));
					if (u4 > y1ve[3]) vplce[3] = prevlineasm1(vince[3],(void *)palookupoffse[3],u4-y1ve[3]-1,vplce[3],(void *)bufplce[3],(void *)(ylookup[y1ve[3]]+p+3));

					if (d4 >= u4) vlineasm4(d4-u4+1,(void *)(ylookup[u4]+p));

					i = p+ylookup[d4+1];
					if (y2ve[0] > d4) prevlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-d4-1,vplce[0],(void *)bufplce[0],(void *)(i+0));
					if (y2ve[1] > d4) prevlineasm1(vince[1],(void *)palookupoffse[1],y2ve[1]-d4-1,vplce[1],(void *)bufplce[1],(void *)(i+1));
					if (y2ve[2] > d4) prevlineasm1(vince[2],(void *)palookupoffse[2],y2ve[2]-d4-1,vplce[2],(void *)bufplce[2],(void *)(i+2));
					if (y2ve[3] > d4) prevlineasm1(vince[3],(void *)palookupoffse[3],y2ve[3]-d4-1,vplce[3],(void *)bufplce[3],(void *)(i+3));
				}
				else
				{
					if ((bad != 0) || (u4 >= d4))
					{
						if (!(bad&1)) mvlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-y1ve[0],vplce[0],(void *)bufplce[0],(void *)(ylookup[y1ve[0]]+p+0));
						if (!(bad&2)) mvlineasm1(vince[1],(void *)palookupoffse[1],y2ve[1]-y1ve[1],vplce[1],(void *)bufplce[1],(void *)(ylookup[y1ve[1]]+p+1));
						if (!(bad&4)) mvlineasm1(vince[2],(void *)palookupoffse[2],y2ve[2]-y1ve[2],vplce[2],(void *)bufplce[2],(void *)(ylookup[y1ve[2]]+p+2));
						if (!(bad&8)) mvlineasm1(vince[3],(void *)palookupoffse[3],y2ve[3]-y1ve[3],vplce[3],(void *)bufplce[3],(void *)(ylookup[y1ve[3]]+p+3));
						continue;
					}

					if (u4 > y1ve[0]) vplce[0] = mvlineasm1(vince[0],(void *)palookupoffse[0],u4-y1ve[0]-1,vplce[0],(void *)bufplce[0],(void *)(ylookup[y1ve[0]]+p+0));
					if (u4 > y1ve[1]) vplce[1] = mvlineasm1(vince[1],(void *)palookupoffse[1],u4-y1ve[1]-1,vplce[1],(void *)bufplce[1],(void *)(ylookup[y1ve[1]]+p+1));
					if (u4 > y1ve[2]) vplce[2] = mvlineasm1(vince[2],(void *)palookupoffse[2],u4-y1ve[2]-1,vplce[2],(void *)bufplce[2],(void *)(ylookup[y1ve[2]]+p+2));
					if (u4 > y1ve[3]) vplce[3] = mvlineasm1(vince[3],(void *)palookupoffse[3],u4-y1ve[3]-1,vplce[3],(void *)bufplce[3],(void *)(ylookup[y1ve[3]]+p+3));

					if (d4 >= u4) mvlineasm4(d4-u4+1,(void *)(ylookup[u4]+p));

					i = p+ylookup[d4+1];
					if (y2ve[0] > d4) mvlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-d4-1,vplce[0],(void *)bufplce[0],(void *)(i+0));
					if (y2ve[1] > d4) mvlineasm1(vince[1],(void *)palookupoffse[1],y2ve[1]-d4-1,vplce[1],(void *)bufplce[1],(void *)(i+1));
					if (y2ve[2] > d4) mvlineasm1(vince[2],(void *)palookupoffse[2],y2ve[2]-d4-1,vplce[2],(void *)bufplce[2],(void *)(i+2));
					if (y2ve[3] > d4) mvlineasm1(vince[3],(void *)palookupoffse[3],y2ve[3]-d4-1,vplce[3],(void *)bufplce[3],(void *)(i+3));
				}

				faketimerhandler();
			}
		}
		else
		{
			if (dastat&64)
			{
				if ((xv2&0x0000ffff) == 0)
				{
					qlinemode = 1;
					setupqrhlineasm4(0L,yv2<<16,(xv2>>16)*ysiz+(yv2>>16),(void *)palookupoffs,0L,0L);
				}
				else
				{
					qlinemode = 0;
					setuprhlineasm4(xv2<<16,yv2<<16,(xv2>>16)*ysiz+(yv2>>16),(void *)palookupoffs,ysiz,0L);
				}
			}
			else
				setuprmhlineasm4(xv2<<16,yv2<<16,(xv2>>16)*ysiz+(yv2>>16),(void *)palookupoffs,ysiz,0L);

			y1 = uplc[x1];
			if (((dastat&8) == 0) && (startumost[x1] > y1)) y1 = startumost[x1];
			y2 = y1;
			for(x=x1;x<x2;x++)
			{
				ny1 = uplc[x]-1; ny2 = dplc[x];
				if ((dastat&8) == 0)
				{
					if (startumost[x]-1 > ny1) ny1 = startumost[x]-1;
					if (startdmost[x] < ny2) ny2 = startdmost[x];
				}

				if (ny1 < ny2-1)
				{
					if (ny1 >= y2)
					{
						while (y1 < y2-1)
						{
							y1++; if ((y1&31) == 0) faketimerhandler();

								//x,y1
							bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1;
							if (dastat&64) {
								if (qlinemode) qrhlineasm4(x-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,0L    ,by<<16,(void *)(ylookup[y1]+x+frameplace));
								else rhlineasm4(x-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y1]+x+frameplace));
							} else rmhlineasm4(x-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y1]+x+frameplace));
						}
						y1 = ny1;
					}
					else
					{
						while (y1 < ny1)
						{
							y1++; if ((y1&31) == 0) faketimerhandler();

								//x,y1
							bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1;
							if (dastat&64) {
								if (qlinemode) qrhlineasm4(x-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,0L    ,by<<16,(void *)(ylookup[y1]+x+frameplace));
								else rhlineasm4(x-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y1]+x+frameplace));
							} else rmhlineasm4(x-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y1]+x+frameplace));
						}
						while (y1 > ny1) lastx[y1--] = x;
					}
					while (y2 > ny2)
					{
						y2--; if ((y2&31) == 0) faketimerhandler();

							//x,y2
						bx += xv*(y2-oy); by += yv*(y2-oy); oy = y2;
						if (dastat&64) {
							if (qlinemode) qrhlineasm4(x-lastx[y2],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,0L    ,by<<16,(void *)(ylookup[y2]+x+frameplace));
							else rhlineasm4(x-lastx[y2],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y2]+x+frameplace));
						} else rmhlineasm4(x-lastx[y2],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y2]+x+frameplace));
					}
					while (y2 < ny2) lastx[y2++] = x;
				}
				else
				{
					while (y1 < y2-1)
					{
						y1++; if ((y1&31) == 0) faketimerhandler();

							//x,y1
						bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1;
						if (dastat&64) {
							if (qlinemode) qrhlineasm4(x-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,0L    ,by<<16,(void *)(ylookup[y1]+x+frameplace));
							else rhlineasm4(x-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y1]+x+frameplace));
						} else rmhlineasm4(x-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y1]+x+frameplace));
					}
					if (x == x2-1) { bx += xv2; by += yv2; break; }
					y1 = uplc[x+1];
					if (((dastat&8) == 0) && (startumost[x+1] > y1)) y1 = startumost[x+1];
					y2 = y1;
				}
				bx += xv2; by += yv2;
			}
			while (y1 < y2-1)
			{
				y1++; if ((y1&31) == 0) faketimerhandler();

					//x2,y1
				bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1;
				if (dastat&64) {
					if (qlinemode) qrhlineasm4(x2-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,0L,by<<16,(void *)(ylookup[y1]+x2+frameplace));
					else rhlineasm4(x2-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y1]+x2+frameplace));
				} else rmhlineasm4(x2-lastx[y1],(void *)((bx>>16)*ysiz+(by>>16)+bufplc),0L,bx<<16,by<<16,(void *)(ylookup[y1]+x2+frameplace));
			}
		}
	}
	else
	{
		if ((dastat&1) == 0)
		{
			if (dastat&64)
				setupspritevline((void *)palookupoffs,(xv>>16)*ysiz,xv<<16,ysiz,yv,0L);
			else
				msetupspritevline((void *)palookupoffs,(xv>>16)*ysiz,xv<<16,ysiz,yv,0L);
		}
		else
		{
			tsetupspritevline((void *)palookupoffs,(xv>>16)*ysiz,xv<<16,ysiz,yv,0L);
			if (dastat&32) settransreverse(); else settransnormal();
		}
		for(x=x1;x<x2;x++)
		{
			bx += xv2; by += yv2;

			y1 = uplc[x]; y2 = dplc[x];
			if ((dastat&8) == 0)
			{
				if (startumost[x] > y1) y1 = startumost[x];
				if (startdmost[x] < y2) y2 = startdmost[x];
			}
			if (y2 <= y1) continue;

			switch(y1-oy)
			{
				case -1: bx -= xv; by -= yv; oy = y1; break;
				case 0: break;
				case 1: bx += xv; by += yv; oy = y1; break;
				default: bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; break;
			}

			p = ylookup[y1]+x+frameplace;

			if ((dastat&1) == 0)
			{
				if (dastat&64)
					spritevline(0L,by<<16,y2-y1+1,bx<<16,(void *)((bx>>16)*ysiz+(by>>16)+bufplc),(void *)p);
				else
					mspritevline(0L,by<<16,y2-y1+1,bx<<16,(void *)((bx>>16)*ysiz+(by>>16)+bufplc),(void *)p);
			}
			else
			{
				tspritevline(0L,by<<16,y2-y1+1,bx<<16,(void *)((bx>>16)*ysiz+(by>>16)+bufplc),(void *)p);
			}
			faketimerhandler();
		}
	}

#else	// USING_A_C

	if ((dastat&1) == 0)
	{
		if (dastat&64)
			setupspritevline((void *)palookupoffs,xv,yv,ysiz);
		else
			msetupspritevline((void *)palookupoffs,xv,yv,ysiz);
	}
	else
	{
		tsetupspritevline((void *)palookupoffs,xv,yv,ysiz);
		if (dastat&32) settransreverse(); else settransnormal();
	}
	for(x=x1;x<x2;x++)
	{
		bx += xv2; by += yv2;

		y1 = uplc[x]; y2 = dplc[x];
		if ((dastat&8) == 0)
		{
			if (startumost[x] > y1) y1 = startumost[x];
			if (startdmost[x] < y2) y2 = startdmost[x];
		}
		if (y2 <= y1) continue;

		switch(y1-oy)
		{
			case -1: bx -= xv; by -= yv; oy = y1; break;
			case 0: break;
			case 1: bx += xv; by += yv; oy = y1; break;
			default: bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; break;
		}

		p = ylookup[y1]+x+frameplace;

		if ((dastat&1) == 0)
		{
			if (dastat&64)
				spritevline(bx&65535,by&65535,y2-y1+1,(void *)((bx>>16)*ysiz+(by>>16)+bufplc),(void *)p);
			else
				mspritevline(bx&65535,by&65535,y2-y1+1,(void *)((bx>>16)*ysiz+(by>>16)+bufplc),(void *)p);
		}
		else
		{
			tspritevline(bx&65535,by&65535,y2-y1+1,(void *)((bx>>16)*ysiz+(by>>16)+bufplc),(void *)p);
			//transarea += (y2-y1);
		}
		faketimerhandler();
	}

#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edx, %r10d
movl %esi, %r12d
leaq 0x5c5abf(%rip), %rax    # 0x5fa950
cmpl $0x0, (%rax)
je 0x34eba
movswl %cx, %ecx
movswl %r8w, %r8d
movsbl %r9b, %r9d
movl %r12d, %esi
movl %r10d, %edx
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5b9f8
movl %r9d, 0x54(%rsp)
movl 0xc8(%rsp), %eax
movl 0xc0(%rsp), %edx
movl 0xb0(%rsp), %r9d
xorl %r15d, %r15d
testl %r9d, %r9d
cmovlel %r15d, %r9d
movl 0xb8(%rsp), %esi
testl %esi, %esi
cmovlel %r15d, %esi
leaq 0x6f13d(%rip), %r11     # 0xa4030
movl (%r11), %ebx
leal -0x1(%rbx), %r11d
cmpl %edx, %ebx
cmovgl %edx, %r11d
leaq 0x6f12d(%rip), %rdx     # 0xa4034
movl (%rdx), %edx
leal -0x1(%rdx), %ebx
cmpl %eax, %edx
cmovgl %eax, %ebx
movq %rbx, 0x40(%rsp)
movb 0xa8(%rsp), %bl
movl %r8d, 0x50(%rsp)
movswq %r8w, %r14
leaq 0x3db0f3(%rip), %rax    # 0x410020
movswl (%rax,%r14,2), %r8d
leaq 0x3cc8a7(%rip), %rax    # 0x4017e0
movswl (%rax,%r14,2), %r13d
movl $0x0, %eax
testb $0x10, %bl
jne 0x34f71
leaq 0x205b11(%rip), %rax    # 0x23aa60
movl (%rax,%r14,4), %eax
movl %eax, %edx
shrl $0x8, %edx
movsbl %dl, %edx
movl %r8d, %r15d
sarl %r15d
addl %edx, %r15d
shrl $0x10, %eax
movsbl %al, %edx
movl %r13d, %eax
sarl %eax
addl %edx, %eax
movl %r8d, 0x38(%rsp)
movq %r14, 0x58(%rsp)
movb 0xa0(%rsp), %dl
movb %dl, 0x17(%rsp)
movzbl %bl, %r8d
movl %r13d, %edx
subl %eax, %edx
testb $0x4, %bl
cmovel %eax, %edx
movl %edx, 0x28(%rsp)
movzwl %cx, %eax
leal 0x200(%rax), %ecx
movl $0x7ff, %edx            # imm = 0x7FF
andl %edx, %ecx
leaq 0x399da0(%rip), %r14    # 0x3ced50
movswq (%r14,%rcx,2), %rbp
andl %edx, %eax
movswq (%r14,%rax,2), %rcx
testb $0x2, %bl
movb %bl, 0xf(%rsp)
movl %r13d, 0x10(%rsp)
movq %rbp, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
je 0x3519a
movl 0x3e1c92(%rip), %eax    # 0x416c70
testb $0x8, %bl
jne 0x35031
leal (%r11,%r9), %r14d
shll $0xf, %r14d
addl $0x10000, %r14d         # imm = 0x10000
addl $0xff600000, %edi       # imm = 0xFF600000
movslq %edi, %rcx
testl %eax, %eax
je 0x3509a
movl 0x246a8b(%rip), %eax    # 0x27ba94
shll $0x10, %eax
movslq 0x3e1c65(%rip), %rdx    # 0x416c78
imulq $0xc8, %rdx, %rdi
cltq
imulq %rcx, %rax
cqto
idivq %rdi
leaq 0x401574(%rip), %rcx    # 0x4365a0
jmp 0x350ca
testl %eax, %eax
je 0x350fc
movl 0x3d2fb0(%rip), %r13d   # 0x407ff0
movl %r13d, %ecx
shll $0x10, %ecx
movslq 0x3d2f9b(%rip), %rax    # 0x407fe8
movslq 0x3e1c24(%rip), %rdx    # 0x416c78
imulq $0xc8, %rdx, %r14
movslq %ecx, %rbx
imulq %rbx, %rax
cqto
idivq %r14
movq %rax, %rcx
movl 0x3d2f7c(%rip), %ebp    # 0x407fec
shll $0xf, %ebp
addl $0xff600000, %edi       # imm = 0xFF600000
movslq %edi, %rax
imulq %rbx, %rax
cqto
idivq %r14
leal (%rax,%rbp), %r14d
addl $0x8000, %r14d          # imm = 0x8000
movq 0x18(%rsp), %rbp
jmp 0x3515e
movslq 0x6f78f(%rip), %rax     # 0xa4830
imulq %rcx, %rax
movabsq $0x6666666666666667, %rcx # imm = 0x6666666666666667
imulq %rcx
movq %rdx, %rax
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x7, %rax
addq %rcx, %rax
leaq 0x2469ce(%rip), %rcx    # 0x27ba98
addl %eax, %r14d
movslq (%rcx), %rax
movq 0x40(%rsp), %rcx
addl %esi, %ecx
shll $0xf, %ecx
addl $0xff9c0000, %r12d      # imm = 0xFF9C0000
movslq %r12d, %rdx
imulq %rax, %rdx
shrq $0x10, %rdx
leal (%rcx,%rdx), %r12d
addl $0x10000, %r12d         # imm = 0x10000
jmp 0x35187
movslq 0x3d2ee9(%rip), %rbx    # 0x407fec
movslq 0x3d2ede(%rip), %rax    # 0x407fe8
imulq %rbx, %rax
movabsq $0x6666666666666667, %r14 # imm = 0x6666666666666667
imulq %r14
movq %rdx, %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rcx
addq %rax, %rcx
addl $0xff600000, %edi       # imm = 0xFF600000
movslq %edi, %rax
imulq %rbx, %rax
imulq %r14
shll $0xf, %ebx
movq %rdx, %rax
shrq $0x3f, %rax
shrq $0x7, %rdx
addl %eax, %edx
leal (%rbx,%rdx), %r14d
addl $0x8000, %r14d          # imm = 0x8000
movl 0x3d2e92(%rip), %r13d   # 0x407ff0
shll $0xf, %r13d
addl $0xff9c0000, %r12d      # imm = 0xFF9C0000
movslq %r12d, %rdx
movslq %ecx, %rax
imulq %rax, %rdx
shrq $0x10, %rdx
leal (%rdx,%r13), %r12d
addl $0x8000, %r12d          # imm = 0x8000
movl 0x10(%rsp), %r13d
movslq %r10d, %r10
imulq %rax, %r10
shrq $0x10, %r10
movl %r14d, %edi
movq 0x20(%rsp), %rcx
movslq %r10d, %r10
movq %r10, %rdx
imulq %rbp, %rdx
shrq $0xe, %rdx
movq %r10, 0x60(%rsp)
imulq %rcx, %r10
shrq $0xe, %r10
andl $0xa, %r8d
movl %edx, %ecx
movl %r10d, %eax
movl %r8d, 0x4c(%rsp)
cmpl $0x8, %r8d
je 0x351e6
movslq 0x3286e8(%rip), %rbx    # 0x35d8b8
movslq %edx, %rcx
imulq %rbx, %rcx
shrq $0x10, %rcx
movslq %r10d, %rax
imulq %rbx, %rax
shrq $0x10, %rax
movl %r15d, %ebx
imull %r10d, %ebx
movl 0x28(%rsp), %ebp
imull %edx, %ebp
addl %ebx, %ebp
subl %ebp, %r12d
movl %r12d, 0x581900(%rip)   # 0x5b6b00
movl 0x38(%rsp), %ebp
imull %ebp, %r10d
addl %r12d, %r10d
movl %r10d, 0x5818f2(%rip)   # 0x5b6b04
imull %r13d, %edx
leal (%r12,%rdx), %r14d
movl %r14d, 0x5818eb(%rip)   # 0x5b6b0c
addl %r10d, %edx
movl %edx, 0x5818de(%rip)    # 0x5b6b08
shll $0x10, %esi
cmpl %esi, %r12d
jge 0x35244
cmpl %esi, %r10d
jge 0x35244
cmpl %esi, %edx
jge 0x35244
cmpl %esi, %r14d
jl 0x35948
movq 0x40(%rsp), %rbx
shll $0x10, %ebx
movq %rbx, %r8
cmpl %ebx, %r12d
jle 0x35267
cmpl %r8d, %r10d
jle 0x35267
cmpl %r8d, %edx
jle 0x35267
cmpl %r8d, %r14d
jg 0x35948
imull %ecx, %r15d
movl 0x28(%rsp), %r10d
imull %eax, %r10d
subl %r15d, %r10d
addl %edi, %r10d
movl %r10d, 0x58189f(%rip)   # 0x5b6b20
imull %ecx, %ebp
addl %r10d, %ebp
movl %ebp, 0x581897(%rip)    # 0x5b6b24
imull 0x10(%rsp), %eax
movl %r10d, %ecx
subl %eax, %ecx
movl %ecx, 0x58188f(%rip)    # 0x5b6b2c
movl %ebp, %edx
subl %eax, %edx
movl %edx, 0x581881(%rip)    # 0x5b6b28
shll $0x10, %r9d
movl %r10d, 0x28(%rsp)
cmpl %r9d, %r10d
jge 0x352c8
cmpl %r9d, %ebp
jge 0x352c8
cmpl %r9d, %edx
jge 0x352c8
cmpl %r9d, %ecx
jl 0x35948
shll $0x10, %r11d
cmpl %r11d, 0x28(%rsp)
jle 0x352e6
cmpl %r11d, %ebp
jle 0x352e6
cmpl %r11d, %edx
jle 0x352e6
cmpl %r11d, %ecx
jg 0x35948
addl $0x10000, %r11d         # imm = 0x10000
xorl %edi, %edi
leaq 0x58182a(%rip), %r15    # 0x5b6b20
movl 0x28(%rsp), %r10d
xorl %ecx, %ecx
movl %edi, %ebp
cmpl %r9d, %r10d
jl 0x3532d
cmpl %r11d, %r10d
jg 0x3532d
movslq %ecx, %rcx
leaq 0x58182d(%rip), %rax    # 0x5b6b40
movl %r10d, (%rax,%rcx,4)
leaq 0x5817e2(%rip), %rax    # 0x5b6b00
movl (%rax,%rbp,4), %eax
leaq 0x581838(%rip), %rdx    # 0x5b6b60
movl %eax, (%rdx,%rcx,4)
incl %ecx
incl %edi
andl $0x3, %edi
movl (%r15,%rdi,4), %r13d
movl %r13d, %r14d
subl %r10d, %r14d
testl %r14d, %r14d
movl %r9d, %edx
cmovlel %r11d, %edx
movl %edx, %eax
subl %r10d, %eax
movl %eax, %ebx
subl %r14d, %ebx
xorl %eax, %ebx
jns 0x35396
movslq %ecx, %rcx
leaq 0x5817e2(%rip), %rbx    # 0x5b6b40
movl %edx, (%rbx,%rcx,4)
leaq 0x581798(%rip), %rdx    # 0x5b6b00
movslq (%rdx,%rbp,4), %rbx
movslq (%rdx,%rdi,4), %rdx
subq %rbx, %rdx
cltq
imulq %rdx, %rax
movslq %r14d, %r15
cqto
idivq %r15
leaq 0x581798(%rip), %r15    # 0x5b6b20
addl %ebx, %eax
leaq 0x5817cf(%rip), %rdx    # 0x5b6b60
movl %eax, (%rdx,%rcx,4)
incl %ecx
testl %r14d, %r14d
movl %r11d, %edx
cmovlel %r9d, %edx
movl %edx, %eax
subl %r10d, %eax
movl %eax, %r10d
subl %r14d, %r10d
xorl %eax, %r10d
jns 0x353ed
movslq %ecx, %rcx
leaq 0x581786(%rip), %r10    # 0x5b6b40
movl %edx, (%r10,%rcx,4)
leaq 0x58173b(%rip), %rdx    # 0x5b6b00
movslq (%rdx,%rbp,4), %r10
movslq (%rdx,%rdi,4), %rdx
subq %r10, %rdx
cltq
imulq %rdx, %rax
movslq %r14d, %rbx
cqto
idivq %rbx
addl %r10d, %eax
leaq 0x581778(%rip), %rdx    # 0x5b6b60
movl %eax, (%rdx,%rcx,4)
incl %ecx
movl %r13d, %r10d
testq %rdi, %rdi
jne 0x352fd
cmpl $0x3, %ecx
jl 0x35948
addl $0x10000, %r8d          # imm = 0x10000
movl %ecx, %r10d
negq %r10
xorl %r9d, %r9d
movl $0x1, %r11d
leaq 0x581741(%rip), %rdi    # 0x5b6b60
leaq 0x58171a(%rip), %rcx    # 0x5b6b40
movq %r10, %rax
addq %r11, %rax
movslq (%rdi), %r13
movl $0x0, %ebp
cmovneq %r11, %rbp
cmpl %esi, %r13d
jl 0x35459
cmpl %r8d, %r13d
jg 0x35459
movslq %r9d, %r9
leaq 0x5816b4(%rip), %rax    # 0x5b6b00
movl %r13d, (%rax,%r9,4)
movl (%rcx), %eax
movl %eax, (%r15,%r9,4)
incl %r9d
leaq 0x581700(%rip), %rax    # 0x5b6b60
movslq (%rax,%rbp,4), %r14
subq %r13, %r14
movl %r8d, %edx
testl %r14d, %r14d
jle 0x35471
movl %esi, %edx
movl %edx, %eax
subl %r13d, %eax
movl %eax, %ebx
subl %r14d, %ebx
xorl %eax, %ebx
jns 0x354b2
movslq %r9d, %r9
leaq 0x581677(%rip), %rbx    # 0x5b6b00
movl %edx, (%rbx,%r9,4)
movslq (%rcx), %rbx
leaq 0x5816a9(%rip), %rdx    # 0x5b6b40
movslq (%rdx,%rbp,4), %rdx
subq %rbx, %rdx
cltq
imulq %rdx, %rax
cqto
idivq %r14
addl %ebx, %eax
movl %eax, (%r15,%r9,4)
incl %r9d
movl %esi, %edx
testl %r14d, %r14d
jle 0x354bc
movl %r8d, %edx
movl %edx, %eax
subl %r13d, %eax
movl %eax, %ebx
subl %r14d, %ebx
xorl %eax, %ebx
jns 0x35500
movslq %r9d, %r9
leaq 0x58162c(%rip), %rbx    # 0x5b6b00
movl %edx, (%rbx,%r9,4)
movslq (%rcx), %rbx
leaq 0x58165e(%rip), %rdx    # 0x5b6b40
movslq (%rdx,%rbp,4), %rdx
subq %rbx, %rdx
cltq
imulq %rdx, %rax
movslq %r14d, %r14
cqto
idivq %r14
addl %ebx, %eax
movl %eax, (%r15,%r9,4)
incl %r9d
addq $0x4, %rcx
addq $0x4, %rdi
leaq (%r10,%r11), %rax
incq %rax
incq %r11
cmpq $0x1, %rax
jne 0x35426
cmpl $0x3, %r9d
jl 0x35948
movl 0x5815f4(%rip), %ebp    # 0x5b6b20
movl %r9d, %eax
decq %rax
xorl %r14d, %r14d
movl %ebp, %ebx
movl 0x4c(%rsp), %r8d
movl %r8d, %r15d
movl %r14d, %ecx
movq %rax, %r14
leaq 0x5815d4(%rip), %rax    # 0x5b6b20
movl (%rax,%r14,4), %r10d
movl %r10d, %edi
sarl $0x10, %edi
cmpl %ebx, %r10d
cmovll %r10d, %ebx
movl (%rax,%rcx,4), %r13d
movl %r13d, %r11d
sarl $0x10, %r11d
cmpl %ebp, %r10d
cmovgl %r10d, %ebp
movl %edi, %esi
subl %r11d, %esi
je 0x355ff
leaq 0x58157f(%rip), %rax    # 0x5b6b00
movl (%rax,%r14,4), %r8d
movl (%rax,%rcx,4), %r9d
movl %r9d, %eax
subl %r8d, %eax
movl %r13d, %ecx
subl %r10d, %ecx
cltq
shlq $0x10, %rax
movslq %ecx, %rcx
cqto
idivq %rcx
movl %r11d, %edx
movslq %eax, %rcx
subl %edi, %edx
jle 0x355d4
notl %r10d
movzwl %r10w, %eax
imulq %rcx, %rax
shrq $0x10, %rax
addl %eax, %r8d
movslq %edi, %rax
leaq 0x41a8a7(%rip), %rsi    # 0x44fe70
leaq (%rsi,%rax,2), %rdi
movl %edx, %esi
movl %r8d, %edx
jmp 0x355f7
notl %r13d
movzwl %r13w, %eax
imulq %rcx, %rax
shrq $0x10, %rax
addl %eax, %r9d
movslq %r11d, %rax
leaq 0x41c680(%rip), %rdx    # 0x451c70
leaq (%rdx,%rax,2), %rdi
movl %r9d, %edx
callq 0x4d1a2
movl %r15d, %r8d
leaq -0x1(%r14), %rax
leaq 0x1(%r14), %rcx
cmpq $0x1, %rcx
ja 0x3553f
movl %ebx, 0x34(%rsp)
leaq 0x363cc4(%rip), %r10    # 0x3992e0
movq 0x58(%rsp), %rbx
cmpq $0x0, (%r10,%rbx,8)
movl 0x50(%rsp), %r14d
jne 0x3563f
movswl %r14w, %edi
movq %r10, %r13
callq 0x2fc7e
movq %r13, %r10
movl %r15d, %r8d
movswl %r14w, %eax
leaq 0x3f90f6(%rip), %rcx    # 0x42e740
cmpb $-0x39, (%rbx,%rcx)
movq 0x20(%rsp), %rdi
ja 0x35659
movb $-0x39, (%rbx,%rcx)
movl %eax, %ecx
andl $0x7, %ecx
leaq 0x6f13b(%rip), %rdx     # 0xa47a0
movb (%rcx,%rdx), %cl
sarl $0x3, %eax
cltq
leaq 0x3f8c3c(%rip), %rdx    # 0x42e2b0
orb %cl, (%rax,%rdx)
movzbl 0x17(%rsp), %ecx
movl 0x54(%rsp), %esi
movzbl %sil, %eax
xorl %edx, %edx
testb %sil, %sil
cmovlel %edx, %eax
movzbl %al, %eax
movswl 0x3df192(%rip), %esi    # 0x414828
decl %esi
cmpl %esi, %eax
cmovll %eax, %esi
shll $0x8, %esi
movabsq $0x100000000, %rax      # imm = 0x100000000
xorl %edx, %edx
idivq 0x60(%rsp)
cltq
imulq %rax, %rdi
shrq $0xe, %rdi
movq 0x18(%rsp), %rdx
imulq %rax, %rdx
shrq $0xe, %rdx
cmpl $0x8, %r8d
movb 0xf(%rsp), %r15b
movq %rdx, 0x18(%rsp)
movq %rdi, 0x20(%rsp)
jne 0x356ed
movl %edi, %r8d
negl %r8d
movslq %edx, %r13
movq %rdx, 0x38(%rsp)
jmp 0x35713
movslq 0x3d28f4(%rip), %r9     # 0x407fe8
movl %edi, %eax
negl %eax
movslq %eax, %r8
imulq %r9, %r8
shrq $0x10, %r8
movslq %edx, %r13
imulq %r13, %r9
shrq $0x10, %r9
movq %r9, 0x38(%rsp)
movl 0x34(%rsp), %edx
leaq 0x3633c2(%rip), %rax    # 0x398ae0
movslq %esi, %rdi
andl $0xffff0000, %edx       # imm = 0xFFFF0000
movl 0x28(%rsp), %esi
notl %esi
addl %edx, %esi
movl $0xffff, %edx           # imm = 0xFFFF
subl %r12d, %edx
movslq %esi, %r14
movslq %edx, %rbx
movslq %r8d, %rdx
imulq %r14, %rdx
imulq %rbx, %r13
addq %rdx, %r13
shrq $0x10, %r13
testb $0x4, %r15b
je 0x35771
movq 0x18(%rsp), %rdx
negl %edx
movq %rdx, 0x18(%rsp)
negl %r8d
movl 0x10(%rsp), %edx
shll $0x10, %edx
notl %r13d
addl %edx, %r13d
movq %r8, 0x28(%rsp)
addq (%rax,%rcx,8), %rdi
movq 0x58(%rsp), %rax
movq (%r10,%rax,8), %rax
movq %rax, 0x40(%rsp)
sarl $0x10, 0x34(%rsp)
sarl $0x10, %ebp
testb $0x1, %r15b
jne 0x357b1
testb $0x40, %r15b
jne 0x357d1
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x10(%rsp), %ecx
callq 0x6fff1
jmp 0x357eb
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x10(%rsp), %ecx
callq 0x7007e
testb $0x20, %r15b
jne 0x357e6
callq 0x6fa57
jmp 0x357eb
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x10(%rsp), %ecx
callq 0x6ff6b
jmp 0x357eb
callq 0x6fa5f
movl 0x34(%rsp), %edx
cmpl %ebp, %edx
movq 0x28(%rsp), %rdi
jge 0x35948
movl %ebp, %ecx
movslq 0x38(%rsp), %rax
movslq 0x20(%rsp), %r12
imulq %r14, %rax
imulq %rbx, %r12
addq %rax, %r12
shrq $0x10, %r12
movslq %edx, %rbp
movslq %ecx, %rbx
leaq (,%rbp,2), %r15
xorl %r14d, %r14d
leaq 0x41a641(%rip), %rax    # 0x44fe70
movzwl (%r15,%rax), %ecx
leaq 0x41c435(%rip), %rax    # 0x451c70
movzwl (%r15,%rax), %eax
testb $0x8, 0xf(%rsp)
jne 0x3586f
leaq 0x39a722(%rip), %rdx    # 0x3cff70
movzwl (%r15,%rdx), %edx
cmpw %cx, %dx
cmovlel %ecx, %edx
leaq 0x39c520(%rip), %rcx    # 0x3d1d80
movzwl (%r15,%rcx), %esi
cmpw %ax, %si
cmovgel %eax, %esi
movl %edx, %ecx
movl %esi, %eax
addl 0x38(%rsp), %r12d
addl %edi, %r13d
cmpw %ax, %cx
jge 0x35938
movswl %cx, %ecx
movl %ecx, %edx
subl %r14d, %edx
cmpl $0x1, %edx
je 0x358a2
testl %edx, %edx
je 0x358c3
cmpl $-0x1, %edx
jne 0x358ae
subl 0x20(%rsp), %r12d
subl 0x18(%rsp), %r13d
jmp 0x358c0
addl 0x20(%rsp), %r12d
addl 0x18(%rsp), %r13d
jmp 0x358c0
movl %edx, %esi
imull 0x20(%rsp), %esi
addl %esi, %r12d
imull 0x18(%rsp), %edx
addl %edx, %r13d
movl %ecx, %r14d
movswl %ax, %edx
movslq %ecx, %rax
leaq 0x3e13d0(%rip), %rsi    # 0x416ca0
movslq (%rsi,%rax,4), %r8
leaq 0x1487d5(%rip), %rax    # 0x17e0b0
addq (%rax), %r8
addq %rbp, %r8
movl %r12d, %edi
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %edi
movl %r13d, %esi
andl %eax, %esi
subl %ecx, %edx
incl %edx
movl %r12d, %eax
sarl $0x10, %eax
imull 0x10(%rsp), %eax
movl %r13d, %ecx
sarl $0x10, %ecx
addl %eax, %ecx
movslq %ecx, %rcx
addq 0x40(%rsp), %rcx
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x35922
testb $0x40, %al
jne 0x35929
callq 0x7000b
jmp 0x3592e
callq 0x70098
jmp 0x3592e
callq 0x6ff85
callq 0xacd7
movq 0x28(%rsp), %rdi
incq %rbp
addq $0x2, %r15
cmpq %rbp, %rbx
jne 0x35828
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq