// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movl %edx, %r10d
movl %esi, %r12d
leaq 0x5c20ef(%rip), %rax    # 0x5f3950
cmpl $0x0, (%rax)
je 0x3188a
movswl %cx, %ecx
movswl %r8w, %r8d
movsbl %r9b, %r9d
movl %r12d, %esi
movl %r10d, %edx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x51706
movl %r9d, 0x4c(%rsp)
movl 0xb8(%rsp), %eax
movl 0xb0(%rsp), %edx
movl 0xa0(%rsp), %r9d
xorl %r14d, %r14d
testl %r9d, %r9d
cmovlel %r14d, %r9d
movl 0xa8(%rsp), %esi
testl %esi, %esi
cmovlel %r14d, %esi
leaq 0x6b76d(%rip), %r11     # 0x9d030
movl (%r11), %ebx
leal -0x1(%rbx), %r11d
cmpl %edx, %ebx
cmovgl %edx, %r11d
leaq 0x6b75d(%rip), %rdx     # 0x9d034
movl (%rdx), %edx
leal -0x1(%rdx), %ebx
cmpl %eax, %edx
cmovgl %eax, %ebx
movq %rbx, 0x30(%rsp)
movb 0x98(%rsp), %bl
movl %r8d, 0x48(%rsp)
movswq %r8w, %r15
leaq 0x3d7723(%rip), %rax    # 0x409020
movswl (%rax,%r15,2), %ebp
leaq 0x3c8ed7(%rip), %rax    # 0x3fa7e0
movswl (%rax,%r15,2), %r13d
movl $0x0, %eax
testb $0x10, %bl
jne 0x31941
leaq 0x202141(%rip), %rax    # 0x233a60
movl (%rax,%r15,4), %eax
movl %eax, %edx
shrl $0x8, %edx
movsbl %dl, %edx
movl %ebp, %r14d
sarl %r14d
addl %edx, %r14d
shrl $0x10, %eax
movsbl %al, %edx
movl %r13d, %eax
sarl %eax
addl %edx, %eax
movq %r15, 0x40(%rsp)
movb 0x90(%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 0x3963d5(%rip), %r15    # 0x3c7d50
movswq (%r15,%rcx,2), %rcx
andl %edx, %eax
movswq (%r15,%rax,2), %r15
testb $0x2, %bl
movb %bl, 0xf(%rsp)
movl %r13d, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
movq %r15, 0x20(%rsp)
je 0x31b38
movl 0x3de2c7(%rip), %eax    # 0x40fc70
testb $0x8, %bl
jne 0x319fc
leal (%r11,%r9), %r15d
shll $0xf, %r15d
addl $0x10000, %r15d         # imm = 0x10000
addl $0xff600000, %edi       # imm = 0xFF600000
movslq %edi, %rcx
testl %eax, %eax
je 0x31a62
movl 0x2430c0(%rip), %eax    # 0x274a94
shll $0x10, %eax
movslq 0x3de29a(%rip), %rdx    # 0x40fc78
imulq $0xc8, %rdx, %rdi
cltq
imulq %rcx, %rax
cqto
idivq %rdi
leaq 0x3fdba9(%rip), %rcx    # 0x42f5a0
jmp 0x31a7e
testl %eax, %eax
je 0x31aad
movl 0x3cf5e5(%rip), %r13d   # 0x400ff0
movl %r13d, %ecx
shll $0x10, %ecx
movslq 0x3cf5d0(%rip), %rax    # 0x400fe8
movslq 0x3de259(%rip), %rdx    # 0x40fc78
imulq $0xc8, %rdx, %r15
movslq %ecx, %rcx
imulq %rcx, %rax
cqto
idivq %r15
movq %rax, 0x38(%rsp)
movl 0x3cf5af(%rip), %ebx    # 0x400fec
shll $0xf, %ebx
addl $0xff600000, %edi       # imm = 0xFF600000
movslq %edi, %rax
imulq %rcx, %rax
cqto
idivq %r15
leal (%rbx,%rax), %r15d
addl $0x8000, %r15d          # imm = 0x8000
jmp 0x31af5
movslq 0x6bdc7(%rip), %rax     # 0x9d830
imulq %rcx, %rax
movl $0x140, %ecx            # imm = 0x140
cqto
idivq %rcx
leaq 0x24301a(%rip), %rcx    # 0x274a98
addl %eax, %r15d
movslq (%rcx), %rax
movq 0x30(%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 0x31b20
movslq 0x3cf538(%rip), %rcx    # 0x400fec
movslq 0x3cf52d(%rip), %rax    # 0x400fe8
imulq %rcx, %rax
movl $0x140, %ebx            # imm = 0x140
cqto
idivq %rbx
movq %rax, 0x38(%rsp)
addl $0xff600000, %edi       # imm = 0xFF600000
movslq %edi, %rax
imulq %rcx, %rax
shll $0xf, %ecx
cqto
idivq %rbx
leal (%rcx,%rax), %r15d
addl $0x8000, %r15d          # imm = 0x8000
movl 0x3cf4fb(%rip), %r13d   # 0x400ff0
shll $0xf, %r13d
addl $0xff9c0000, %r12d      # imm = 0xFF9C0000
movslq %r12d, %rcx
movslq 0x38(%rsp), %rax
imulq %rax, %rcx
shrq $0x10, %rcx
leal (%rcx,%r13), %r12d
addl $0x8000, %r12d          # imm = 0x8000
movl 0x10(%rsp), %r13d
movslq %r10d, %r10
imulq %rax, %r10
shrq $0x10, %r10
movl %r15d, %edi
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %r15
movslq %r10d, %r10
movq %r10, %rdx
imulq %rcx, %rdx
shrq $0xe, %rdx
movq %r10, 0x50(%rsp)
imulq %r15, %r10
shrq $0xe, %r10
andl $0xa, %r8d
movl %edx, %ecx
movl %r10d, %eax
movl %r8d, 0x38(%rsp)
cmpl $0x8, %r8d
je 0x31b84
movslq 0x324d4a(%rip), %rbx    # 0x3568b8
movslq %edx, %rcx
imulq %rbx, %rcx
shrq $0x10, %rcx
movslq %r10d, %rax
imulq %rbx, %rax
shrq $0x10, %rax
movl %r14d, %ebx
imull %r10d, %ebx
movl 0x28(%rsp), %r15d
imull %edx, %r15d
addl %ebx, %r15d
subl %r15d, %r12d
movl %r12d, 0x57df5f(%rip)   # 0x5afb00
imull %ebp, %r10d
addl %r12d, %r10d
movl %r10d, 0x57df55(%rip)   # 0x5afb04
imull %r13d, %edx
leal (%r12,%rdx), %r15d
movl %r15d, 0x57df4e(%rip)   # 0x5afb0c
addl %r10d, %edx
movl %edx, 0x57df41(%rip)    # 0x5afb08
shll $0x10, %esi
cmpl %esi, %r12d
jge 0x31be1
cmpl %esi, %r10d
jge 0x31be1
cmpl %esi, %edx
jge 0x31be1
cmpl %esi, %r15d
jl 0x31ec7
movq 0x30(%rsp), %rbx
shll $0x10, %ebx
movq %rbx, %r8
cmpl %ebx, %r12d
jle 0x31c04
cmpl %r8d, %r10d
jle 0x31c04
cmpl %r8d, %edx
jle 0x31c04
cmpl %r8d, %r15d
jg 0x31ec7
imull %ecx, %r14d
movl 0x28(%rsp), %r10d
imull %eax, %r10d
subl %r14d, %r10d
addl %edi, %r10d
movl %r10d, 0x57df02(%rip)   # 0x5afb20
imull %ecx, %ebp
addl %r10d, %ebp
movl %ebp, 0x57defa(%rip)    # 0x5afb24
imull 0x10(%rsp), %eax
movl %r10d, %ecx
subl %eax, %ecx
movl %ecx, 0x57def2(%rip)    # 0x5afb2c
movl %ebp, %edx
subl %eax, %edx
movl %edx, 0x57dee4(%rip)    # 0x5afb28
shll $0x10, %r9d
movl %r10d, 0x28(%rsp)
cmpl %r9d, %r10d
jge 0x31c65
cmpl %r9d, %ebp
jge 0x31c65
cmpl %r9d, %edx
jge 0x31c65
cmpl %r9d, %ecx
jl 0x31ec7
shll $0x10, %r11d
cmpl %r11d, 0x28(%rsp)
jle 0x31c83
cmpl %r11d, %ebp
jle 0x31c83
cmpl %r11d, %edx
jle 0x31c83
cmpl %r11d, %ecx
jg 0x31ec7
addl $0x10000, %r11d         # imm = 0x10000
xorl %edi, %edi
movl 0x28(%rsp), %r10d
xorl %ecx, %ecx
movl %edi, %r15d
cmpl %r9d, %r10d
jl 0x31cc5
cmpl %r11d, %r10d
jg 0x31cc5
movslq %ecx, %rcx
leaq 0x57de96(%rip), %rax    # 0x5afb40
movl %r10d, (%rax,%rcx,4)
leaq 0x57de4b(%rip), %rax    # 0x5afb00
movl (%rax,%r15,4), %eax
leaq 0x57dea0(%rip), %rdx    # 0x5afb60
movl %eax, (%rdx,%rcx,4)
incl %ecx
incl %edi
andl $0x3, %edi
leaq 0x57de4f(%rip), %rax    # 0x5afb20
movl (%rax,%rdi,4), %r14d
movl %r14d, %r13d
subl %r10d, %r13d
testl %r13d, %r13d
movl %r9d, %edx
cmovlel %r11d, %edx
movl %edx, %eax
subl %r10d, %eax
movl %eax, %ebx
subl %r13d, %ebx
xorl %eax, %ebx
movslq %r13d, %rbp
jns 0x31d2e
movslq %ecx, %rcx
leaq 0x57de40(%rip), %rbx    # 0x5afb40
movl %edx, (%rbx,%rcx,4)
leaq 0x57ddf6(%rip), %rdx    # 0x5afb00
movslq (%rdx,%r15,4), %rbx
movslq (%rdx,%rdi,4), %rdx
subq %rbx, %rdx
cltq
imulq %rdx, %rax
cqto
idivq %rbp
addl %ebx, %eax
leaq 0x57de37(%rip), %rdx    # 0x5afb60
movl %eax, (%rdx,%rcx,4)
incl %ecx
testl %r13d, %r13d
movl %r11d, %edx
cmovlel %r9d, %edx
movl %edx, %eax
subl %r10d, %eax
movl %eax, %r10d
subl %r13d, %r10d
xorl %eax, %r10d
jns 0x31d82
movslq %ecx, %rcx
leaq 0x57ddee(%rip), %r10    # 0x5afb40
movl %edx, (%r10,%rcx,4)
leaq 0x57dda3(%rip), %rdx    # 0x5afb00
movslq (%rdx,%r15,4), %r10
movslq (%rdx,%rdi,4), %rdx
subq %r10, %rdx
cltq
imulq %rdx, %rax
cqto
idivq %rbp
addl %r10d, %eax
leaq 0x57dde3(%rip), %rdx    # 0x5afb60
movl %eax, (%rdx,%rcx,4)
incl %ecx
movl %r14d, %r10d
testq %rdi, %rdi
jne 0x31c93
cmpl $0x3, %ecx
jl 0x31ec7
addl $0x10000, %r8d          # imm = 0x10000
movl %ecx, %r10d
negq %r10
xorl %r9d, %r9d
pushq $0x1
popq %r11
leaq 0x57ddae(%rip), %rdi    # 0x5afb60
leaq 0x57dd87(%rip), %rcx    # 0x5afb40
movq %r10, %rax
addq %r11, %rax
movslq (%rdi), %r13
movl $0x0, %r15d
cmovneq %r11, %r15
cmpl %esi, %r13d
jl 0x31df4
cmpl %r8d, %r13d
jg 0x31df4
movslq %r9d, %r9
leaq 0x57dd20(%rip), %rax    # 0x5afb00
movl %r13d, (%rax,%r9,4)
movl (%rcx), %eax
leaq 0x57dd33(%rip), %rdx    # 0x5afb20
movl %eax, (%rdx,%r9,4)
incl %r9d
leaq 0x57dd65(%rip), %rax    # 0x5afb60
movslq (%rax,%r15,4), %rbp
subq %r13, %rbp
movl %r8d, %edx
testl %ebp, %ebp
jle 0x31e0b
movl %esi, %edx
movl %edx, %eax
subl %r13d, %eax
movl %eax, %ebx
subl %ebp, %ebx
xorl %eax, %ebx
jns 0x31e52
movslq %r9d, %r9
leaq 0x57dcde(%rip), %rbx    # 0x5afb00
movl %edx, (%rbx,%r9,4)
movslq (%rcx), %rbx
leaq 0x57dd10(%rip), %rdx    # 0x5afb40
movslq (%rdx,%r15,4), %rdx
subq %rbx, %rdx
cltq
imulq %rdx, %rax
cqto
idivq %rbp
addl %ebx, %eax
leaq 0x57dcd5(%rip), %rdx    # 0x5afb20
movl %eax, (%rdx,%r9,4)
incl %r9d
movl %esi, %edx
testl %ebp, %ebp
jle 0x31e5b
movl %r8d, %edx
movl %edx, %eax
subl %r13d, %eax
movl %eax, %ebx
subl %ebp, %ebx
xorl %eax, %ebx
jns 0x31ea5
movslq %r9d, %r9
leaq 0x57dc8e(%rip), %rbx    # 0x5afb00
movl %edx, (%rbx,%r9,4)
movslq (%rcx), %rbx
leaq 0x57dcc0(%rip), %rdx    # 0x5afb40
movslq (%rdx,%r15,4), %rdx
subq %rbx, %rdx
cltq
imulq %rdx, %rax
movslq %ebp, %r14
cqto
idivq %r14
addl %ebx, %eax
leaq 0x57dc82(%rip), %rdx    # 0x5afb20
movl %eax, (%rdx,%r9,4)
incl %r9d
addq $0x4, %rcx
addq $0x4, %rdi
leaq (%r10,%r11), %rax
incq %rax
incq %r11
cmpq $0x1, %rax
jne 0x31db9
cmpl $0x3, %r9d
jge 0x31ed6
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x57dc44(%rip), %ebp    # 0x5afb20
movl %r9d, %ecx
decq %rcx
xorl %eax, %eax
movl %ebp, %r13d
movl 0x48(%rsp), %ebx
movq %rcx, %r15
incq %rcx
testq %rcx, %rcx
jle 0x31fbd
leaq 0x57dc1f(%rip), %rcx    # 0x5afb20
movl (%rcx,%r15,4), %edi
movl %eax, %eax
movl %edi, %r10d
sarl $0x10, %r10d
cmpl %ebp, %edi
cmovll %edi, %ebp
movl (%rcx,%rax,4), %r14d
movl %r14d, %r11d
sarl $0x10, %r11d
cmpl %r13d, %edi
cmovgl %edi, %r13d
movl %r10d, %esi
subl %r11d, %esi
je 0x31fb1
leaq 0x57dbc8(%rip), %rcx    # 0x5afb00
movl (%rcx,%r15,4), %r8d
movl (%rcx,%rax,4), %r9d
movl %r9d, %eax
subl %r8d, %eax
movl %r14d, %ecx
subl %edi, %ecx
cltq
shlq $0x10, %rax
movslq %ecx, %rcx
cqto
idivq %rcx
movl %r11d, %edx
movslq %eax, %rcx
subl %r10d, %edx
jle 0x31f89
notl %edi
movzwl %di, %eax
imulq %rcx, %rax
shrq $0x10, %rax
addl %eax, %r8d
movslq %r10d, %rax
leaq 0x416ef2(%rip), %rsi    # 0x448e70
leaq (%rsi,%rax,2), %rdi
movl %edx, %esi
movl %r8d, %edx
jmp 0x31fac
notl %r14d
movzwl %r14w, %eax
imulq %rcx, %rax
shrq $0x10, %rax
addl %eax, %r9d
movslq %r11d, %rax
leaq 0x418ccb(%rip), %rdx    # 0x44ac70
leaq (%rdx,%rax,2), %rdi
movl %r9d, %edx
callq 0x4448f
leaq -0x1(%r15), %rcx
movq %r15, %rax
jmp 0x31eeb
movl %r13d, 0x30(%rsp)
movl %ebp, %r14d
leaq 0x360314(%rip), %r15    # 0x3922e0
movq 0x40(%rsp), %rax
cmpq $0x0, (%r15,%rax,8)
jne 0x31fe0
movswl %bx, %edi
callq 0x2cc4a
movswl %bx, %edi
callq 0x2cc16
movzbl 0x17(%rsp), %ecx
movl 0x4c(%rsp), %esi
movzbl %sil, %eax
xorl %edx, %edx
testb %sil, %sil
cmovlel %edx, %eax
movzbl %al, %eax
movswl 0x3db821(%rip), %esi    # 0x40d828
decl %esi
cmpl %esi, %eax
cmovll %eax, %esi
shll $0x8, %esi
movabsq $0x100000000, %rax      # imm = 0x100000000
xorl %edx, %edx
idivq 0x50(%rsp)
cltq
movq 0x20(%rsp), %r9
imulq %rax, %r9
shrq $0xe, %r9
movq 0x18(%rsp), %rdx
imulq %rax, %rdx
shrq $0xe, %rdx
cmpl $0x8, 0x38(%rsp)
movq %rdx, 0x18(%rsp)
jne 0x32058
movl %r9d, %r10d
negl %r10d
movslq %edx, %rbp
movl %edx, %r8d
jmp 0x3207a
movslq 0x3cef89(%rip), %r8     # 0x400fe8
movl %r9d, %eax
negl %eax
movslq %eax, %r10
imulq %r8, %r10
shrq $0x10, %r10
movslq %edx, %rbp
imulq %rbp, %r8
shrq $0x10, %r8
leaq 0x35fa5f(%rip), %rax    # 0x391ae0
movslq %esi, %rdi
movl %r14d, %edx
andl $0xffff0000, %edx       # imm = 0xFFFF0000
movl 0x28(%rsp), %esi
notl %esi
addl %edx, %esi
movl $0xffff, %edx           # imm = 0xFFFF
subl %r12d, %edx
movslq %esi, %rsi
movq %r8, 0x28(%rsp)
movslq %r8d, %r8
imulq %rsi, %r8
movslq %edx, %rdx
movq %r9, 0x20(%rsp)
movslq %r9d, %rbx
imulq %rdx, %rbx
addq %r8, %rbx
movslq %r10d, %r8
imulq %rsi, %r8
imulq %rdx, %rbp
addq %r8, %rbp
shrq $0x10, %rbp
movb 0xf(%rsp), %r12b
testb $0x4, %r12b
je 0x320f5
movq 0x18(%rsp), %rdx
negl %edx
movq %rdx, 0x18(%rsp)
negl %r10d
movl 0x10(%rsp), %edx
shll $0x10, %edx
notl %ebp
addl %edx, %ebp
movl 0x30(%rsp), %r13d
movq %r10, 0x30(%rsp)
shrq $0x10, %rbx
addq (%rax,%rcx,8), %rdi
movq 0x40(%rsp), %rax
movq (%r15,%rax,8), %rax
movq %rax, 0x40(%rsp)
sarl $0x10, %r14d
sarl $0x10, %r13d
testb $0x1, %r12b
jne 0x3213e
testb $0x40, %r12b
movq 0x18(%rsp), %rdx
jne 0x3215e
movq 0x20(%rsp), %rsi
movl 0x10(%rsp), %ecx
callq 0x646c6
jmp 0x32173
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x10(%rsp), %ecx
callq 0x6474e
testb $0x20, %r12b
jne 0x3216e
callq 0x641a7
jmp 0x32173
movq 0x20(%rsp), %rsi
movl 0x10(%rsp), %ecx
callq 0x64645
jmp 0x32173
callq 0x641af
movslq %r14d, %r12
movslq %r13d, %r9
leaq (%r12,%r12), %r14
xorl %r13d, %r13d
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %r8
movq %r9, %r15
cmpq %r9, %r12
jge 0x31ec7
leaq 0x416cd3(%rip), %rax    # 0x448e70
movzwl (%r14,%rax), %ecx
leaq 0x418ac7(%rip), %rax    # 0x44ac70
movzwl (%r14,%rax), %eax
testb $0x8, 0xf(%rsp)
jne 0x321dd
leaq 0x396db4(%rip), %rdx    # 0x3c8f70
movzwl (%r14,%rdx), %edx
cmpw %cx, %dx
cmovlel %ecx, %edx
leaq 0x398bb2(%rip), %rcx    # 0x3cad80
movzwl (%r14,%rcx), %esi
cmpw %ax, %si
cmovgel %eax, %esi
movl %edx, %ecx
movl %esi, %eax
addl %r8d, %ebx
addl %edi, %ebp
cmpw %ax, %cx
jge 0x322a1
movswl %cx, %ecx
movl %ecx, %edx
subl %r13d, %edx
cmpl $0x1, %edx
je 0x3220b
testl %edx, %edx
je 0x32228
cmpl $-0x1, %edx
jne 0x32215
subl 0x20(%rsp), %ebx
subl 0x18(%rsp), %ebp
jmp 0x32225
addl 0x20(%rsp), %ebx
addl 0x18(%rsp), %ebp
jmp 0x32225
movl %edx, %esi
imull 0x20(%rsp), %esi
addl %esi, %ebx
imull 0x18(%rsp), %edx
addl %edx, %ebp
movl %ecx, %r13d
movswl %ax, %edx
movslq %ecx, %rax
leaq 0x3dda6b(%rip), %rsi    # 0x40fca0
movslq (%rsi,%rax,4), %r8
leaq 0x144e70(%rip), %rax    # 0x1770b0
addq (%rax), %r8
addq %r12, %r8
movl %ebx, %edi
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %edi
movl %ebp, %esi
andl %eax, %esi
subl %ecx, %edx
incl %edx
movl %ebx, %eax
sarl $0x10, %eax
imull 0x10(%rsp), %eax
movl %ebp, %ecx
sarl $0x10, %ecx
addl %eax, %ecx
movslq %ecx, %rcx
addq 0x40(%rsp), %rcx
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x32283
testb $0x40, %al
jne 0x3228a
callq 0x646e0
jmp 0x3228f
callq 0x64768
jmp 0x3228f
callq 0x6465f
callq 0x9fd2
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %r8
movq %r15, %r9
incq %r12
addq $0x2, %r14
jmp 0x3218d