// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: hitscan
int hitscan(int xs, int ys, int zs, short sectnum, int vx, int vy, int vz,
	short *hitsect, short *hitwall, short *hitsprite,
	int *hitx, int *hity, int *hitz, unsigned int cliptype)
{
	sectortype *sec;
	walltype *wal, *wal2;
	spritetype *spr;
	int z, zz, x1, y1=0, z1=0, x2, y2, x3, y3, x4, y4, intx, inty, intz;
	int topt, topu, bot, dist, offx, offy, cstat;
	int i, j, k, l, tilenum, xoff, yoff, dax, day, daz, daz2;
	int ang, cosang, sinang, xspan, yspan, xrepeat, yrepeat;
	int dawalclipmask, dasprclipmask;
	short tempshortcnt, tempshortnum, dasector, startwall, endwall;
	short nextsector;
	unsigned char clipyou;

	*hitsect = -1; *hitwall = -1; *hitsprite = -1;
	if (sectnum < 0) return(-1);

	*hitx = hitscangoalx; *hity = hitscangoaly;

	dawalclipmask = (cliptype&65535);
	dasprclipmask = (cliptype>>16);

	clipsectorlist[0] = sectnum;
	tempshortcnt = 0; tempshortnum = 1;
	do
	{
		dasector = clipsectorlist[tempshortcnt]; sec = &sector[dasector];

		x1 = 0x7fffffff;
		if (sec->ceilingstat&2)
		{
			wal = &wall[sec->wallptr]; wal2 = &wall[wal->point2];
			dax = wal2->x-wal->x; day = wal2->y-wal->y;
			i = nsqrtasm(dax*dax+day*day); if (i == 0) continue;
			i = divscale15(sec->ceilingheinum,i);
			dax *= i; day *= i;

			j = (vz<<8)-dmulscale15(dax,vy,-day,vx);
			if (j != 0)
			{
				i = ((sec->ceilingz-zs)<<8)+dmulscale15(dax,ys-wal->y,-day,xs-wal->x);
				if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j)))
				{
					i = divscale30(i,j);
					x1 = xs + mulscale30(vx,i);
					y1 = ys + mulscale30(vy,i);
					z1 = zs + mulscale30(vz,i);
				}
			}
		}
		else if ((vz < 0) && (zs >= sec->ceilingz))
		{
			z1 = sec->ceilingz; i = z1-zs;
			if ((klabs(i)>>1) < -vz)
			{
				i = divscale30(i,vz);
				x1 = xs + mulscale30(vx,i);
				y1 = ys + mulscale30(vy,i);
			}
		}
		if ((x1 != 0x7fffffff) && (klabs(x1-xs)+klabs(y1-ys) < klabs((*hitx)-xs)+klabs((*hity)-ys)))
			if (inside(x1,y1,dasector) != 0)
			{
				*hitsect = dasector; *hitwall = -1; *hitsprite = -1;
				*hitx = x1; *hity = y1; *hitz = z1;
			}

		x1 = 0x7fffffff;
		if (sec->floorstat&2)
		{
			wal = &wall[sec->wallptr]; wal2 = &wall[wal->point2];
			dax = wal2->x-wal->x; day = wal2->y-wal->y;
			i = nsqrtasm(dax*dax+day*day); if (i == 0) continue;
			i = divscale15(sec->floorheinum,i);
			dax *= i; day *= i;

			j = (vz<<8)-dmulscale15(dax,vy,-day,vx);
			if (j != 0)
			{
				i = ((sec->floorz-zs)<<8)+dmulscale15(dax,ys-wal->y,-day,xs-wal->x);
				if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j)))
				{
					i = divscale30(i,j);
					x1 = xs + mulscale30(vx,i);
					y1 = ys + mulscale30(vy,i);
					z1 = zs + mulscale30(vz,i);
				}
			}
		}
		else if ((vz > 0) && (zs <= sec->floorz))
		{
			z1 = sec->floorz; i = z1-zs;
			if ((klabs(i)>>1) < vz)
			{
				i = divscale30(i,vz);
				x1 = xs + mulscale30(vx,i);
				y1 = ys + mulscale30(vy,i);
			}
		}
		if ((x1 != 0x7fffffff) && (klabs(x1-xs)+klabs(y1-ys) < klabs((*hitx)-xs)+klabs((*hity)-ys)))
			if (inside(x1,y1,dasector) != 0)
			{
				*hitsect = dasector; *hitwall = -1; *hitsprite = -1;
				*hitx = x1; *hity = y1; *hitz = z1;
			}

		startwall = sec->wallptr; endwall = startwall + sec->wallnum;
		for(z=startwall,wal=&wall[startwall];z<endwall;z++,wal++)
		{
			wal2 = &wall[wal->point2];
			x1 = wal->x; y1 = wal->y; x2 = wal2->x; y2 = wal2->y;

			if ((x1-xs)*(y2-ys) < (x2-xs)*(y1-ys)) continue;
			if (rintersect(xs,ys,zs,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz) == 0) continue;

			if (klabs(intx-xs)+klabs(inty-ys) >= klabs((*hitx)-xs)+klabs((*hity)-ys)) continue;

			nextsector = wal->nextsector;
			if ((nextsector < 0) || (wal->cstat&dawalclipmask))
			{
				*hitsect = dasector; *hitwall = z; *hitsprite = -1;
				*hitx = intx; *hity = inty; *hitz = intz;
				continue;
			}
			getzsofslope(nextsector,intx,inty,&daz,&daz2);
			if ((intz <= daz) || (intz >= daz2))
			{
				*hitsect = dasector; *hitwall = z; *hitsprite = -1;
				*hitx = intx; *hity = inty; *hitz = intz;
				continue;
			}

			for(zz=tempshortnum-1;zz>=0;zz--)
				if (clipsectorlist[zz] == nextsector) break;
			if (zz < 0) clipsectorlist[tempshortnum++] = nextsector;
		}

		for(z=headspritesect[dasector];z>=0;z=nextspritesect[z])
		{
			spr = &sprite[z];
			cstat = spr->cstat;
#if USE_POLYMOST
			if (!hitallsprites)
#endif
			if ((cstat&dasprclipmask) == 0) continue;

			x1 = spr->x; y1 = spr->y; z1 = spr->z;
			switch(cstat&48)
			{
				case 0:
					topt = vx*(x1-xs) + vy*(y1-ys); if (topt <= 0) continue;
					bot = vx*vx + vy*vy; if (bot == 0) continue;

					intz = zs+scale(vz,topt,bot);

					i = (tilesizy[spr->picnum]*spr->yrepeat<<2);
					if (cstat&128) z1 += (i>>1);
					if (picanm[spr->picnum]&0x00ff0000) z1 -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2);
					if ((intz > z1) || (intz < z1-i)) continue;
					topu = vx*(y1-ys) - vy*(x1-xs);

					offx = scale(vx,topu,bot);
					offy = scale(vy,topu,bot);
					dist = offx*offx + offy*offy;
					i = tilesizx[spr->picnum]*spr->xrepeat; i *= i;
					if (dist > (i>>7)) continue;
					intx = xs + scale(vx,topt,bot);
					inty = ys + scale(vy,topt,bot);

					if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue;

					*hitsect = dasector; *hitwall = -1; *hitsprite = z;
					*hitx = intx; *hity = inty; *hitz = intz;
					break;
				case 16:
						//These lines get the 2 points of the rotated sprite
						//Given: (x1, y1) starts out as the center point
					tilenum = spr->picnum;
					xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset);
					if ((cstat&4) > 0) xoff = -xoff;
					k = spr->ang; l = spr->xrepeat;
					dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l;
					l = tilesizx[tilenum]; k = (l>>1)+xoff;
					x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l);
					y1 -= mulscale16(day,k); y2 = y1+mulscale16(day,l);

					if ((cstat&64) != 0)   //back side of 1-way sprite
						if ((x1-xs)*(y2-ys) < (x2-xs)*(y1-ys)) continue;

					if (rintersect(xs,ys,zs,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz) == 0) continue;

					if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue;

					k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2);
					if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z;
					if (picanm[spr->picnum]&0x00ff0000) daz -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2);
					if ((intz < daz) && (intz > daz-k))
					{
						*hitsect = dasector; *hitwall = -1; *hitsprite = z;
						*hitx = intx; *hity = inty; *hitz = intz;
					}
					break;
				case 32:
					if (vz == 0) continue;
					intz = z1;
					if (((intz-zs)^vz) < 0) continue;
					if ((cstat&64) != 0)
						if ((zs > intz) == ((cstat&8)==0)) continue;

					intx = xs+scale(intz-zs,vx,vz);
					inty = ys+scale(intz-zs,vy,vz);

					if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue;

					tilenum = spr->picnum;
					xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset);
					yoff = (int)((signed char)((picanm[tilenum]>>16)&255))+((int)spr->yoffset);
					if ((cstat&4) > 0) xoff = -xoff;
					if ((cstat&8) > 0) yoff = -yoff;

					ang = spr->ang;
					cosang = sintable[(ang+512)&2047]; sinang = sintable[ang];
					xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat;
					yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat;

					dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat;
					x1 += dmulscale16(sinang,dax,cosang,day)-intx;
					y1 += dmulscale16(sinang,day,-cosang,dax)-inty;
					l = xspan*xrepeat;
					x2 = x1 - mulscale16(sinang,l);
					y2 = y1 + mulscale16(cosang,l);
					l = yspan*yrepeat;
					k = -mulscale16(cosang,l); x3 = x2+k; x4 = x1+k;
					k = -mulscale16(sinang,l); y3 = y2+k; y4 = y1+k;

					clipyou = 0;
					if ((y1^y2) < 0)
					{
						if ((x1^x2) < 0) clipyou ^= (x1*y2<x2*y1)^(y1<y2);
						else if (x1 >= 0) clipyou ^= 1;
					}
					if ((y2^y3) < 0)
					{
						if ((x2^x3) < 0) clipyou ^= (x2*y3<x3*y2)^(y2<y3);
						else if (x2 >= 0) clipyou ^= 1;
					}
					if ((y3^y4) < 0)
					{
						if ((x3^x4) < 0) clipyou ^= (x3*y4<x4*y3)^(y3<y4);
						else if (x3 >= 0) clipyou ^= 1;
					}
					if ((y4^y1) < 0)
					{
						if ((x4^x1) < 0) clipyou ^= (x4*y1<x1*y4)^(y4<y1);
						else if (x4 >= 0) clipyou ^= 1;
					}

					if (clipyou != 0)
					{
						*hitsect = dasector; *hitwall = -1; *hitsprite = z;
						*hitx = intx; *hity = inty; *hitz = intz;
					}
					break;
			}
		}
		tempshortcnt++;
	} while (tempshortcnt < tempshortnum);
	return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %edx, 0x14(%rsp)
movq 0xe8(%rsp), %rax
movq 0xd8(%rsp), %rdx
orw $-0x1, (%rdx)
movq 0xe0(%rsp), %rdx
orw $-0x1, (%rdx)
orw $-0x1, (%rax)
testw %cx, %cx
js 0x34bb2
movl 0x108(%rsp), %r13d
movq 0xf8(%rsp), %rbx
movq 0xf0(%rsp), %r10
movl %r9d, %r11d
movl 0xd0(%rsp), %r15d
movl 0x69d03(%rip), %eax     # 0x9d834
movl %eax, (%r10)
movl 0x69cfe(%rip), %eax     # 0x9d838
movl %eax, (%rbx)
shrl $0x10, %r13d
movw %cx, 0x3f69f9(%rip)     # 0x42a540
movl %r15d, %eax
shll $0x8, %eax
movl %eax, 0x68(%rsp)
movslq %r9d, %rcx
movslq %r8d, %rdx
movslq %r15d, %rax
movl %eax, %r9d
movq %r9, 0x90(%rsp)
movq %rax, 0x60(%rsp)
negl %eax
movl %eax, 0x7c(%rsp)
movl %edx, %eax
imull %edx, %eax
movl %ecx, %r9d
imull %r9d, %r9d
addl %eax, %r9d
movw $0x1, %ax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
leaq 0x242120(%rip), %r12    # 0x275cb0
movl %r11d, 0x1c(%rsp)
movl %r8d, 0x34(%rsp)
movq %rsi, %r8
movq %rsi, 0x20(%rsp)
movq %rdi, 0x28(%rsp)
movl %r13d, 0xc(%rsp)
movq %rcx, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
movq %r9, 0x88(%rsp)
movl %r10d, 0x3c(%rsp)
movl %eax, 0x4c(%rsp)
movswq %ax, %rax
leaq 0x3f696e(%rip), %rcx    # 0x42a540
movzwl (%rcx,%rax,2), %edx
movswq %dx, %rcx
movq %rcx, 0x70(%rsp)
imulq $0x28, %rcx, %rax
leaq 0x208e76(%rip), %rcx    # 0x23ca60
leaq (%rcx,%rax), %r13
testb $0x2, 0xc(%rax,%rcx)
movw %dx, 0x1a(%rsp)
movswl %dx, %eax
movl %eax, 0x10(%rsp)
jne 0x33c43
testl %r15d, %r15d
movq %r8, %r9
jns 0x33e31
movl 0x4(%r13), %r14d
movl %r14d, %eax
subl 0x14(%rsp), %eax
jg 0x33e31
movl %eax, %ecx
negl %ecx
shrl %ecx
cmpl 0x7c(%rsp), %ecx
jae 0x33e31
cltq
shlq $0x1e, %rax
cqto
idivq 0x60(%rsp)
movslq %eax, %rbx
jmp 0x33d69
movl %r15d, %ebx
movswq (%r13), %rax
shlq $0x5, %rax
leaq 0x17ddfa(%rip), %rdx    # 0x1b1a50
movswq 0x8(%rax,%rdx), %rcx
shlq $0x5, %rcx
movl (%rax,%rdx), %ebp
movl 0x4(%rax,%rdx), %r14d
movl (%rcx,%rdx), %r12d
movl 0x4(%rcx,%rdx), %r15d
subl %ebp, %r12d
subl %r14d, %r15d
movl %r12d, %eax
imull %r12d, %eax
movl %r15d, %edi
imull %r15d, %edi
addl %eax, %edi
callq 0x22169
testl %eax, %eax
je 0x34b62
movswq 0x12(%r13), %rcx
shlq $0xf, %rcx
movslq %eax, %rsi
movq %rcx, %rax
cqto
idivq %rsi
imull %eax, %r12d
imull %eax, %r15d
negl %r15d
movslq %r12d, %rdx
movq %rdx, %rcx
imulq 0x50(%rsp), %rcx
movslq %r15d, %rax
movq %rax, %rsi
imulq 0x58(%rsp), %rsi
addq %rcx, %rsi
shrq $0xf, %rsi
movl 0x68(%rsp), %ecx
subl %esi, %ecx
movq 0x20(%rsp), %r9
movq 0x28(%rsp), %rdi
leaq 0x241fc7(%rip), %r12    # 0x275cb0
je 0x33e31
movl 0x4(%r13), %esi
subl 0x14(%rsp), %esi
shll $0x8, %esi
movl %r9d, %edi
subl %r14d, %edi
movq 0x28(%rsp), %r8
subl %ebp, %r8d
movslq %edi, %rdi
imulq %rdi, %rdx
movslq %r8d, %rdi
imulq %rdi, %rax
movq 0x28(%rsp), %rdi
addq %rdx, %rax
shrq $0xf, %rax
addl %esi, %eax
movl %eax, %edx
xorl %ecx, %edx
js 0x33e31
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
shrl %edx
movl %ecx, %esi
negl %esi
cmovsl %ecx, %esi
cmpl %esi, %edx
jae 0x33e31
cltq
shlq $0x1e, %rax
movslq %ecx, %rcx
cqto
idivq %rcx
movslq %eax, %rbx
movq %rbx, %r14
imulq 0x60(%rsp), %r14
shrq $0x1e, %r14
addl 0x14(%rsp), %r14d
movq %rbx, %rax
imulq 0x58(%rsp), %rax
shrq $0x1e, %rax
leal (%rax,%rdi), %ebp
cmpl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
je 0x33e31
imulq 0x50(%rsp), %rbx
shrq $0x1e, %rbx
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ebx, %eax
negl %eax
cmovsl %ebx, %eax
addl %ecx, %eax
movq 0xf0(%rsp), %rcx
movl (%rcx), %ecx
subl %edi, %ecx
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
movq 0xf8(%rsp), %rcx
movl (%rcx), %ecx
subl %r9d, %ecx
movl %ecx, %esi
negl %esi
cmovsl %ecx, %esi
addl %edx, %esi
cmpl %esi, %eax
jae 0x33e31
addl %r9d, %ebx
movl %ebp, %edi
movl %ebx, %esi
movl 0x10(%rsp), %edx
callq 0x330c8
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %r9
testl %eax, %eax
je 0x33e31
movq 0xd8(%rsp), %rax
movzwl 0x1a(%rsp), %ecx
movw %cx, (%rax)
movq 0xe0(%rsp), %rax
orw $-0x1, (%rax)
movq 0xe8(%rsp), %rax
orw $-0x1, (%rax)
movq 0xf0(%rsp), %rax
movl %ebp, (%rax)
movq 0xf8(%rsp), %rax
movl %ebx, (%rax)
movq 0x100(%rsp), %rax
movl %r14d, (%rax)
testb $0x2, 0xe(%r13)
jne 0x33e80
cmpl $0x0, 0xd0(%rsp)
jle 0x3406b
movl 0x8(%r13), %r14d
movl %r14d, %eax
subl 0x14(%rsp), %eax
jl 0x3406b
movl %eax, %ecx
shrl %ecx
cmpl 0xd0(%rsp), %ecx
jae 0x3406b
cltq
shlq $0x1e, %rax
cqto
idivq 0x90(%rsp)
movslq %eax, %rbx
jmp 0x33fa3
movswq (%r13), %rax
shlq $0x5, %rax
leaq 0x17dbc0(%rip), %rdx    # 0x1b1a50
movswq 0x8(%rax,%rdx), %rcx
shlq $0x5, %rcx
movl (%rax,%rdx), %ebp
movl 0x4(%rax,%rdx), %r14d
movl (%rcx,%rdx), %r12d
movl 0x4(%rcx,%rdx), %r15d
subl %ebp, %r12d
subl %r14d, %r15d
movl %r12d, %eax
imull %r12d, %eax
movl %r15d, %edi
imull %r15d, %edi
addl %eax, %edi
callq 0x22169
testl %eax, %eax
je 0x34b81
movswq 0x1a(%r13), %rcx
shlq $0xf, %rcx
movslq %eax, %rsi
movq %rcx, %rax
cqto
idivq %rsi
imull %eax, %r12d
imull %eax, %r15d
negl %r15d
movslq %r12d, %rdx
movq %rdx, %rcx
imulq 0x50(%rsp), %rcx
movslq %r15d, %rax
movq %rax, %rsi
imulq 0x58(%rsp), %rsi
addq %rcx, %rsi
shrq $0xf, %rsi
movl 0x68(%rsp), %ecx
subl %esi, %ecx
movq 0x20(%rsp), %r9
movq 0x28(%rsp), %rdi
leaq 0x241d8d(%rip), %r12    # 0x275cb0
je 0x3406b
movl 0x8(%r13), %esi
subl 0x14(%rsp), %esi
shll $0x8, %esi
movl %r9d, %edi
subl %r14d, %edi
movq 0x28(%rsp), %r8
subl %ebp, %r8d
movslq %edi, %rdi
imulq %rdi, %rdx
movslq %r8d, %rdi
imulq %rdi, %rax
movq 0x28(%rsp), %rdi
addq %rdx, %rax
shrq $0xf, %rax
addl %esi, %eax
movl %eax, %edx
xorl %ecx, %edx
js 0x3406b
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
shrl %edx
movl %ecx, %esi
negl %esi
cmovsl %ecx, %esi
cmpl %esi, %edx
jae 0x3406b
cltq
shlq $0x1e, %rax
movslq %ecx, %rcx
cqto
idivq %rcx
movslq %eax, %rbx
movq %rbx, %r14
imulq 0x60(%rsp), %r14
shrq $0x1e, %r14
addl 0x14(%rsp), %r14d
movq %rbx, %rax
imulq 0x58(%rsp), %rax
shrq $0x1e, %rax
leal (%rax,%rdi), %ebp
cmpl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
je 0x3406b
imulq 0x50(%rsp), %rbx
shrq $0x1e, %rbx
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ebx, %eax
negl %eax
cmovsl %ebx, %eax
addl %ecx, %eax
movq 0xf0(%rsp), %rcx
movl (%rcx), %ecx
subl %edi, %ecx
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
movq 0xf8(%rsp), %rcx
movl (%rcx), %ecx
subl %r9d, %ecx
movl %ecx, %esi
negl %esi
cmovsl %ecx, %esi
addl %edx, %esi
cmpl %esi, %eax
jae 0x3406b
addl %r9d, %ebx
movl %ebp, %edi
movl %ebx, %esi
movl 0x10(%rsp), %edx
callq 0x330c8
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %r9
testl %eax, %eax
je 0x3406b
movq 0xd8(%rsp), %rax
movzwl 0x1a(%rsp), %ecx
movw %cx, (%rax)
movq 0xe0(%rsp), %rax
orw $-0x1, (%rax)
movq 0xe8(%rsp), %rax
orw $-0x1, (%rax)
movq 0xf0(%rsp), %rax
movl %ebp, (%rax)
movq 0xf8(%rsp), %rax
movl %ebx, (%rax)
movq 0x100(%rsp), %rax
movl %r14d, (%rax)
movswq (%r13), %r14
movzwl 0x2(%r13), %eax
addw %r14w, %ax
movq %r14, %rbp
shlq $0x5, %rbp
leaq 0x17d9c9(%rip), %rcx    # 0x1b1a50
addq %rcx, %rbp
movswl %ax, %r15d
movl 0x34(%rsp), %r13d
movl 0x1c(%rsp), %r8d
movl %r15d, 0x10(%rsp)
cmpl %r15d, %r14d
jge 0x3432e
movswq 0x8(%rbp), %rcx
shlq $0x5, %rcx
movl (%rbp), %eax
movl 0x4(%rbp), %r10d
leaq 0x17d993(%rip), %rdx    # 0x1b1a50
movl (%rcx,%rdx), %r11d
movl 0x4(%rcx,%rdx), %ebx
movl %eax, %ecx
subl %edi, %ecx
movl %ebx, %edx
subl %r9d, %edx
imull %ecx, %edx
movl %r11d, %ecx
subl %edi, %ecx
movl %r10d, %esi
subl %r9d, %esi
imull %ecx, %esi
cmpl %esi, %edx
jl 0x3423e
subq $0x8, %rsp
movq %rdi, %r15
movl %r9d, %esi
movl 0x1c(%rsp), %edx
movl %r13d, %ecx
movq %r9, %r12
movl 0xd8(%rsp), %r9d
leaq 0x40(%rsp), %r13
pushq %r13
leaq 0x50(%rsp), %r13
pushq %r13
leaq 0x5c(%rsp), %r13
pushq %r13
pushq %rbx
pushq %r11
pushq %r10
pushq %rax
callq 0x34bc7
addq $0x40, %rsp
testl %eax, %eax
je 0x3420a
movl 0x44(%rsp), %r13d
movl %r13d, %eax
subl %r15d, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl 0x40(%rsp), %ebx
movl %ebx, %eax
subl %r12d, %eax
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
addl %ecx, %edx
movq 0xf0(%rsp), %rax
movl (%rax), %eax
subl %r15d, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movq 0xf8(%rsp), %rax
movl (%rax), %eax
subl %r12d, %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
addl %ecx, %esi
cmpl %esi, %edx
movq %r12, %r9
movq %r15, %rdi
jae 0x34228
movzwl 0xc(%rbp), %r12d
testw %r12w, %r12w
movl 0x10(%rsp), %r15d
js 0x341ac
movzwl 0xe(%rbp), %eax
testl %eax, 0x108(%rsp)
je 0x3424a
movq 0xd8(%rsp), %rax
movzwl 0x1a(%rsp), %ecx
movw %cx, (%rax)
movq 0xe0(%rsp), %rax
movw %r14w, (%rax)
movq 0xe8(%rsp), %rax
orw $-0x1, (%rax)
movq 0xf0(%rsp), %rax
movl %r13d, (%rax)
movq 0xf8(%rsp), %rax
movl %ebx, (%rax)
movl 0x38(%rsp), %eax
movq 0x100(%rsp), %rcx
movl %eax, (%rcx)
movl 0x1c(%rsp), %r8d
movl 0x34(%rsp), %r13d
leaq 0x241aa8(%rip), %r12    # 0x275cb0
jmp 0x3423e
movq %r12, %r9
movq %r15, %rdi
leaq 0x241a99(%rip), %r12    # 0x275cb0
movl 0x1c(%rsp), %r8d
movl 0x10(%rsp), %r15d
movl 0x34(%rsp), %r13d
jmp 0x3423e
movl 0x34(%rsp), %r13d
leaq 0x241a7c(%rip), %r12    # 0x275cb0
movl 0x1c(%rsp), %r8d
movl 0x10(%rsp), %r15d
incl %r14d
addq $0x20, %rbp
jmp 0x3409d
movswl %r12w, %edi
movl %r13d, %esi
movl %ebx, %edx
leaq 0x6c(%rsp), %rcx
leaq 0x84(%rsp), %r8
callq 0x2373c
movl 0x38(%rsp), %eax
movl 0x6c(%rsp), %ecx
movl %ecx, 0x3c(%rsp)
cmpl %ecx, %eax
jle 0x342b1
cmpl 0x84(%rsp), %eax
jge 0x342b1
movswq 0x48(%rsp), %rax
movl %eax, %ecx
movl 0x34(%rsp), %r13d
movq 0x20(%rsp), %r9
movq 0x28(%rsp), %rdi
testl %ecx, %ecx
jle 0x34311
leaq -0x1(%rcx), %rdx
leaq 0x3f629c(%rip), %rsi    # 0x42a540
cmpw %r12w, -0x2(%rsi,%rcx,2)
movq %rdx, %rcx
jne 0x34295
jmp 0x34324
movq 0xd8(%rsp), %rcx
movzwl 0x1a(%rsp), %edx
movw %dx, (%rcx)
movq 0xe0(%rsp), %rcx
movw %r14w, (%rcx)
movq 0xe8(%rsp), %rcx
orw $-0x1, (%rcx)
movq 0xf0(%rsp), %rcx
movl %r13d, (%rcx)
movq 0xf8(%rsp), %rcx
movl %ebx, (%rcx)
movq 0x100(%rsp), %rcx
movl %eax, (%rcx)
movl 0x1c(%rsp), %r8d
movl 0x34(%rsp), %r13d
movq 0x20(%rsp), %r9
movq 0x28(%rsp), %rdi
jmp 0x34201
leal 0x1(%rax), %ecx
movl %ecx, 0x48(%rsp)
leaq 0x3f6221(%rip), %rcx    # 0x42a540
movw %r12w, (%rcx,%rax,2)
movl 0x1c(%rsp), %r8d
jmp 0x34201
leaq 0x3711db(%rip), %rax    # 0x3a5510
movq 0x70(%rsp), %rcx
leaq (%rax,%rcx,2), %rax
movl 0xd0(%rsp), %r15d
movl 0xc(%rsp), %r13d
movswq (%rax), %rbx
testq %rbx, %rbx
js 0x34b4d
imulq $0x2c, %rbx, %rbp
movzwl 0xc(%rbp,%r12), %r14d
movl %r13d, %eax
andl %r14d, %eax
orl 0x17d6ca(%rip), %eax    # 0x1b1a38
je 0x34802
addq %r12, %rbp
movl (%rbp), %r11d
movl 0x4(%rbp), %r10d
movl 0x8(%rbp), %esi
movl %r14d, %eax
shrl $0x4, %eax
andl $0x3, %eax
leaq 0x37b4a(%rip), %rcx     # 0x6bedc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x88(%rsp), %r8
testl %r8d, %r8d
sete %cl
subl %edi, %r11d
movl %r11d, %edx
movl 0x34(%rsp), %r15d
imull %r15d, %edx
subl %r9d, %r10d
movl %r10d, %eax
imull 0x1c(%rsp), %eax
addl %edx, %eax
setle %dl
orb %cl, %dl
jne 0x347fa
movl %esi, %r13d
movl %eax, %esi
movq %rsi, %rax
imulq 0x60(%rsp), %rax
cqto
idivq %r8
movq %rax, %rcx
addl 0x14(%rsp), %ecx
movl %ecx, 0x38(%rsp)
movswq 0xe(%rbp), %r9
leaq 0x3c63e6(%rip), %rax    # 0x3fa7e0
movswl (%rax,%r9,2), %eax
movzbl 0x15(%rbp), %edi
imull %edi, %eax
movsbl %r14b, %r8d
sarl $0x7, %r8d
leal (%rax,%rax), %edx
andl %r8d, %edx
addl %r13d, %edx
leaq 0x1ff642(%rip), %r8     # 0x233a60
movl (%r8,%r9,4), %r8d
testl $0xff0000, %r8d         # imm = 0xFF0000
je 0x3443c
shrl $0x10, %r8d
movsbl %r8b, %r8d
imull %r8d, %edi
shll $0x2, %edi
subl %edi, %edx
cmpl %edx, %ecx
movq 0x28(%rsp), %rdi
jg 0x347f0
shll $0x2, %eax
subl %eax, %edx
cmpl %edx, %ecx
jl 0x347f0
imull %r15d, %r10d
imull 0x1c(%rsp), %r11d
subl %r11d, %r10d
movslq %r10d, %rdi
movq %rdi, %rax
movq 0x58(%rsp), %r11
imulq %r11, %rax
cqto
movq 0x88(%rsp), %r14
idivq %r14
movq %rax, %r8
movq 0x50(%rsp), %r10
imulq %r10, %rdi
movq %rdi, %rax
cqto
idivq %r14
imull %r8d, %r8d
imull %eax, %eax
addl %r8d, %eax
leaq 0x3d4b7c(%rip), %rdx    # 0x409020
movswl (%rdx,%r9,2), %edx
movzbl 0x14(%rbp), %edi
imull %edx, %edi
imull %edi, %edi
shrl $0x7, %edi
cmpl %edi, %eax
jbe 0x3491a
movq 0x20(%rsp), %r9
movq 0x28(%rsp), %rdi
jmp 0x347f5
movl %esi, 0x10(%rsp)
movswq 0xe(%rbp), %r12
leaq 0x1ff583(%rip), %rax    # 0x233a60
movl (%rax,%r12,4), %r13d
movl %r13d, %eax
shrl $0x8, %eax
movsbl %al, %eax
movsbl 0x16(%rbp), %ecx
addl %eax, %ecx
movl %ecx, %edx
negl %edx
testb $0x4, %r14b
cmovel %ecx, %edx
movzwl 0x1c(%rbp), %ecx
movzbl 0x14(%rbp), %esi
movl %ecx, %eax
movl $0x7ff, %r8d            # imm = 0x7FF
andl %r8d, %eax
leaq 0x39383b(%rip), %r9     # 0x3c7d50
movswq (%r9,%rax,2), %rax
imulq %rsi, %rax
addl $0x600, %ecx            # imm = 0x600
andl %r8d, %ecx
movswq (%r9,%rcx,2), %r15
imulq %rsi, %r15
leaq 0x3d4ae9(%rip), %rcx    # 0x409020
movq %r12, 0x70(%rsp)
movswq (%rcx,%r12,2), %rcx
movl %ecx, %esi
sarl %esi
addl %edx, %esi
movslq %esi, %rdx
movq %rdx, %rsi
imulq %rax, %rsi
shrq $0x10, %rsi
subl %esi, %r11d
imulq %rcx, %rax
shrq $0x10, %rax
addl %r11d, %eax
imulq %r15, %rdx
shrq $0x10, %rdx
subl %edx, %r10d
imulq %rcx, %r15
shrq $0x10, %r15
addl %r10d, %r15d
testb $0x40, %r14b
je 0x34693
movl %r11d, %ecx
subl %edi, %ecx
movl %r15d, %edx
movq 0x20(%rsp), %r8
subl %r8d, %edx
imull %ecx, %edx
movl %eax, %ecx
subl %edi, %ecx
movl %r10d, %esi
subl %r8d, %esi
imull %ecx, %esi
cmpl %esi, %edx
jge 0x34693
movl 0xc(%rsp), %r13d
movq 0x20(%rsp), %r9
leaq 0x2416f4(%rip), %r12    # 0x275cb0
jmp 0x347fa
testl %r15d, %r15d
je 0x34802
movl %esi, 0x38(%rsp)
movl %esi, %eax
subl 0x14(%rsp), %eax
movl %eax, %ecx
xorl %r15d, %ecx
js 0x34802
testb $0x40, %r14b
je 0x345fb
cmpl 0x14(%rsp), %esi
setl %cl
testb $0x8, %r14b
sete %dl
cmpb %cl, %dl
je 0x34802
movl %esi, 0x10(%rsp)
movl %r15d, %r8d
movslq %eax, %rcx
movq %rcx, %rax
imulq 0x58(%rsp), %rax
cqto
movq %r9, %r15
movq 0x60(%rsp), %r9
idivq %r9
movq %rax, %rsi
leal (%rax,%rdi), %r13d
movl %r13d, 0x44(%rsp)
imulq 0x50(%rsp), %rcx
movq %rcx, %rax
cqto
idivq %r9
movq %r15, %r9
leal (%rax,%r15), %edx
movl %esi, %ecx
negl %ecx
cmovsl %esi, %ecx
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
movl %edx, 0x40(%rsp)
addl %ecx, %esi
movq 0xf0(%rsp), %rax
movl (%rax), %eax
subl %edi, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movq 0xf8(%rsp), %rax
movl (%rax), %eax
subl %r9d, %eax
movl %eax, %edi
negl %edi
cmovsl %eax, %edi
addl %ecx, %edi
cmpl %edi, %esi
jbe 0x34812
movq 0x28(%rsp), %rdi
movl 0xc(%rsp), %r13d
movl %r8d, %r15d
jmp 0x34802
movl %r13d, 0x80(%rsp)
subq $0x8, %rsp
movq %rdi, %r13
movq 0x28(%rsp), %rsi
movl 0x1c(%rsp), %edx
movl 0x3c(%rsp), %ecx
movl 0x24(%rsp), %r8d
movl 0xd8(%rsp), %r9d
leaq 0x40(%rsp), %r12
pushq %r12
leaq 0x50(%rsp), %r12
pushq %r12
leaq 0x5c(%rsp), %r12
pushq %r12
pushq %r15
pushq %rax
pushq %r10
pushq %r11
callq 0x34bc7
addq $0x40, %rsp
testl %eax, %eax
je 0x347d2
movl 0x44(%rsp), %r8d
movl %r8d, %eax
subl %r13d, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl 0x40(%rsp), %edx
movl %edx, %eax
movq 0x20(%rsp), %r9
subl %r9d, %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
addl %ecx, %esi
movq 0xf0(%rsp), %rax
movl (%rax), %eax
subl %r13d, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movq 0xf8(%rsp), %rax
movl (%rax), %eax
subl %r9d, %eax
movl %eax, %edi
negl %edi
cmovsl %eax, %edi
addl %ecx, %edi
cmpl %edi, %esi
movq %r13, %rdi
movl 0xd0(%rsp), %r15d
movl 0xc(%rsp), %r13d
leaq 0x24155b(%rip), %r12    # 0x275cb0
ja 0x34802
movq %r9, %r10
leaq 0x3c607b(%rip), %rax    # 0x3fa7e0
movq 0x70(%rsp), %rcx
movswl (%rax,%rcx,2), %eax
movzbl 0x15(%rbp), %ecx
imull %ecx, %eax
movsbl %r14b, %esi
sarl $0x7, %esi
leal (%rax,%rax), %r9d
andl %esi, %r9d
addl 0x10(%rsp), %r9d
movl 0x80(%rsp), %esi
testl $0xff0000, %esi         # imm = 0xFF0000
je 0x347a6
shll $0x8, %esi
sarl $0x16, %esi
andl $-0x4, %esi
imull %ecx, %esi
subl %esi, %r9d
movl 0x38(%rsp), %ecx
cmpl %r9d, %ecx
movl %r9d, 0x3c(%rsp)
jge 0x349af
shll $0x2, %eax
movl %r9d, %esi
subl %eax, %esi
cmpl %esi, %ecx
movl 0xc(%rsp), %r13d
movq %r10, %r9
jg 0x34afa
jmp 0x34802
movq 0x20(%rsp), %r9
movq %r13, %rdi
movl 0xd0(%rsp), %r15d
movl 0xc(%rsp), %r13d
leaq 0x2414c2(%rip), %r12    # 0x275cb0
jmp 0x34802
movq 0x20(%rsp), %r9
movl 0xc(%rsp), %r13d
movl 0xd0(%rsp), %r15d
leaq 0x37ad17(%rip), %rax    # 0x3af520
leaq (%rax,%rbx,2), %rax
jmp 0x3434b
movswq 0xe(%rbp), %rax
leaq 0x1ff242(%rip), %rcx    # 0x233a60
movl (%rcx,%rax,4), %ecx
movl %ecx, %esi
shrl $0x8, %esi
movsbl %sil, %esi
movsbl 0x16(%rbp), %edi
addl %esi, %edi
shrl $0x10, %ecx
movsbl %cl, %ecx
movsbl 0x17(%rbp), %esi
addl %ecx, %esi
movl %r13d, %r8d
movl %edi, %r13d
negl %r13d
testb $0x4, %r14b
cmovel %edi, %r13d
movl %esi, %ecx
negl %ecx
testb $0x8, %r14b
cmovel %esi, %ecx
movswq 0x1c(%rbp), %rdi
leal 0x200(%rdi), %esi
andl $0x7ff, %esi            # imm = 0x7FF
leaq 0x3934e0(%rip), %r9     # 0x3c7d50
movswq (%r9,%rsi,2), %rsi
movswq (%r9,%rdi,2), %r14
leaq 0x3d479f(%rip), %rdi    # 0x409020
movswq (%rdi,%rax,2), %r12
movzbl 0x14(%rbp), %r9d
leaq 0x3c5f4e(%rip), %rdi    # 0x3fa7e0
movswq (%rdi,%rax,2), %r15
movzbl 0x15(%rbp), %edi
movl %r12d, %eax
sarl %eax
addl %r13d, %eax
movslq %eax, %r13
imulq %r9, %r13
movl %r15d, %eax
sarl %eax
addl %ecx, %eax
cltq
imulq %rdi, %rax
movq %r13, %rbp
imulq %r14, %rbp
movq %rax, %rcx
imulq %rsi, %rcx
addq %rbp, %rcx
shrq $0x10, %rcx
subl %r8d, %ecx
addl %r11d, %ecx
imulq %r14, %rax
imulq %rsi, %r13
subq %r13, %rax
shrq $0x10, %rax
subl %edx, %eax
addl %r10d, %eax
imulq %r12, %r9
movq %r9, %r11
imulq %r14, %r11
shrq $0x10, %r11
movl %ecx, %r10d
subl %r11d, %r10d
imulq %rsi, %r9
shrq $0x10, %r9
leal (%rax,%r9), %r11d
movl %r11d, %ebp
xorl %eax, %ebp
js 0x349bc
xorl %r9d, %r9d
jmp 0x349e9
movq %rsi, %rax
imulq %r11, %rax
cqto
idivq %r14
movq %rax, %rdi
movq 0x28(%rsp), %r11
leal (%rax,%r11), %r8d
movl %r8d, 0x44(%rsp)
imulq %r10, %rsi
movq %rsi, %rax
cqto
idivq %r14
movq 0x20(%rsp), %r10
leal (%rax,%r10), %edx
movl %edi, %esi
negl %esi
cmovsl %edi, %esi
movl %eax, %edi
negl %edi
cmovsl %eax, %edi
movl %edx, 0x40(%rsp)
addl %esi, %edi
movq 0xf0(%rsp), %rax
movl (%rax), %eax
subl %r11d, %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
movq 0xf8(%rsp), %rax
movl (%rax), %eax
subl %r10d, %eax
movl %eax, %r9d
negl %r9d
cmovsl %eax, %r9d
addl %esi, %r9d
cmpl %r9d, %edi
movq %r11, %rdi
movq %r10, %r9
movl 0xc(%rsp), %r13d
movl 0xd0(%rsp), %r15d
ja 0x34802
jmp 0x34afa
movl 0xc(%rsp), %r13d
movq %r10, %r9
jmp 0x34802
movl %r10d, %ebp
xorl %ecx, %ebp
js 0x349cb
testl %ecx, %ecx
setns %r9b
jmp 0x349e9
movl %r11d, %ebp
imull %ecx, %ebp
movl %r10d, %r12d
imull %eax, %r12d
cmpl %r12d, %ebp
setl %bpl
testl %r9d, %r9d
setg %r9b
xorb %bpl, %r9b
movl 0xd0(%rsp), %r13d
imulq %r15, %rdi
imulq %rdi, %rsi
shrq $0x10, %rsi
movl %r10d, %ebp
subl %esi, %ebp
imulq %r14, %rdi
shrq $0x10, %rdi
movl %r11d, %r14d
subl %edi, %r14d
movl %r14d, %r15d
xorl %r11d, %r15d
leaq 0x241293(%rip), %r12    # 0x275cb0
jns 0x34a58
movl %ebp, %r15d
xorl %r10d, %r15d
js 0x34a36
testl %r10d, %r10d
setns %r10b
xorb %r9b, %r10b
movl %r10d, %r9d
jmp 0x34a58
imull %r14d, %r10d
movl %ebp, %r15d
imull %r11d, %r15d
cmpl %r15d, %r10d
setl %r10b
cmpl %r14d, %r11d
setl %r11b
xorb %r9b, %r11b
xorb %r10b, %r11b
movl %r11d, %r9d
movl %ecx, %r10d
subl %esi, %r10d
movl %eax, %esi
subl %edi, %esi
movl %r14d, %edi
xorl %esi, %edi
movl %r13d, %r15d
jns 0x34aa1
movl %ebp, %edi
xorl %r10d, %edi
js 0x34a81
testl %ebp, %ebp
setns %dil
xorb %r9b, %dil
movl %edi, %r9d
jmp 0x34aa1
imull %esi, %ebp
movl %r14d, %edi
imull %r10d, %edi
cmpl %edi, %ebp
setl %dil
cmpl %esi, %r14d
setl %r11b
xorb %r9b, %r11b
xorb %dil, %r11b
movl %r11d, %r9d
movl %esi, %edi
xorl %eax, %edi
js 0x34ab2
movl 0x10(%rsp), %eax
movl %eax, %ecx
testb %r9b, %r9b
jmp 0x34ae5
movl %r10d, %edi
xorl %ecx, %edi
js 0x34aca
testl %r10d, %r10d
setns %al
xorb %r9b, %al
movl 0x10(%rsp), %eax
movl %eax, %ecx
jmp 0x34ae5
imull %eax, %r10d
imull %esi, %ecx
cmpl %ecx, %r10d
setl %cl
cmpl %eax, %esi
setl %al
xorb %cl, %al
movl 0x10(%rsp), %ecx
cmpb %r9b, %al
movq 0x20(%rsp), %r9
movq 0x28(%rsp), %rdi
movl 0xc(%rsp), %r13d
je 0x34802
movq 0xd8(%rsp), %rax
movq %r9, %rsi
movzwl 0x1a(%rsp), %r9d
movw %r9w, (%rax)
movq %rsi, %r9
movq 0xe0(%rsp), %rax
orw $-0x1, (%rax)
movq 0xe8(%rsp), %rax
movw %bx, (%rax)
movq 0xf0(%rsp), %rax
movl %r8d, (%rax)
movq 0xf8(%rsp), %rax
movl %edx, (%rax)
movq 0x100(%rsp), %rax
movl %ecx, (%rax)
jmp 0x34802
movq %r9, %r8
movl 0x3c(%rsp), %r10d
movl %r10d, 0x6c(%rsp)
movl 0x4c(%rsp), %eax
incl %eax
jmp 0x34ba3
movq 0x20(%rsp), %r8
movq 0x28(%rsp), %rdi
movl 0x4c(%rsp), %eax
leaq 0x241139(%rip), %r12    # 0x275cb0
movl 0x3c(%rsp), %r10d
movl %ebx, %r15d
jmp 0x34ba3
movq 0x20(%rsp), %r8
movq 0x28(%rsp), %rdi
movl 0xd0(%rsp), %r15d
movl 0x4c(%rsp), %eax
leaq 0x241112(%rip), %r12    # 0x275cb0
movl 0x3c(%rsp), %r10d
cmpw 0x48(%rsp), %ax
jl 0x33bbe
xorl %eax, %eax
jmp 0x34bb5
pushq $-0x1
popq %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq