// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/jfbuild/src/polymost.c
// Function: polymost_drawrooms
void polymost_drawrooms (void)
{
	int i, j, n, n2, closest;
	double ox, oy, oz, ox2, oy2, oz2, r, px[6], py[6], pz[6], px2[6], py2[6], pz2[6], sx[6], sy[6];
	static unsigned char tempbuf[MAXWALLS];

	if (!rendmode) return;

	frameoffset = frameplace + windowy1*bytesperline + windowx1;

#if USE_OPENGL
	if (rendmode == 3)
	{
		resizeglcheck();

		//glfunc.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
		glfunc.glEnable(GL_DEPTH_TEST);
		glfunc.glDepthFunc(GL_ALWAYS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS

		//glfunc.glPolygonOffset(1,1); //Supposed to make sprites pasted on walls or floors not disappear
#if (USE_OPENGL == USE_GLES2)
		glfunc.glDepthRangef(0.00001f,1.f); //<- this is more widely supported than glPolygonOffset
#else
		glfunc.glDepthRange(0.00001,1.0); //<- this is more widely supported than glPolygonOffset
#endif

		 //Enable this for OpenGL red-blue glasses mode :)
		if (glredbluemode)
		{
			static int grbfcnt = 0; grbfcnt++;
			if (redblueclearcnt < numpages) { redblueclearcnt++; glfunc.glColorMask(1,1,1,1); glfunc.glClear(GL_COLOR_BUFFER_BIT); }
			if (grbfcnt&1)
			{
				glfunc.glViewport(windowx1-16,yres-(windowy2+1),windowx2-(windowx1-16)+1,windowy2-windowy1+1);
				glfunc.glColorMask(1,0,0,1);
				globalposx += singlobalang/1024;
				globalposy -= cosglobalang/1024;
			}
			else
			{
				glfunc.glViewport(windowx1,yres-(windowy2+1),windowx2+16-windowx1+1,windowy2-windowy1+1);
				glfunc.glColorMask(0,1,1,1);
				globalposx -= singlobalang/1024;
				globalposy += cosglobalang/1024;
			}
		}
	}
#endif

		//Polymost supports true look up/down :) Here, we convert horizon to angle.
		//gchang&gshang are cos&sin of this angle (respectively)
	gyxscale = ((double)xdimenscale)/131072.0;
	gxyaspect = ((double)xyaspect*(double)viewingrange)*(5.0/(65536.0*262144.0));
	gviewxrange = ((double)viewingrange)*((double)xdimen)/(32768.0*1024.0);
	gcosang = ((double)cosglobalang)/262144.0;
	gsinang = ((double)singlobalang)/262144.0;
	gcosang2 = gcosang*((double)viewingrange)/65536.0;
	gsinang2 = gsinang*((double)viewingrange)/65536.0;
	ghalfx = (double)halfxdimen; grhalfxdown10 = 1.0/(((double)ghalfx)*1024);
	ghoriz = (double)globalhoriz;

	gvisibility = ((float)globalvisibility)*gxyaspect*FOGSCALE;

		//global cos/sin height angle
	r = (double)((ydimen>>1)-ghoriz);
	gshang = r/sqrt(r*r+ghalfx*ghalfx);
	gchang = sqrt(1.0-gshang*gshang);
	ghoriz = (double)(ydimen>>1);

	  //global cos/sin tilt angle
	gctang = cos(gtang);
	gstang = sin(gtang);
	if (fabs(gstang) < .001) //This hack avoids nasty precision bugs in domost()
		{ gstang = 0; if (gctang > 0) gctang = 1.0; else gctang = -1.0; }

	if (inpreparemirror)
		gstang = -gstang;

		//Generate viewport trapezoid (for handling screen up/down)
	px[0] = px[3] = 0-1; px[1] = px[2] = windowx2+1-windowx1+2;
	py[0] = py[1] = 0-1; py[2] = py[3] = windowy2+1-windowy1+2; n = 4;
	for(i=0;i<n;i++)
	{
		ox = px[i]-ghalfx; oy = py[i]-ghoriz; oz = ghalfx;

			//Tilt rotation (backwards)
		ox2 = ox*gctang + oy*gstang;
		oy2 = oy*gctang - ox*gstang;
		oz2 = oz;

			//Up/down rotation (backwards)
		px[i] = ox2;
		py[i] = oy2*gchang + oz2*gshang;
		pz[i] = oz2*gchang - oy2*gshang;
	}

		//Clip to SCISDIST plane
	n2 = 0;
	for(i=0;i<n;i++)
	{
		j = i+1; if (j >= n) j = 0;
		if (pz[i] >= SCISDIST) { px2[n2] = px[i]; py2[n2] = py[i]; pz2[n2] = pz[i]; n2++; }
		if ((pz[i] >= SCISDIST) != (pz[j] >= SCISDIST))
		{
			r = (SCISDIST-pz[i])/(pz[j]-pz[i]);
			px2[n2] = (px[j]-px[i])*r + px[i];
			py2[n2] = (py[j]-py[i])*r + py[i];
			pz2[n2] = SCISDIST; n2++;
		}
	}
	if (n2 < 3) return;
	for(i=0;i<n2;i++)
	{
		r = ghalfx / pz2[i];
		sx[i] = px2[i]*r + ghalfx;
		sy[i] = py2[i]*r + ghoriz;
	}
	initmosts(sx,sy,n2);

	if (searchit == 2)
	{
		short hitsect, hitwall, hitsprite;
		int vx, vy, vz, hitx, hity, hitz;

		ox2 = searchx-ghalfx; oy2 = searchy-ghoriz; oz2 = ghalfx;

			//Tilt rotation
		ox = ox2*gctang + oy2*gstang;
		oy = oy2*gctang - ox2*gstang;
		oz = oz2;

			//Up/down rotation
		ox2 = oz*gchang - oy*gshang;
		oy2 = ox;
		oz2 = oy*gchang + oz*gshang;

			//Standard Left/right rotation
		vx = (int)(ox2*((float)cosglobalang) - oy2*((float)singlobalang));
		vy = (int)(ox2*((float)singlobalang) + oy2*((float)cosglobalang));
		vz = (int)(oz2*16384.0);

		hitallsprites = 1;
		hitscan(globalposx,globalposy,globalposz,globalcursectnum, //Start position
			vx>>12,vy>>12,vz>>8,&hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,0xffff0030);
		hitallsprites = 0;

		searchsector = hitsect;
		if (hitwall >= 0)
		{
			searchwall = hitwall; searchstat = 0;
			if (wall[hitwall].nextwall >= 0)
			{
				int cz, fz;
				getzsofslope(wall[hitwall].nextsector,hitx,hity,&cz,&fz);
				if (hitz > fz)
				{
					if (wall[hitwall].cstat&2) //'2' bottoms of walls
						searchwall = wall[hitwall].nextwall;
				}
				else if ((hitz > cz) && (wall[hitwall].cstat&(16+32))) //masking or 1-way
					searchstat = 4;
			}
		}
		else if (hitsprite >= 0) { searchwall = hitsprite; searchstat = 3; }
		else
		{
			int cz, fz;
			getzsofslope(hitsect,hitx,hity,&cz,&fz);
			if ((hitz<<1) < cz+fz) searchstat = 1; else searchstat = 2;
			//if (vz < 0) searchstat = 1; else searchstat = 2; //Won't work for slopes :/
		}
		searchit = 0;
	}

	numscans = numbunches = 0;

	if (globalcursectnum >= MAXSECTORS)
		globalcursectnum -= MAXSECTORS;
	else
	{
		i = globalcursectnum;
		updatesector(globalposx,globalposy,&globalcursectnum);
		if (globalcursectnum < 0) globalcursectnum = i;
	}

	polymost_scansector(globalcursectnum);

	if (inpreparemirror)
	{
		grhalfxdown10x = -grhalfxdown10;
		inpreparemirror = 0;
		polymost_drawalls(0);
		numbunches--;
		bunchfirst[0] = bunchfirst[numbunches];
		bunchlast[0] = bunchlast[numbunches];
	}
	else
		grhalfxdown10x = grhalfxdown10;

	while (numbunches > 0)
	{
		memset(tempbuf,0,numbunches+3); tempbuf[0] = 1;

		closest = 0;              //Almost works, but not quite :(
		for(i=1;i<numbunches;i++)
		{
			j = polymost_bunchfront(i,closest); if (j < 0) continue;
			tempbuf[i] = 1;
			if (!j) { tempbuf[closest] = 1; closest = i; }
		}
		for(i=0;i<numbunches;i++) //Double-check
		{
			if (tempbuf[i]) continue;
			j = polymost_bunchfront(i,closest); if (j < 0) continue;
			tempbuf[i] = 1;
			if (!j) { tempbuf[closest] = 1; closest = i; i = 0; }
		}

		polymost_drawalls(closest);

		if (automapping)
		{
			for(j=bunchfirst[closest];j>=0;j=p2[j])
				show2dwall[thewall[j]>>3] |= pow2char[thewall[j]&7];
		}

		numbunches--;
		bunchfirst[closest] = bunchfirst[numbunches];
		bunchlast[closest] = bunchlast[numbunches];
	}
#if USE_OPENGL
	if (rendmode == 3)
	{
		glfunc.glDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS

		//glfunc.glPolygonOffset(0,0);
#if (USE_OPENGL == USE_GLES2)
		glfunc.glDepthRangef(0.f,0.99999f); //<- this is more widely supported than glPolygonOffset
#else
		glfunc.glDepthRange(0.0,0.99999); //<- this is more widely supported than glPolygonOffset
#endif
	}
#endif
}

// Assembly:
movl 0x5a83c0(%rip), %eax    # 0x5f9950
testl %eax, %eax
je 0x5250c
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
leaq 0x12bb00(%rip), %rcx    # 0x17d0b0
leaq 0x3815c9(%rip), %r12    # 0x3d2b80
movslq (%r12), %rdx
leaq 0x12bcc2(%rip), %rsi    # 0x17d284
movslq (%rsi), %rsi
imulq %rdx, %rsi
addq (%rcx), %rsi
leaq 0x37f79d(%rip), %r13    # 0x3d0d70
movslq (%r13), %rcx
addq %rsi, %rcx
leaq 0x3851af(%rip), %rdx    # 0x3d6790
movq %rcx, (%rdx)
cmpl $0x3, %eax
jne 0x5177c
callq 0x4e306
leaq 0x5a8147(%rip), %rbx    # 0x5f9740
movl $0xb71, %edi            # imm = 0xB71
callq *0x40(%rbx)
movl $0x207, %edi            # imm = 0x207
callq *0x98(%rbx)
movsd 0x27cfc(%rip), %xmm0    # 0x79310
movsd 0x234bc(%rip), %xmm1    # 0x74ad8
callq *0xa8(%rbx)
cmpl $0x0, 0x5a8357(%rip)    # 0x5f9980
je 0x5177c
incl 0x5ac57b(%rip)          # 0x5fdbb0
movl 0x5a8411(%rip), %eax    # 0x5f9a4c
leaq 0x3d083e(%rip), %rcx    # 0x421e80
cmpl (%rcx), %eax
jge 0x5166d
incl %eax
movl %eax, 0x5a83fe(%rip)    # 0x5f9a4c
movl $0x1, %edi
movl $0x1, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq *0x10(%rbx)
movl $0x4000, %edi           # imm = 0x4000
callq *0x8(%rbx)
testb $0x1, 0x5ac53c(%rip)    # 0x5fdbb0
movq 0x80(%rbx), %rax
movl (%r13), %edi
leaq 0x519ae(%rip), %rdx     # 0xa3034
leaq 0x3b5957(%rip), %rcx    # 0x406fe4
jne 0x51701
movl (%rcx), %ecx
movl %ecx, %esi
notl %esi
addl (%rdx), %esi
leaq 0x3b5942(%rip), %rdx    # 0x406fe0
movl (%rdx), %edx
subl %edi, %edx
addl $0x11, %edx
subl (%r12), %ecx
incl %ecx
callq *%rax
xorl %edi, %edi
movl $0x1, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq *0x10(%rbx)
leaq 0x21d3b0(%rip), %rax    # 0x26ea78
movl (%rax), %ecx
movl $0x3ff, %eax            # imm = 0x3FF
leal (%rcx,%rax), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
sarl $0xa, %edx
leaq 0x1e836f(%rip), %rcx    # 0x239a50
subl %edx, (%rcx)
leaq 0x21d386(%rip), %rcx    # 0x26ea70
movl (%rcx), %ecx
addl %ecx, %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
sarl $0xa, %eax
leaq 0x1e8357(%rip), %rcx    # 0x239a54
addl (%rcx), %eax
jmp 0x51773
movl (%rcx), %ecx
movl %ecx, %esi
notl %esi
addl (%rdx), %esi
leaq 0x3b58d0(%rip), %rdx    # 0x406fe0
movl (%rdx), %edx
subl %edi, %edx
addl $-0x10, %edi
addl $0x11, %edx
subl (%r12), %ecx
incl %ecx
callq *%rax
movl $0x1, %edi
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq *0x10(%rbx)
leaq 0x21d33e(%rip), %rax    # 0x26ea78
movl (%rax), %eax
movl $0x3ff, %ecx            # imm = 0x3FF
leal (%rax,%rcx), %edx
testl %eax, %eax
cmovnsl %eax, %edx
sarl $0xa, %edx
leaq 0x1e82fd(%rip), %rax    # 0x239a50
addl %edx, (%rax)
leaq 0x21d314(%rip), %rax    # 0x26ea70
movl (%rax), %eax
addl %eax, %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0xa, %ecx
leaq 0x1e82e5(%rip), %rax    # 0x239a54
movl (%rax), %eax
subl %ecx, %eax
leaq 0x1e82da(%rip), %rcx    # 0x239a54
movl %eax, (%rcx)
leaq 0x229315(%rip), %rax    # 0x27aa98
cvtsi2sdl (%rax), %xmm2
mulsd 0x27b89(%rip), %xmm2    # 0x79318
leaq 0x30b122(%rip), %rax    # 0x35c8b8
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
leaq 0x37d5ac(%rip), %rax    # 0x3ced50
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
mulsd %xmm1, %xmm0
mulsd 0x27b69(%rip), %xmm0    # 0x79320
leaq 0x52072(%rip), %rax     # 0xa3830
cvtsi2sdl (%rax), %xmm3
movsd %xmm2, 0x5ac3ee(%rip)   # 0x5fdbb8
mulsd %xmm1, %xmm3
mulsd 0x27b52(%rip), %xmm3    # 0x79328
movsd %xmm0, 0x5ac3e2(%rip)   # 0x5fdbc0
leaq 0x21d28b(%rip), %rbx    # 0x26ea70
xorps %xmm2, %xmm2
cvtsi2sdl (%rbx), %xmm2
movsd %xmm3, 0x5ac3d4(%rip)   # 0x5fdbc8
movsd 0x27b34(%rip), %xmm3    # 0x79330
mulsd %xmm3, %xmm2
movsd %xmm2, 0x5a81a8(%rip)   # 0x5f99b0
leaq 0x21d269(%rip), %r14    # 0x26ea78
cvtsi2sdl (%r14), %xmm4
mulsd %xmm3, %xmm4
movsd %xmm4, 0x5a81a0(%rip)   # 0x5f99c0
mulsd %xmm1, %xmm2
movsd 0x2276c(%rip), %xmm3    # 0x73f98
mulsd %xmm3, %xmm2
movsd %xmm2, 0x5a8170(%rip)   # 0x5f99a8
mulsd %xmm1, %xmm4
mulsd %xmm3, %xmm4
movsd %xmm4, 0x5a8170(%rip)   # 0x5f99b8
leaq 0x3c6615(%rip), %rax    # 0x417e64
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
movsd 0x246ea(%rip), %xmm2    # 0x75f48
mulsd %xmm1, %xmm2
movsd 0x2326e(%rip), %xmm4    # 0x74ad8
movapd %xmm4, %xmm3
divsd %xmm2, %xmm3
movsd %xmm3, 0x5a832e(%rip)   # 0x5f9ba8
leaq 0x22921b(%rip), %rax    # 0x27aa9c
xorps %xmm2, %xmm2
cvtsi2sdl (%rax), %xmm2
leaq 0x37c4b1(%rip), %rax    # 0x3cdd40
xorps %xmm3, %xmm3
cvtsi2ssl (%rax), %xmm3
movsd %xmm1, 0x5a8292(%rip)   # 0x5f9b30
movsd %xmm2, 0x5a8292(%rip)   # 0x5f9b38
cvtss2sd %xmm3, %xmm3
mulsd %xmm0, %xmm3
mulsd 0x27a82(%rip), %xmm3    # 0x79338
movsd %xmm3, 0x5ac312(%rip)   # 0x5fdbd0
leaq 0x2291cf(%rip), %r15    # 0x27aa94
movl (%r15), %eax
sarl %eax
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
subsd %xmm2, %xmm3
mulsd %xmm1, %xmm1
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x518f5
sqrtsd %xmm0, %xmm0
jmp 0x51912
movsd %xmm3, 0x28(%rsp)
callq 0x64c0
xorpd %xmm1, %xmm1
movsd 0x28(%rsp), %xmm3
movsd 0x231c6(%rip), %xmm4    # 0x74ad8
divsd %xmm0, %xmm3
movsd %xmm3, 0x5a8222(%rip)   # 0x5f9b40
mulsd %xmm3, %xmm3
movapd %xmm4, %xmm0
subsd %xmm3, %xmm0
ucomisd %xmm1, %xmm0
jb 0x51936
sqrtsd %xmm0, %xmm0
jmp 0x5193b
callq 0x64c0
movl (%r15), %eax
sarl %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd %xmm0, 0x5a81d1(%rip)   # 0x5f9b20
movsd %xmm1, 0x5a81e1(%rip)   # 0x5f9b38
xorps %xmm0, %xmm0
cvtss2sd 0x5a7ff6(%rip), %xmm0   # 0x5f9958
callq 0x6a10
movsd %xmm0, 0x5a81b9(%rip)   # 0x5f9b28
xorps %xmm0, %xmm0
cvtss2sd 0x5a7fde(%rip), %xmm0   # 0x5f9958
callq 0x6390
movsd %xmm0, 0x5a81c1(%rip)   # 0x5f9b48
andps 0x27ae2(%rip), %xmm0    # 0x79470
movsd 0x279aa(%rip), %xmm1    # 0x79340
ucomisd %xmm0, %xmm1
jbe 0x519d0
movsd 0x5a8184(%rip), %xmm0   # 0x5f9b28
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
movq $0x0, 0x5a818c(%rip) # 0x5f9b48
leaq 0x27abd(%rip), %rcx     # 0x79480
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, 0x5a8158(%rip)   # 0x5f9b28
leaq 0x166067(%rip), %r15    # 0x1b7a3e
cmpb $0x0, (%r15)
je 0x519f3
movsd 0x5a8163(%rip), %xmm0   # 0x5f9b48
xorps 0x25354(%rip), %xmm0    # 0x76d40
movlps %xmm0, 0x5a8155(%rip)   # 0x5f9b48
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0xd8(%rsp)
leaq 0x3b55d4(%rip), %rcx    # 0x406fe0
movl (%rcx), %ecx
subl (%r13), %ecx
movq %rax, 0xc0(%rsp)
addl $0x3, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd %xmm0, 0xc8(%rsp)
movq %rax, 0x98(%rsp)
movq %rax, 0x90(%rsp)
leaq 0x3b5597(%rip), %rax    # 0x406fe4
movl (%rax), %eax
subl (%r12), %eax
addl $0x3, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0xa8(%rsp)
movsd %xmm0, 0xa0(%rsp)
movsd 0x5a80b9(%rip), %xmm0   # 0x5f9b30
movsd 0x5a80b9(%rip), %xmm1   # 0x5f9b38
movsd 0x5a80a1(%rip), %xmm2   # 0x5f9b28
movsd 0x5a80b9(%rip), %xmm3   # 0x5f9b48
movsd 0x5a8089(%rip), %xmm4   # 0x5f9b20
movsd 0x5a80a1(%rip), %xmm5   # 0x5f9b40
movapd %xmm0, %xmm6
mulsd %xmm5, %xmm6
xorl %eax, %eax
movapd %xmm0, %xmm7
mulsd %xmm4, %xmm7
movsd 0xc0(%rsp,%rax,8), %xmm8
subsd %xmm0, %xmm8
movsd 0x90(%rsp,%rax,8), %xmm9
subsd %xmm1, %xmm9
movapd %xmm9, %xmm10
mulsd %xmm3, %xmm10
movapd %xmm3, %xmm11
mulsd %xmm8, %xmm11
mulsd %xmm2, %xmm8
addsd %xmm10, %xmm8
mulsd %xmm2, %xmm9
subsd %xmm11, %xmm9
movsd %xmm8, 0xc0(%rsp,%rax,8)
movapd %xmm5, %xmm8
mulsd %xmm9, %xmm8
mulsd %xmm4, %xmm9
addsd %xmm6, %xmm9
movsd %xmm9, 0x90(%rsp,%rax,8)
movapd %xmm7, %xmm9
subsd %xmm8, %xmm9
movsd %xmm9, 0x180(%rsp,%rax,8)
incq %rax
cmpq $0x4, %rax
jne 0x51ab1
xorl %edx, %edx
movsd 0x22f8e(%rip), %xmm0    # 0x74ad8
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
xorl %eax, %eax
movsd 0x22f7a(%rip), %xmm5    # 0x74ad8
movsd 0x180(%rsp,%rdx,8), %xmm1
ucomisd %xmm5, %xmm1
jb 0x51b9e
movsd 0xc0(%rsp,%rdx,8), %xmm2
cltq
movsd %xmm2, 0x150(%rsp,%rax,8)
movsd 0x90(%rsp,%rdx,8), %xmm2
movsd %xmm2, 0x120(%rsp,%rax,8)
movsd %xmm1, 0xf0(%rsp,%rax,8)
incl %eax
leaq 0x1(%rdx), %rsi
cmpq $0x3, %rdx
movl $0x0, %edi
cmovneq %rsi, %rdi
movsd 0x180(%rsp,%rdi,8), %xmm2
movapd %xmm0, %xmm3
cmpnlepd %xmm2, %xmm3
movapd %xmm0, %xmm4
cmplepd %xmm1, %xmm4
xorpd %xmm3, %xmm4
movd %xmm4, %r8d
testb $0x1, %r8b
jne 0x51c43
movapd %xmm5, %xmm3
subsd %xmm1, %xmm3
subsd %xmm1, %xmm2
divsd %xmm2, %xmm3
movsd 0xc0(%rsp,%rdi,8), %xmm1
movsd 0xc0(%rsp,%rdx,8), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
cltq
movsd %xmm1, 0x150(%rsp,%rax,8)
movsd 0x90(%rsp,%rdi,8), %xmm1
movsd 0x90(%rsp,%rdx,8), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd %xmm1, 0x120(%rsp,%rax,8)
movq %rcx, 0xf0(%rsp,%rax,8)
incl %eax
movq %rsi, %rdx
cmpq $0x4, %rsi
jne 0x51b5e
cmpl $0x3, %eax
jl 0x524fb
movsd 0x5a7ecf(%rip), %xmm0   # 0x5f9b30
movsd 0x5a7ecf(%rip), %xmm1   # 0x5f9b38
movl %eax, %ecx
xorl %edx, %edx
movapd %xmm0, %xmm2
divsd 0xf0(%rsp,%rdx,8), %xmm2
movsd 0x150(%rsp,%rdx,8), %xmm3
mulsd %xmm2, %xmm3
addsd %xmm0, %xmm3
movsd %xmm3, 0x60(%rsp,%rdx,8)
mulsd 0x120(%rsp,%rdx,8), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, 0x30(%rsp,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x51c6d
movl $0x1, 0x5bbf2a(%rip)    # 0x60dbe0
movsd 0x60(%rsp), %xmm0
xorl %esi, %esi
ucomisd 0x68(%rsp), %xmm0
leal -0x1(%rax), %edx
seta %sil
movq %rdx, %rdi
movl %esi, %ecx
movsd 0x60(%rsp,%rcx,8), %xmm0
ucomisd 0x60(%rsp,%rdi,8), %xmm0
movl %edi, %ecx
ja 0x51ce2
movl %esi, %ecx
leaq -0x1(%rdi), %r8
movl %ecx, %esi
cmpq $0x2, %rdi
movq %r8, %rdi
jg 0x51cce
movl %ecx, %esi
xorps %xmm0, %xmm0
cvtsd2ss 0x60(%rsp,%rsi,8), %xmm0
xorps %xmm1, %xmm1
cvtsd2ss 0x30(%rsp,%rsi,8), %xmm1
movss %xmm0, 0x5bbf0b(%rip)   # 0x60dc18
movss %xmm1, 0x5bbf0f(%rip)   # 0x60dc24
movss %xmm1, 0x5bbeff(%rip)   # 0x60dc1c
movl $0x2, 0x5bbeb9(%rip)    # 0x60dbe0
leal 0x1(%rcx), %esi
xorl %edi, %edi
cmpl %eax, %esi
cmovgel %edi, %esi
leal -0x1(%rcx), %r8d
testl %ecx, %ecx
cmovlel %edx, %r8d
movl $0x2, %r9d
leaq 0x5bbea8(%rip), %rcx    # 0x60dbf0
movl %esi, %r10d
movsd 0x60(%rsp,%r10,8), %xmm0
movl %r8d, %r11d
movsd 0x60(%rsp,%r11,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x51e0e
cmpl $0x2, %r9d
jl 0x51d8d
leal -0x1(%r9), %r12d
leaq (%r12,%r12,4), %r13
xorps %xmm2, %xmm2
cvtss2sd (%rcx,%r13,8), %xmm2
ucomisd %xmm0, %xmm2
jb 0x51d8d
movl %r12d, 0x5bbe56(%rip)   # 0x60dbe0
movl %r12d, %r9d
xorps %xmm2, %xmm2
cvtsd2ss %xmm0, %xmm2
movslq %r9d, %r9
leaq (%r9,%r9,4), %r12
movss %xmm2, (%rcx,%r12,8)
movsd 0x30(%rsp,%r11,8), %xmm2
leal 0x1(%r8), %r11d
cmpl %eax, %r11d
cmovgel %edi, %r11d
movsd 0x60(%rsp,%r11,8), %xmm3
subsd %xmm3, %xmm0
movsd 0x30(%rsp,%r11,8), %xmm4
subsd %xmm4, %xmm2
mulsd %xmm0, %xmm2
xorps %xmm0, %xmm0
cvtsd2ss 0x30(%rsp,%r10,8), %xmm0
subsd %xmm3, %xmm1
divsd %xmm1, %xmm2
addsd %xmm4, %xmm2
xorps %xmm1, %xmm1
cvtsd2ss %xmm2, %xmm1
movss %xmm0, 0x4(%rcx,%r12,8)
movss %xmm1, 0xc(%rcx,%r12,8)
incl %r9d
movl %r9d, 0x5bbdde(%rip)    # 0x60dbe0
incl %esi
cmpl %eax, %esi
cmovgel %edi, %esi
jmp 0x51f30
ucomisd %xmm1, %xmm0
jbe 0x51eb5
cmpl $0x2, %r9d
jl 0x51e3f
leal -0x1(%r9), %r12d
leaq (%r12,%r12,4), %r13
xorps %xmm2, %xmm2
cvtss2sd (%rcx,%r13,8), %xmm2
ucomisd %xmm1, %xmm2
jb 0x51e3f
movl %r12d, 0x5bbda4(%rip)   # 0x60dbe0
movl %r12d, %r9d
xorps %xmm2, %xmm2
cvtsd2ss %xmm1, %xmm2
movslq %r9d, %r9
leaq (%r9,%r9,4), %r12
movss %xmm2, (%rcx,%r12,8)
xorps %xmm2, %xmm2
cvtsd2ss 0x30(%rsp,%r11,8), %xmm2
leal -0x1(%rsi), %r11d
testl %esi, %esi
cmovlel %edx, %r11d
movss %xmm2, 0xc(%rcx,%r12,8)
movsd 0x60(%rsp,%r11,8), %xmm2
subsd %xmm2, %xmm1
movsd 0x30(%rsp,%r10,8), %xmm3
movsd 0x30(%rsp,%r11,8), %xmm4
subsd %xmm4, %xmm3
mulsd %xmm1, %xmm3
subsd %xmm2, %xmm0
divsd %xmm0, %xmm3
addsd %xmm4, %xmm3
xorps %xmm0, %xmm0
cvtsd2ss %xmm3, %xmm0
movss %xmm0, 0x4(%rcx,%r12,8)
incl %r9d
movl %r9d, 0x5bbd2d(%rip)    # 0x60dbe0
jmp 0x51f25
cmpl $0x2, %r9d
jl 0x51edc
leal -0x1(%r9), %r12d
leaq (%r12,%r12,4), %r13
xorps %xmm1, %xmm1
cvtss2sd (%rcx,%r13,8), %xmm1
ucomisd %xmm0, %xmm1
jb 0x51edc
movl %r12d, 0x5bbd07(%rip)   # 0x60dbe0
movl %r12d, %r9d
cvtsd2ss %xmm0, %xmm0
movslq %r9d, %r9
leaq (%r9,%r9,4), %r12
movss %xmm0, (%rcx,%r12,8)
xorps %xmm0, %xmm0
cvtsd2ss 0x30(%rsp,%r10,8), %xmm0
movss %xmm0, 0x4(%rcx,%r12,8)
xorps %xmm0, %xmm0
cvtsd2ss 0x30(%rsp,%r11,8), %xmm0
movss %xmm0, 0xc(%rcx,%r12,8)
incl %r9d
movl %r9d, 0x5bbcc7(%rip)    # 0x60dbe0
incl %esi
cmpl %eax, %esi
cmovgel %edi, %esi
cmpl %r8d, %esi
je 0x51f39
testl %r8d, %r8d
leal -0x1(%r8), %r8d
cmovlel %edx, %r8d
cmpl %r8d, %esi
jne 0x51d48
movl %esi, %edx
movsd 0x60(%rsp,%rdx,8), %xmm0
movslq 0x5bbc98(%rip), %rax    # 0x60dbe0
leaq (%rax,%rax,4), %rsi
xorps %xmm1, %xmm1
cvtss2sd -0x28(%rcx,%rsi,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x51f81
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rcx,%rsi,8)
xorps %xmm0, %xmm0
cvtsd2ss 0x30(%rsp,%rdx,8), %xmm0
movss %xmm0, 0xc(%rcx,%rsi,8)
movss %xmm0, 0x4(%rcx,%rsi,8)
incl %eax
movl %eax, 0x5bbc5f(%rip)    # 0x60dbe0
movslq 0x5bbc58(%rip), %rax    # 0x60dbe0
testq %rax, %rax
jle 0x51fc7
leaq 0x5bbc90(%rip), %rdx    # 0x60dc24
xorl %esi, %esi
leaq 0x1(%rsi), %rdi
movss -0x8(%rdx), %xmm0
movss (%rdx), %xmm1
movss %xmm0, -0x2c(%rdx)
movl %esi, -0x14(%rdx)
movss %xmm1, -0x24(%rdx)
movl %esi, -0x10(%rdx)
movl %edi, -0x20(%rdx)
decl %esi
movl %esi, -0x1c(%rdx)
addq $0x28, %rdx
movq %rdi, %rsi
cmpq %rdi, %rax
jne 0x51f96
leal -0x1(%rax), %esi
leaq (%rax,%rax,4), %rdx
movl $0x0, -0x14(%rcx,%rdx,8)
movl %esi, 0x5bbc2c(%rip)    # 0x60dc08
movl %eax, 0x5e3c0e(%rip)    # 0x635bf0
cmpl $0xfff, %eax            # imm = 0xFFF
jg 0x5201c
leal -0x1(%rax), %esi
leaq (%rcx,%rdx,8), %rdi
addq $0x18, %rdi
movq %rax, %r8
incq %r8
movq %r8, %r9
leal 0x2(%rsi), %r10d
movl %r10d, -0x4(%rdi)
movl %esi, (%rdi)
incl %esi
addq $0x28, %rdi
incq %r9
cmpl $0x1000, %r8d           # imm = 0x1000
movq %r9, %r8
jne 0x51ffd
movl %eax, 0x5e3bba(%rip)    # 0x635bdc
movl $0xfff, 0x18(%rcx,%rdx,8) # imm = 0xFFF
leaq 0x345a9f(%rip), %r12    # 0x397ad0
cmpw $0x2, (%r12)
jne 0x522be
leaq 0x51bfc(%rip), %rax     # 0xa3c40
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
movsd 0x5a7add(%rip), %xmm2   # 0x5f9b30
leaq 0x3c5e0e(%rip), %rax    # 0x417e68
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
subsd %xmm2, %xmm0
subsd 0x5a7acb(%rip), %xmm1   # 0x5f9b38
movsd 0x5a7ab3(%rip), %xmm3   # 0x5f9b28
movsd 0x5a7acb(%rip), %xmm4   # 0x5f9b48
movapd %xmm1, %xmm5
mulsd %xmm4, %xmm5
mulsd %xmm0, %xmm4
mulsd %xmm3, %xmm0
addsd %xmm5, %xmm0
mulsd %xmm3, %xmm1
subsd %xmm4, %xmm1
movsd 0x5a7a7f(%rip), %xmm3   # 0x5f9b20
movsd 0x5a7a97(%rip), %xmm4   # 0x5f9b40
movapd %xmm2, %xmm5
mulsd %xmm4, %xmm2
mulsd %xmm1, %xmm4
mulsd %xmm3, %xmm5
subsd %xmm4, %xmm5
mulsd %xmm3, %xmm1
xorps %xmm3, %xmm3
cvtsi2ssl (%rbx), %xmm3
cvtss2sd %xmm3, %xmm3
xorps %xmm4, %xmm4
cvtsi2ssl (%r14), %xmm4
cvtss2sd %xmm4, %xmm4
movapd %xmm0, %xmm6
mulsd %xmm4, %xmm6
movapd %xmm5, %xmm7
mulsd %xmm3, %xmm7
subsd %xmm6, %xmm7
cvttsd2si %xmm7, %r8d
addsd %xmm2, %xmm1
mulsd %xmm3, %xmm0
mulsd %xmm4, %xmm5
addsd %xmm0, %xmm5
cvttsd2si %xmm5, %r9d
mulsd 0x23e1a(%rip), %xmm1    # 0x75f28
cvttsd2si %xmm1, %eax
leaq 0x16591f(%rip), %rbx    # 0x1b7a38
movl $0x1, (%rbx)
leaq 0x1e792a(%rip), %rcx    # 0x239a50
movl (%rcx), %edi
leaq 0x1e7925(%rip), %rcx    # 0x239a54
movl (%rcx), %esi
leaq 0x218928(%rip), %rcx    # 0x26aa60
movl (%rcx), %edx
leaq 0x37bc0b(%rip), %rcx    # 0x3cdd4c
movswl (%rcx), %ecx
sarl $0xc, %r8d
sarl $0xc, %r9d
sarl $0x8, %eax
leaq 0x14(%rsp), %r10
leaq 0x18(%rsp), %r11
leaq 0x1c(%rsp), %r13
leaq 0xe(%rsp), %rbp
leaq 0xc(%rsp), %r14
leaq 0x26(%rsp), %r15
pushq $-0xffd0                # imm = 0xFFFF0030
pushq %r10
pushq %r11
pushq %r13
pushq %rbp
pushq %r14
pushq %r15
pushq %rax
callq 0x36048
addq $0x40, %rsp
movl $0x0, (%rbx)
movzwl (%r15), %ecx
leaq 0x402d58(%rip), %rax    # 0x454ef0
movw %cx, (%rax)
movswq (%r14), %rax
testq %rax, %rax
js 0x52230
leaq 0x402d43(%rip), %r13    # 0x454ef2
movw %ax, (%r13)
leaq 0x345917(%rip), %rbp    # 0x397ad2
movw $0x0, (%rbp)
shlq $0x5, %rax
leaq 0x165884(%rip), %r14    # 0x1b7a50
cmpw $0x0, 0xa(%r14,%rax)
leaq 0x165864(%rip), %r15    # 0x1b7a3e
js 0x522b7
movswl 0xc(%r14,%rax), %edi
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
leaq 0x10(%rsp), %rcx
leaq 0x20(%rsp), %rbx
movq %rbx, %r8
callq 0x2600d
movl 0x14(%rsp), %eax
cmpl (%rbx), %eax
jle 0x52252
movswq 0xc(%rsp), %rax
shlq $0x5, %rax
testb $0x2, 0xe(%r14,%rax)
je 0x522b7
addq %rax, %r14
movzwl 0xa(%r14), %eax
movw %ax, (%r13)
jmp 0x522b7
movzwl 0xe(%rsp), %eax
testw %ax, %ax
js 0x52272
leaq 0x402cb1(%rip), %rcx    # 0x454ef2
movw %ax, (%rcx)
leaq 0x345887(%rip), %rax    # 0x397ad2
movw $0x3, (%rax)
jmp 0x522b0
cmpl 0x10(%rsp), %eax
jle 0x522b7
movswq 0xc(%rsp), %rax
shlq $0x5, %rax
testb $0x30, 0xe(%r14,%rax)
je 0x522b7
movw $0x4, (%rbp)
jmp 0x522b7
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
movswl %cx, %edi
leaq 0x10(%rsp), %rbx
leaq 0x20(%rsp), %r14
movq %rbx, %rcx
movq %r14, %r8
callq 0x2600d
movl 0x14(%rsp), %eax
addl %eax, %eax
movl (%r14), %ecx
addl (%rbx), %ecx
xorl %edx, %edx
cmpl %ecx, %eax
setge %dl
incl %edx
leaq 0x345825(%rip), %rax    # 0x397ad2
movw %dx, (%rax)
leaq 0x165787(%rip), %r15    # 0x1b7a3e
movw $0x0, (%r12)
leaq 0x3844d7(%rip), %r12    # 0x3d679c
xorl %eax, %eax
movw %ax, (%r12)
leaq 0x3844c7(%rip), %rcx    # 0x3d679a
movw %ax, (%rcx)
leaq 0x37ba6f(%rip), %rbx    # 0x3cdd4c
movswl (%rbx), %r14d
cmpl $0x1000, %r14d          # imm = 0x1000
jl 0x522f3
addl $0xfffff000, %r14d      # imm = 0xFFFFF000
jmp 0x52313
leaq 0x1e7756(%rip), %rax    # 0x239a50
movl (%rax), %edi
leaq 0x1e7751(%rip), %rax    # 0x239a54
movl (%rax), %esi
movq %rbx, %rdx
callq 0x25f34
cmpw $0x0, (%rbx)
jns 0x52317
movw %r14w, (%rbx)
movswl (%rbx), %edi
callq 0x5250d
cmpb $0x0, (%r15)
movsd 0x5a787d(%rip), %xmm0   # 0x5f9ba8
je 0x52376
xorpd 0x24a0b(%rip), %xmm0    # 0x76d40
movlpd %xmm0, 0x5a7863(%rip)   # 0x5f9ba0
movb $0x0, (%r15)
xorl %edi, %edi
callq 0x52bb4
movzwl (%r12), %eax
decl %eax
movw %ax, (%r12)
movswq %ax, %rax
leaq 0x384461(%rip), %rcx    # 0x3d67c0
movzwl (%rcx,%rax,2), %edx
movw %dx, (%rcx)
leaq 0x386453(%rip), %rcx    # 0x3d87c0
movzwl (%rcx,%rax,2), %eax
movw %ax, (%rcx)
jmp 0x5237e
movsd %xmm0, 0x5a7822(%rip)   # 0x5f9ba0
movzwl (%r12), %ecx
testw %cx, %cx
jle 0x524ce
leaq 0x5a781d(%rip), %rbx    # 0x5f9bb0
leaq 0x38c436(%rip), %r13    # 0x3de7d0
addl $0x3, %ecx
movzwl %cx, %edx
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x62f0
movb $0x1, 0x5a77fd(%rip)    # 0x5f9bb0
cmpw $0x2, (%r12)
jl 0x523ef
xorl %ebp, %ebp
movl $0x1, %r14d
movl %r14d, %edi
movl %ebp, %esi
callq 0x575fc
testl %eax, %eax
js 0x523e2
movb $0x1, (%r14,%rbx)
jne 0x523e2
movslq %ebp, %rax
movb $0x1, (%rax,%rbx)
movl %r14d, %ebp
incq %r14
movswq (%r12), %rax
cmpq %rax, %r14
jl 0x523c3
cmpw $0x0, (%r12)
jle 0x52437
xorl %r14d, %r14d
movslq %r14d, %r15
cmpb $0x0, (%r15,%rbx)
je 0x52413
incl %r14d
movswl (%r12), %eax
cmpl %eax, %r14d
jl 0x523fa
jmp 0x52437
movl %r14d, %edi
movl %ebp, %esi
callq 0x575fc
testl %eax, %eax
js 0x52404
movb $0x1, (%r15,%rbx)
jne 0x52404
movslq %ebp, %rax
movb $0x1, (%rax,%rbx)
movl %r14d, %ebp
xorl %r14d, %r14d
jmp 0x52404
movl %ebp, %edi
callq 0x52bb4
leaq 0x35909b(%rip), %rax    # 0x3ab4e0
cmpb $0x0, (%rax)
movslq %ebp, %rax
leaq 0x1e55fe(%rip), %rdi    # 0x237a50
leaq 0x51347(%rip), %r8      # 0xa37a0
leaq 0x358880(%rip), %r9     # 0x3aace0
je 0x52497
leaq 0x384357(%rip), %rcx    # 0x3d67c0
movzwl (%rcx,%rax,2), %ecx
testw %cx, %cx
js 0x52497
movzwl %cx, %ecx
addl %ecx, %ecx
movswq (%rdi,%rcx), %rdx
movl %edx, %esi
andl $0x7, %esi
movb (%r8,%rsi), %sil
sarl $0x3, %edx
movslq %edx, %rdx
orb %sil, (%r9,%rdx)
movzwl (%r13,%rcx), %ecx
jmp 0x5246d
movzwl (%r12), %ecx
decl %ecx
movw %cx, (%r12)
movswq %cx, %rdx
leaq 0x384312(%rip), %rdi    # 0x3d67c0
movzwl (%rdi,%rdx,2), %esi
movw %si, (%rdi,%rax,2)
leaq 0x386303(%rip), %rsi    # 0x3d87c0
movzwl (%rsi,%rdx,2), %edx
movw %dx, (%rsi,%rax,2)
testw %cx, %cx
jg 0x5239a
cmpl $0x3, 0x5a747b(%rip)    # 0x5f9950
jne 0x524fb
leaq 0x5a7262(%rip), %rbx    # 0x5f9740
movl $0x203, %edi            # imm = 0x203
callq *0x98(%rbx)
movsd 0x26e57(%rip), %xmm1    # 0x79348
xorpd %xmm0, %xmm0
callq *0xa8(%rbx)
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq