// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: drawvox
static void drawvox(int dasprx, int daspry, int dasprz, int dasprang,
		  int daxscale, int dayscale, unsigned char daindex,
		  signed char dashade, unsigned char dapal, int *daumost, int *dadmost)
{
	int i, j, k, x, y, syoff, ggxstart, ggystart, nxoff;
	int cosang, sinang, sprcosang, sprsinang, backx, backy, gxinc, gyinc;
	int daxsiz, daysiz, dazsiz, daxpivot, daypivot, dazpivot;
	int daxscalerecip, dayscalerecip, cnt, gxstart, gystart, odayscale;
	int l1, l2, xyvoxoffs, *longptr;
	intptr_t slabxoffs;
	int lx, rx, nx, ny, x1=0, y1=0, z1, x2=0, y2=0, z2, yplc, yinc=0;
	int yoff, xs=0, ys=0, xe, ye, xi=0, yi=0, cbackx, cbacky, dagxinc, dagyinc;
	short *shortptr;
	unsigned char *voxptr, *voxend, *davoxptr, oand, oand16, oand32;

	(void)dazsiz;

	cosang = sintable[(globalang+512)&2047];
	sinang = sintable[globalang&2047];
	sprcosang = sintable[(dasprang+512)&2047];
	sprsinang = sintable[dasprang&2047];

	i = klabs(dmulscale6(dasprx-globalposx,cosang,daspry-globalposy,sinang));
	j = (int)(getpalookup((int)mulscale21(globvis,i),(int)dashade)<<8);
	setupdrawslab(ylookup[1], palookup[dapal]+j);
	j = 1310720;
	j *= min(daxscale,dayscale); j >>= 6;  //New hacks (for sized-down voxels)
	for(k=0;k<MAXVOXMIPS;k++)
	{
		if (i < j) { i = k; break; }
		j <<= 1;
	}
	if (k >= MAXVOXMIPS) i = MAXVOXMIPS-1;

	if (novoxmips) i = 0;
	davoxptr = (unsigned char *)voxoff[daindex][i];
	if (!davoxptr && i > 0) { davoxptr = (unsigned char *)voxoff[daindex][0]; i = 0; }
	if (!davoxptr) return;

	if (voxscale[daindex] == 65536)
		{ daxscale <<= (i+8); dayscale <<= (i+8); }
	else
	{
		daxscale = mulscale8(daxscale<<i,voxscale[daindex]);
		dayscale = mulscale8(dayscale<<i,voxscale[daindex]);
	}

	odayscale = dayscale;
	daxscale = mulscale16(daxscale,xyaspect);
	daxscale = scale(daxscale,xdimenscale,xdimen<<8);
	dayscale = scale(dayscale,mulscale16(xdimenscale,viewingrangerecip),xdimen<<8);

	daxscalerecip = (1<<30)/daxscale;
	dayscalerecip = (1<<30)/dayscale;

	longptr = (int *)davoxptr;
	daxsiz = B_LITTLE32(longptr[0]); daysiz = B_LITTLE32(longptr[1]); dazsiz = B_LITTLE32(longptr[2]);
	daxpivot = B_LITTLE32(longptr[3]); daypivot = B_LITTLE32(longptr[4]); dazpivot = B_LITTLE32(longptr[5]);
	davoxptr += (6<<2);

	x = mulscale16(globalposx-dasprx,daxscalerecip);
	y = mulscale16(globalposy-daspry,daxscalerecip);
	backx = ((dmulscale10(x,sprcosang,y,sprsinang)+daxpivot)>>8);
	backy = ((dmulscale10(y,sprcosang,x,-sprsinang)+daypivot)>>8);
	cbackx = min(max(backx,0),daxsiz-1);
	cbacky = min(max(backy,0),daysiz-1);

	sprcosang = mulscale14(daxscale,sprcosang);
	sprsinang = mulscale14(daxscale,sprsinang);

	x = (dasprx-globalposx) - dmulscale18(daxpivot,sprcosang,daypivot,-sprsinang);
	y = (daspry-globalposy) - dmulscale18(daypivot,sprcosang,daxpivot,sprsinang);

	cosang = mulscale16(cosang,dayscalerecip);
	sinang = mulscale16(sinang,dayscalerecip);

	gxstart = y*cosang - x*sinang;
	gystart = x*cosang + y*sinang;
	gxinc = dmulscale10(sprsinang,cosang,sprcosang,-sinang);
	gyinc = dmulscale10(sprcosang,cosang,sprsinang,sinang);

	x = 0; y = 0; j = max(daxsiz,daysiz);
	for(i=0;i<=j;i++)
	{
		ggxinc[i] = x; x += gxinc;
		ggyinc[i] = y; y += gyinc;
	}

	if ((klabs(globalposz-dasprz)>>10) >= klabs(odayscale)) return;
	syoff = divscale21(globalposz-dasprz,odayscale) + (dazpivot<<7);
	yoff = ((klabs(gxinc)+klabs(gyinc))>>1);
	longptr = (int *)davoxptr;
	xyvoxoffs = ((daxsiz+1)<<2);

	for(cnt=0;cnt<8;cnt++)
	{
		switch(cnt)
		{
			case 0: xs = 0;        ys = 0;        xi = 1;  yi = 1;  break;
			case 1: xs = daxsiz-1; ys = 0;        xi = -1; yi = 1;  break;
			case 2: xs = 0;        ys = daysiz-1; xi = 1;  yi = -1; break;
			case 3: xs = daxsiz-1; ys = daysiz-1; xi = -1; yi = -1; break;
			case 4: xs = 0;        ys = cbacky;   xi = 1;  yi = 2;  break;
			case 5: xs = daxsiz-1; ys = cbacky;   xi = -1; yi = 2;  break;
			case 6: xs = cbackx;   ys = 0;        xi = 2;  yi = 1;  break;
			case 7: xs = cbackx;   ys = daysiz-1; xi = 2;  yi = -1; break;
		}
		xe = cbackx; ye = cbacky;
		if (cnt < 4)
		{
			if ((xi < 0) && (xe >= xs)) continue;
			if ((xi > 0) && (xe <= xs)) continue;
			if ((yi < 0) && (ye >= ys)) continue;
			if ((yi > 0) && (ye <= ys)) continue;
		}
		else
		{
			if ((xi < 0) && (xe > xs)) continue;
			if ((xi > 0) && (xe < xs)) continue;
			if ((yi < 0) && (ye > ys)) continue;
			if ((yi > 0) && (ye < ys)) continue;
			xe += xi; ye += yi;
		}

		i = ksgn(ys-backy)+ksgn(xs-backx)*3+4;
		switch(i)
		{
			case 6: case 7: x1 = 0; y1 = 0; break;
			case 8: case 5: x1 = gxinc; y1 = gyinc; break;
			case 0: case 3: x1 = gyinc; y1 = -gxinc; break;
			case 2: case 1: x1 = gxinc+gyinc; y1 = gyinc-gxinc; break;
		}
		switch(i)
		{
			case 2: case 5: x2 = 0; y2 = 0; break;
			case 0: case 1: x2 = gxinc; y2 = gyinc; break;
			case 8: case 7: x2 = gyinc; y2 = -gxinc; break;
			case 6: case 3: x2 = gxinc+gyinc; y2 = gyinc-gxinc; break;
		}
		oand = pow2char[(xs<backx)+0]+pow2char[(ys<backy)+2];
		oand16 = oand+16;
		oand32 = oand+32;

		if (yi > 0) { dagxinc = gxinc; dagyinc = mulscale16(gyinc,viewingrangerecip); }
		else { dagxinc = -gxinc; dagyinc = -mulscale16(gyinc,viewingrangerecip); }

			//Fix for non 90 degree viewing ranges
		nxoff = mulscale16(x2-x1,viewingrangerecip);
		x1 = mulscale16(x1,viewingrangerecip);

		ggxstart = gxstart+ggyinc[ys];
		ggystart = gystart-ggxinc[ys];

		for(x=xs;x!=xe;x+=xi)
		{
			slabxoffs = (intptr_t)&davoxptr[B_LITTLE32(longptr[x])];
			shortptr = (short *)&davoxptr[((x*(daysiz+1))<<1)+xyvoxoffs];

			nx = mulscale16(ggxstart+ggxinc[x],viewingrangerecip)+x1;
			ny = ggystart+ggyinc[x];
			for(y=ys;y!=ye;y+=yi,nx+=dagyinc,ny-=dagxinc)
			{
				if ((ny <= nytooclose) || (ny >= nytoofar)) continue;
				voxptr = (unsigned char *)(B_LITTLE16(shortptr[y])+slabxoffs);
				voxend = (unsigned char *)(B_LITTLE16(shortptr[y+1])+slabxoffs);
				if (voxptr == voxend) continue;

				lx = mulscale32(nx>>3,distrecip[(ny+y1)>>14])+halfxdimen;
				if (lx < 0) lx = 0;
				rx = mulscale32((nx+nxoff)>>3,distrecip[(ny+y2)>>14])+halfxdimen;
				if (rx > xdimen) rx = xdimen;
				if (rx <= lx) continue;
				rx -= lx;

				l1 = distrecip[(ny-yoff)>>14];
				l2 = distrecip[(ny+yoff)>>14];
				for(;voxptr<voxend;voxptr+=voxptr[1]+3)
				{
					j = (voxptr[0]<<15)-syoff;
					if (j < 0)
					{
						k = j+(voxptr[1]<<15);
						if (k < 0)
						{
							if ((voxptr[2]&oand32) == 0) continue;
							z2 = mulscale32(l2,k) + globalhoriz;     //Below slab
						}
						else
						{
							if ((voxptr[2]&oand) == 0) continue;    //Middle of slab
							z2 = mulscale32(l1,k) + globalhoriz;
						}
						z1 = mulscale32(l1,j) + globalhoriz;
					}
					else
					{
						if ((voxptr[2]&oand16) == 0) continue;
						z1 = mulscale32(l2,j) + globalhoriz;        //Above slab
						z2 = mulscale32(l1,j+(voxptr[1]<<15)) + globalhoriz;
					}

					if (voxptr[1] == 1)
					{
						yplc = 0; yinc = 0;
						if (z1 < daumost[lx]) z1 = daumost[lx];
					}
					else
					{
						if (z2-z1 >= 1024) yinc = divscale16(voxptr[1],z2-z1);
						else if (z2 > z1) yinc = (lowrecip[z2-z1]*voxptr[1]>>8);
						if (z1 < daumost[lx]) { yplc = yinc*(daumost[lx]-z1); z1 = daumost[lx]; } else yplc = 0;
					}
					if (z2 > dadmost[lx]) z2 = dadmost[lx];
					z2 -= z1; if (z2 <= 0) continue;

					drawslab(rx,yplc,z2,yinc,&voxptr[3],(void *)(ylookup[z1]+lx+frameoffset));
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movl %r9d, %r14d
movl %r8d, %r12d
movl %edx, 0x30(%rsp)
movzbl 0x1a0(%rsp), %eax
movzwl 0x38ecda(%rip), %r10d   # 0x3ced30
movl $0x200, %edx            # imm = 0x200
leal (%r10,%rdx), %r8d
movl $0x7ff, %r9d            # imm = 0x7FF
andl %r9d, %r8d
leaq 0x38ece1(%rip), %r15    # 0x3ced50
movswq (%r15,%r8,2), %rbx
andl %r9d, %r10d
movswq (%r15,%r10,2), %r11
addl %ecx, %edx
andl %r9d, %edx
andl %r9d, %ecx
movslq 0x1fa9c5(%rip), %r9     # 0x23aa50
movl %edi, 0x90(%rsp)
movslq %edi, %r8
subq %r9, %r8
movslq 0x1fa9b5(%rip), %r10    # 0x23aa54
movl %esi, 0x14(%rsp)
movslq %esi, %r9
subq %r10, %r9
movq %rbx, 0x68(%rsp)
imulq %rbx, %r8
movq %r11, 0x50(%rsp)
imulq %r11, %r9
addq %r8, %r9
shrq $0x6, %r9
movl %r9d, %ebx
negl %ebx
cmovsl %r9d, %ebx
movsbl 0x198(%rsp), %esi
movslq 0x3d4756(%rip), %r8     # 0x414830
imulq %rbx, %r8
shrq $0x15, %r8
sarl $0x8, %r8d
addl %esi, %r8d
xorl %r13d, %r13d
testl %r8d, %r8d
cmovlel %r13d, %r8d
movswl 0x3d472e(%rip), %esi    # 0x414828
decl %esi
cmpl %esi, %r8d
cmovll %r8d, %esi
shll $0x8, %esi
leaq 0x3589d3(%rip), %r8     # 0x398ae0
movslq %esi, %rsi
addq (%r8,%rax,8), %rsi
movswq (%r15,%rdx,2), %rbp
movswq (%r15,%rcx,2), %r15
movl 0x3d6b80(%rip), %edi    # 0x416ca4
callq 0x701af
cmpl %r14d, %r12d
movl %r14d, %eax
cmovll %r12d, %eax
shll $0xc, %eax
leal (%rax,%rax,4), %eax
cmpl %eax, %ebx
jl 0x4014a
addl %eax, %eax
incl %r13d
cmpl $0x5, %r13d
jne 0x40139
jmp 0x40150
cmpl $0x5, %r13d
jb 0x40156
movl $0x4, %r13d
xorl %eax, %eax
cmpl $0x0, 0x1788a1(%rip)    # 0x1b8a00
cmovnel %eax, %r13d
movzbl 0x190(%rsp), %eax
leaq (%rax,%rax,4), %rcx
leaq 0x31e95a(%rip), %rdx    # 0x35ead0
leaq (%rdx,%rcx,8), %rsi
movq (%rsi,%r13,8), %r8
testq %r8, %r8
setne %sil
testl %r13d, %r13d
sete %dil
orb %sil, %dil
jne 0x40198
movq (%rdx,%rcx,8), %r8
xorl %r13d, %r13d
movq %r8, 0x8(%rsp)
testq %r8, %r8
je 0x40d25
leaq 0x354923(%rip), %rcx    # 0x394ad0
movslq (%rcx,%rax,4), %rax
cmpq $0x10000, %rax          # imm = 0x10000
jne 0x401c8
addb $0x8, %r13b
movl %r13d, %ecx
shll %cl, %r12d
shll %cl, %r14d
jmp 0x401e7
movl %r13d, %ecx
shll %cl, %r12d
movslq %r12d, %r12
imulq %rax, %r12
shll %cl, %r14d
shrq $0x8, %r12
movslq %r14d, %r14
imulq %rax, %r14
shrq $0x8, %r14
movslq 0x31d6ca(%rip), %rax    # 0x35d8b8
movslq %r12d, %rcx
imulq %rax, %rcx
movslq 0x23b89c(%rip), %rsi    # 0x27ba98
movl 0x6462e(%rip), %edx     # 0xa4830
shll $0x8, %edx
shrq $0x10, %rcx
movslq %ecx, %rax
imulq %rsi, %rax
movslq %edx, %rdi
cqto
idivq %rdi
movq %rax, %rcx
movslq 0x38eb16(%rip), %rax    # 0x3ced38
movslq %r14d, %rdx
imulq %rsi, %rax
shrq $0x10, %rax
cltq
movq %rdx, 0x28(%rsp)
imulq %rdx, %rax
cqto
idivq %rdi
movq %rax, %rsi
xorl %r11d, %r11d
movl $0x40000000, %eax       # imm = 0x40000000
xorl %edx, %edx
idivl %ecx
movl %eax, %edi
movl $0x40000000, %eax       # imm = 0x40000000
xorl %edx, %edx
idivl %esi
movq 0x8(%rsp), %r13
movl (%r13), %r10d
movslq 0xc(%r13), %r12
movslq 0x10(%r13), %rdx
movl 0x1fa7e2(%rip), %esi    # 0x23aa50
movl %esi, 0xa0(%rsp)
subl 0x90(%rsp), %esi
movslq %esi, %rbx
movslq %edi, %r9
movl 0x1fa7cc(%rip), %esi    # 0x23aa54
movl %esi, %edi
subl 0x14(%rsp), %edi
movslq %edi, %rdi
shlq $0x10, %r9
imulq %r9, %rbx
sarq $0x20, %rbx
movq %rbx, %r8
imulq %rbp, %r8
imulq %rdi, %r9
sarq $0x20, %r9
movq %r9, %rdi
imulq %r15, %rdi
addq %r8, %rdi
shrq $0xa, %rdi
movq %r12, 0xa8(%rsp)
addl %r12d, %edi
sarl $0x8, %edi
imulq %rbp, %r9
imulq %r15, %rbx
subq %rbx, %r9
shrq $0xa, %r9
movq %rdx, 0x88(%rsp)
addl %edx, %r9d
sarl $0x8, %r9d
testl %edi, %edi
movl $0x0, %r8d
movq %rdi, 0x98(%rsp)
cmovgl %edi, %r8d
leal -0x1(%r10), %edi
cmpl %edi, %r8d
movl %edi, 0x78(%rsp)
movl %r8d, 0xb8(%rsp)
cmovll %r8d, %edi
movq %rdi, 0x48(%rsp)
testl %r9d, %r9d
movl $0x0, %edi
movq %r9, 0xe8(%rsp)
cmovgl %r9d, %edi
movl 0x4(%r13), %ebx
leal -0x1(%rbx), %r8d
cmpl %r8d, %edi
movl %r8d, 0x3c(%rsp)
cmovgel %r8d, %edi
movq %rdi, 0x40(%rsp)
movslq %ecx, %rcx
imulq %rcx, %r15
imulq %rcx, %rbp
cltq
movq 0x68(%rsp), %rdi
imulq %rax, %rdi
movq 0x50(%rsp), %rcx
imulq %rax, %rcx
shrq $0xe, %r15
shrq $0xe, %rbp
movslq %ebp, %r12
movq %rcx, %rdx
shrq $0x10, %rdx
movq %rdi, 0x68(%rsp)
movq %rdi, %rax
sarq $0x10, %rax
movslq %r15d, %rdi
movq %rax, %r8
imulq %rdi, %r8
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
movq %rdx, %r9
imulq %rbp, %r9
sarq $0x20, %r9
imulq %r12, %r9
addq %r8, %r9
imulq %r12, %rax
sarq $0x10, %rcx
imulq %rdi, %rcx
addq %rax, %rcx
shrq $0xa, %r9
shrq $0xa, %rcx
cmpl %ebx, %r10d
movq %rbx, %rax
movq %rbx, 0xd8(%rsp)
movq %r10, 0xd0(%rsp)
cmovgl %r10d, %eax
movl 0x14(%r13), %r10d
testl %eax, %eax
js 0x4040c
incl %eax
leaq 0x56d7f8(%rip), %rbx    # 0x5adbe0
leaq 0x56dc01(%rip), %rbp    # 0x5adff0
xorl %r8d, %r8d
xorl %r13d, %r13d
movl %r11d, (%r8,%rbx)
addl %r9d, %r11d
movl %r13d, (%r8,%rbp)
addl %ecx, %r13d
addq $0x4, %r8
decq %rax
jne 0x403f5
movq %r9, 0x20(%rsp)
movq %rcx, 0x50(%rsp)
movslq 0x22b643(%rip), %rax    # 0x26ba60
movslq 0x30(%rsp), %r8
subq %r8, %rax
movl %eax, %r8d
negl %r8d
cmovsl %eax, %r8d
shrl $0xa, %r8d
movl %r14d, %r11d
negl %r11d
cmovsl %r14d, %r11d
cmpl %r11d, %r8d
movq 0x98(%rsp), %r14
jae 0x40d25
movl %r10d, %r9d
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
imulq %rcx, %r15
sarq $0x20, %r15
movq %r12, %r8
movq 0xa8(%rsp), %rcx
imulq %rcx, %r8
movq %rdx, %r10
movq 0x88(%rsp), %rdx
imulq %rdx, %r15
addq %r8, %r15
imulq %rdx, %r12
imulq %rcx, %rdi
addq %r12, %rdi
shrq $0x12, %r15
shrq $0x12, %rdi
movl 0xa0(%rsp), %edx
addl %r15d, %edx
addl %edi, %esi
movq 0x68(%rsp), %r8
shrq $0x10, %r8
movl 0x90(%rsp), %ecx
subl %edx, %ecx
movl 0x14(%rsp), %edi
subl %esi, %edi
movl %edi, %esi
imull %r8d, %esi
movl %ecx, %edx
imull %r10d, %edx
subl %edx, %esi
imull %r8d, %ecx
imull %r10d, %edi
addl %ecx, %edi
movl %edi, 0x14(%rsp)
addq $0x18, 0x8(%rsp)
shlq $0x15, %rax
cqto
idivq 0x28(%rsp)
movq 0x20(%rsp), %rdi
movl %edi, %ebp
negl %ebp
movl %edi, %ecx
cmovnsl %ebp, %ecx
movq 0x50(%rsp), %rdx
movl %edx, %r8d
negl %r8d
cmovsl %edx, %r8d
addl %ecx, %r8d
shrl %r8d
movq %r8, 0x108(%rsp)
movq 0xd0(%rsp), %rcx
leal 0x4(,%rcx,4), %ecx
movl %ecx, 0xc4(%rsp)
leal (%rdi,%rdx), %ecx
movl %ecx, 0x74(%rsp)
movl %edx, %ecx
subl %edi, %ecx
movl %ecx, 0x70(%rsp)
movslq %edx, %rcx
movq %rcx, 0xe0(%rsp)
movq 0xd8(%rsp), %rcx
leal 0x2(,%rcx,2), %ecx
movl %ecx, 0xc0(%rsp)
shll $0x7, %r9d
addl %eax, %r9d
negl %r9d
movslq %esi, %rax
movq %rax, 0x100(%rsp)
xorl %r11d, %r11d
movq $0x0, 0x60(%rsp)
movl $0x0, 0x4(%rsp)
movq $0x0, 0x58(%rsp)
xorl %eax, %eax
xorl %esi, %esi
movl %r9d, 0x80(%rsp)
movl %ebp, 0xb4(%rsp)
movl $0x2, %edi
movl %esi, %ecx
leaq 0x369d4(%rip), %rdx     # 0x76f80
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl %esi, %edx
xorl %r8d, %r8d
movl %esi, 0xbc(%rsp)
movl %esi, %r12d
movl $0x1, %esi
jmpq *%rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl 0x3c(%rsp), %r12d
cmpl $0x0, 0x48(%rsp)
movq 0x8(%rsp), %rbx
movq 0x20(%rsp), %r15
jle 0x40ced
xorl %r13d, %r13d
movl $0x1, %ecx
jmp 0x40656
cmpl $0x0, 0xd0(%rsp)
movq 0x8(%rsp), %rbx
movq 0x20(%rsp), %r15
jle 0x40ced
movl $0x2, %esi
movl $0x1, %edi
xorl %r13d, %r13d
movq 0x40(%rsp), %rcx
movl %ecx, %r12d
jmp 0x406db
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl 0x3c(%rsp), %r8d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %edx, %esi
movl %r8d, %r12d
movl 0x78(%rsp), %edi
movl %edi, %r13d
cmpl %edi, 0xb8(%rsp)
movq 0x8(%rsp), %rbx
movq 0x20(%rsp), %r15
jge 0x40ced
testl %esi, %esi
jns 0x40665
cmpl %r12d, 0x40(%rsp)
jge 0x40ced
testl %esi, %esi
movq 0x50(%rsp), %r10
jle 0x40d01
movq 0x48(%rsp), %rdi
movl %edi, 0x18(%rsp)
movq 0x40(%rsp), %rdi
movl %edi, 0x1c(%rsp)
cmpl %r12d, %edi
jle 0x40ced
jmp 0x4070a
movl $0x2, %ecx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl 0x3c(%rsp), %r12d
movq 0x48(%rsp), %rdx
movl %edx, %r13d
jmp 0x406ba
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x40(%rsp), %rdx
movl %edx, %r12d
movl 0x78(%rsp), %r13d
movq 0x8(%rsp), %rbx
movq 0x20(%rsp), %r15
jmp 0x406ed
movq 0x48(%rsp), %rcx
movl %ecx, %r13d
xorl %r12d, %r12d
movq 0x8(%rsp), %rbx
movq 0x20(%rsp), %r15
movl %edi, %ecx
movl %esi, %edi
cmpl %r12d, 0xd8(%rsp)
jle 0x40ced
movq 0x48(%rsp), %rsi
addl %ecx, %esi
movl %esi, 0x18(%rsp)
movq 0x40(%rsp), %rsi
addl %edi, %esi
movl %esi, 0x1c(%rsp)
movl %edi, %esi
movq 0x50(%rsp), %r10
movq %rcx, 0x28(%rsp)
movl %r12d, %r8d
movl %r11d, 0x30(%rsp)
movl %r12d, 0x7c(%rsp)
subl 0xe8(%rsp), %r8d
movl %r8d, %edi
sarl $0x1f, %edi
testl %r8d, %r8d
movl $0x1, %r8d
cmovgl %r8d, %edi
movl %r13d, %r9d
subl %r14d, %r9d
movl %r9d, %r8d
sarl $0x1f, %r8d
andl $-0x3, %r8d
testl %r9d, %r9d
movl $0x3, %r9d
cmovgl %r9d, %r8d
leal (%r8,%rdi), %r9d
addl $0x4, %r9d
cmpl $0x8, %r9d
ja 0x40d18
leaq 0x36832(%rip), %r11     # 0x76fa0
movslq (%r11,%r9,4), %r9
addq %r11, %r9
movq 0xe0(%rsp), %rcx
jmpq *%r9
movl %r10d, %eax
movl %ebp, %r9d
jmp 0x407a6
xorl %eax, %eax
movq $0x0, 0x58(%rsp)
jmp 0x407ab
movl %r15d, %eax
movl %r10d, %r9d
jmp 0x407a6
movl 0x74(%rsp), %eax
movl 0x70(%rsp), %r9d
movq %r9, 0x58(%rsp)
addl %edi, %r8d
addl $0x4, %r8d
movl %eax, %edx
cmpl $0x8, %r8d
ja 0x40803
leaq 0x36803(%rip), %r9      # 0x76fc4
movslq (%r9,%r8,4), %rdi
addq %r9, %rdi
jmpq *%rdi
movl %r15d, 0x4(%rsp)
movq %r10, 0x60(%rsp)
jmp 0x40803
movl %r10d, 0x4(%rsp)
movl %ebp, %edi
jmp 0x407eb
movl 0x74(%rsp), %edi
movl %edi, 0x4(%rsp)
movl 0x70(%rsp), %edi
movq %rdi, 0x60(%rsp)
jmp 0x40803
movl $0x0, 0x4(%rsp)
movq $0x0, 0x60(%rsp)
xorl %edi, %edi
cmpl %r14d, %r13d
setl %r9b
xorl %r8d, %r8d
movl 0x7c(%rsp), %r14d
cmpl 0xe8(%rsp), %r14d
setl %r10b
movl %r13d, %r12d
movslq 0x38e50e(%rip), %r13    # 0x3ced38
movq %rcx, %r11
imulq %r13, %r11
shrq $0x10, %r11
movl %r11d, %eax
negl %eax
testl %esi, %esi
cmovgl %ebp, %r15d
movl %r15d, 0x68(%rsp)
cmovgl %r11d, %eax
movl %eax, 0x84(%rsp)
movslq %edx, %rax
imulq %r13, %rax
shrq $0x10, %rax
cmpl 0x18(%rsp), %r12d
jne 0x40874
movl 0x30(%rsp), %r11d
movq 0x98(%rsp), %r14
jmp 0x40ced
movq %rax, 0xf0(%rsp)
movb %r9b, %dil
movb %r10b, %r8b
leaq 0x63f17(%rip), %r9      # 0xa47a0
movb 0x2(%r8,%r9), %al
addb (%rdi,%r9), %al
leal 0x10(%rax), %edi
movl %edi, 0xa8(%rsp)
movq %rax, 0x140(%rsp)
addl $0x20, %eax
movl %eax, 0xcc(%rsp)
movl 0x4(%rsp), %edi
subl %edx, %edi
movslq %edi, %rax
imulq %rax, %r13
shrq $0x10, %r13
movq %r13, 0x138(%rsp)
movslq %r14d, %rdi
leaq 0x56d71f(%rip), %rax    # 0x5adff0
movslq (%rax,%rdi,4), %r8
movl 0x14(%rsp), %r9d
leaq 0x56d2ff(%rip), %rax    # 0x5adbe0
movq %rdi, 0x118(%rsp)
subl (%rax,%rdi,4), %r9d
movl %r9d, 0xc8(%rsp)
addq 0x100(%rsp), %r8
movq %r8, 0x110(%rsp)
movslq %esi, %rax
movq %rax, 0x90(%rsp)
movslq %r12d, %rdx
movslq 0x28(%rsp), %rax
movq %rax, 0x120(%rsp)
movl 0x80(%rsp), %r9d
movl 0x30(%rsp), %r11d
movl 0x1c(%rsp), %r10d
movl 0x84(%rsp), %ebp
cmpl %r10d, 0x7c(%rsp)
movq %rdx, 0x130(%rsp)
je 0x40cb7
movslq (%rbx,%rdx,4), %rax
addq %rbx, %rax
movq %rax, 0x128(%rsp)
movl 0xc0(%rsp), %eax
imull %edx, %eax
addl 0xc4(%rsp), %eax
cltq
addq %rbx, %rax
movq %rax, 0x150(%rsp)
leaq 0x56d670(%rip), %rax    # 0x5adff0
movl (%rax,%rdx,4), %r13d
addl 0xc8(%rsp), %r13d
movslq 0x38e3a5(%rip), %rax    # 0x3ced38
leaq 0x56d246(%rip), %rcx    # 0x5adbe0
movslq (%rcx,%rdx,4), %r12
addq 0x110(%rsp), %r12
imulq %rax, %r12
shrq $0x10, %r12
addl 0xf0(%rsp), %r12d
movq 0x118(%rsp), %r15
cmpl 0x45b53b(%rip), %r13d   # 0x49bf00
jle 0x40c9e
cmpb $0x0, 0x45b532(%rip)    # 0x49bf04
movl $0x0, %eax
movl $0x3ff00000, %ecx       # imm = 0x3FF00000
cmovnel %ecx, %eax
cmpl %eax, %r13d
jge 0x40c9e
movq 0x150(%rsp), %rax
movswq (%rax,%r15,2), %rbx
movswq 0x2(%rax,%r15,2), %r8
cmpw %r8w, %bx
je 0x40c9e
movl %r12d, %eax
sarl $0x3, %eax
movq 0x58(%rsp), %rcx
addl %r13d, %ecx
sarl $0xe, %ecx
movslq %ecx, %rcx
leaq 0x41b4e0(%rip), %rsi    # 0x45bf00
movslq (%rsi,%rcx,4), %rcx
movslq %eax, %rdi
imulq %rcx, %rdi
shrq $0x20, %rdi
movl 0x3d842f(%rip), %eax    # 0x418e64
addl %eax, %edi
testl %edi, %edi
movl $0x0, %ecx
cmovlel %ecx, %edi
movq 0x138(%rsp), %rcx
addl %r12d, %ecx
sarl $0x3, %ecx
movq 0x60(%rsp), %rdx
addl %r13d, %edx
sarl $0xe, %edx
movslq %edx, %rdx
movslq (%rsi,%rdx,4), %rdx
movslq %ecx, %rcx
imulq %rdx, %rcx
shrq $0x20, %rcx
addl %eax, %ecx
movl 0x63dbc(%rip), %eax     # 0xa4830
cmpl %eax, %ecx
cmovgel %eax, %ecx
movq %rdi, 0x88(%rsp)
subl %edi, %ecx
movq %rcx, 0xa0(%rsp)
jle 0x40c9e
movq 0x128(%rsp), %rax
addq %rax, %rbx
addq %rax, %r8
cmpq %r8, %rbx
jae 0x40c9e
movq 0x108(%rsp), %rcx
leal (%rcx,%r13), %eax
sarl $0xe, %eax
cltq
leaq 0x41b440(%rip), %rdx    # 0x45bf00
movslq (%rdx,%rax,4), %rax
movq %rax, 0xf8(%rsp)
movl %r13d, %eax
subl %ecx, %eax
sarl $0xe, %eax
cltq
movslq (%rdx,%rax,4), %rax
movq %rax, 0x28(%rsp)
movl 0x88(%rsp), %r14d
movq %r8, 0x30(%rsp)
movq %r14, 0x148(%rsp)
movzbl (%rbx), %esi
shll $0xf, %esi
addl %r9d, %esi
js 0x40b44
movl 0xa8(%rsp), %eax
testb %al, 0x2(%rbx)
je 0x40c8a
movl %esi, %edi
imulq 0xf8(%rsp), %rdi
shrq $0x20, %rdi
movl 0x23af77(%rip), %r8d    # 0x27ba9c
addl %r8d, %edi
movb 0x1(%rbx), %dl
movzbl %dl, %eax
movl %eax, %ecx
shll $0xf, %ecx
addl %esi, %ecx
imulq 0x28(%rsp), %rcx
shrq $0x20, %rcx
addl %r8d, %ecx
jmp 0x40bbe
movb 0x1(%rbx), %dl
movb 0x2(%rbx), %dil
movzbl %dl, %eax
movl %eax, %ecx
shll $0xf, %ecx
addl %esi, %ecx
js 0x40b75
testb %dil, 0x140(%rsp)
je 0x40c8a
movl %r9d, %r14d
movl %ecx, %ecx
movq 0x28(%rsp), %r9
imulq %r9, %rcx
jmp 0x40b97
testb %dil, 0xcc(%rsp)
je 0x40c8a
movl %r9d, %r14d
movslq %ecx, %rcx
imulq 0xf8(%rsp), %rcx
movq 0x28(%rsp), %r9
shrq $0x20, %rcx
movl 0x23aefa(%rip), %r8d    # 0x27ba9c
addl %r8d, %ecx
movslq %esi, %rdi
imulq %r9, %rdi
shrq $0x20, %rdi
addl %r8d, %edi
movl %r14d, %r9d
movq 0x148(%rsp), %r14
cmpb $0x1, %dl
jne 0x40bda
leaq 0x46dd46(%rip), %rax    # 0x4ae910
movl (%rax,%r14,4), %eax
cmpl %eax, %edi
cmovgl %edi, %eax
xorl %esi, %esi
xorl %r11d, %r11d
jmp 0x40c24
movl %ecx, %esi
subl %edi, %esi
cmpl $0x400, %esi            # imm = 0x400
jl 0x40bef
shll $0x10, %eax
xorl %edx, %edx
divl %esi
jmp 0x40c04
cmpl %edi, %ecx
jle 0x40c07
movslq %esi, %rdx
leaq 0x31ced3(%rip), %rsi    # 0x35dad0
imull (%rsi,%rdx,4), %eax
sarl $0x8, %eax
movl %eax, %r11d
leaq 0x46dd02(%rip), %rax    # 0x4ae910
movl (%rax,%r14,4), %eax
xorl %esi, %esi
movl %eax, %edx
subl %edi, %edx
jle 0x40c22
imull %r11d, %edx
movl %edx, %esi
jmp 0x40c24
movl %edi, %eax
leaq 0x46a0e5(%rip), %rdx    # 0x4aad10
movl (%rdx,%r14,4), %edx
cmpl %edx, %ecx
cmovll %ecx, %edx
subl %eax, %edx
jle 0x40c85
leaq 0x3(%rbx), %r8
cltq
leaq 0x3d605b(%rip), %rcx    # 0x416ca0
movslq (%rcx,%rax,4), %rax
movslq 0x88(%rsp), %r9
addq %rax, %r9
addq 0x396b35(%rip), %r9     # 0x3d7790
movq 0xa0(%rsp), %rdi
movl %r11d, %ecx
movl %r11d, %ebp
callq 0x701bd
movl 0x1c(%rsp), %r10d
movl %ebp, %r11d
movl 0x84(%rsp), %ebp
movl 0x80(%rsp), %r9d
movq 0x30(%rsp), %r8
movzbl 0x1(%rbx), %eax
addq %rax, %rbx
addq $0x3, %rbx
cmpq %r8, %rbx
jb 0x40af4
addq 0x90(%rsp), %r15
addl %ebp, %r12d
addl 0x68(%rsp), %r13d
cmpl %r15d, %r10d
jne 0x409be
movq 0x130(%rsp), %rdx
addq 0x120(%rsp), %rdx
cmpl %edx, 0x18(%rsp)
movq 0x8(%rsp), %rbx
jne 0x40939
movq 0xf0(%rsp), %rax
movq 0x98(%rsp), %r14
movl 0xb4(%rsp), %ebp
movl 0xbc(%rsp), %esi
incl %esi
cmpl $0x8, %esi
jne 0x4059e
jmp 0x40d25
movq 0x48(%rsp), %rdi
movl %edi, 0x18(%rsp)
movq 0x40(%rsp), %rdi
movl %edi, 0x1c(%rsp)
jmp 0x4070a
movq 0xe0(%rsp), %rcx
jmp 0x407ab
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq