// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: maskwallscan
static void maskwallscan(int x1, int x2, short *uwal, short *dwal, int *swal, int *lwal)
{
	int x, startx, xnice, ynice;
	intptr_t i, fpalookup, p;
	int y1ve[4], y2ve[4], u4, d4, dax, z, tsizx, tsizy;
	char bad;

	tsizx = tilesizx[globalpicnum];
	tsizy = tilesizy[globalpicnum];
	setgotpic(globalpicnum);
	if ((tsizx <= 0) || (tsizy <= 0)) return;
	if ((uwal[x1] > ydimen) && (uwal[x2] > ydimen)) return;
	if ((dwal[x1] < 0) && (dwal[x2] < 0)) return;

	if (waloff[globalpicnum] == 0) loadtile(globalpicnum);

	startx = x1;

	xnice = (pow2long[picsiz[globalpicnum]&15] == tsizx);
	if (xnice) tsizx = (tsizx-1);
	ynice = (pow2long[picsiz[globalpicnum]>>4] == tsizy);
	if (ynice) tsizy = (picsiz[globalpicnum]>>4);

	fpalookup = (intptr_t)palookup[globalpal];

	setupmvlineasm(globalshiftval);

#ifndef USING_A_C

	x = startx;
	while ((startumost[x+windowx1] > startdmost[x+windowx1]) && (x <= x2)) x++;

	p = x+frameoffset;

	for(;(x<=x2)&&(p&3);x++,p++)
	{
		y1ve[0] = max(uwal[x],startumost[x+windowx1]-windowy1);
		y2ve[0] = min(dwal[x],startdmost[x+windowx1]-windowy1);
		if (y2ve[0] <= y1ve[0]) continue;

		palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8);

		bufplce[0] = lwal[x] + globalxpanning;
		if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; }
		if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy;

		vince[0] = swal[x]*globalyscale;
		vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1);

		mvlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],(void *)(bufplce[0]+waloff[globalpicnum]),(void *)(p+ylookup[y1ve[0]]));
	}
	for(;x<=x2-3;x+=4,p+=4)
	{
		bad = 0;
		for(z=3,dax=x+3;z>=0;z--,dax--)
		{
			y1ve[z] = max(uwal[dax],startumost[dax+windowx1]-windowy1);
			y2ve[z] = min(dwal[dax],startdmost[dax+windowx1]-windowy1)-1;
			if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; }

			i = lwal[dax] + globalxpanning;
			if (i >= tsizx) { if (xnice == 0) i %= tsizx; else i &= tsizx; }
			if (ynice == 0) i *= tsizy; else i <<= tsizy;
			bufplce[z] = waloff[globalpicnum]+i;

			vince[z] = swal[dax]*globalyscale;
			vplce[z] = globalzd + vince[z]*(y1ve[z]-globalhoriz+1);
		}
		if (bad == 15) continue;

		palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8);
		palookupoffse[3] = fpalookup+(getpalookup((int)mulscale16(swal[x+3],globvis),globalshade)<<8);

		if ((palookupoffse[0] == palookupoffse[3]) && ((bad&0x9) == 0))
		{
			palookupoffse[1] = palookupoffse[0];
			palookupoffse[2] = palookupoffse[0];
		}
		else
		{
			palookupoffse[1] = fpalookup+(getpalookup((int)mulscale16(swal[x+1],globvis),globalshade)<<8);
			palookupoffse[2] = fpalookup+(getpalookup((int)mulscale16(swal[x+2],globvis),globalshade)<<8);
		}

		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 ((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));
	}
	for(;x<=x2;x++,p++)
	{
		y1ve[0] = max(uwal[x],startumost[x+windowx1]-windowy1);
		y2ve[0] = min(dwal[x],startdmost[x+windowx1]-windowy1);
		if (y2ve[0] <= y1ve[0]) continue;

		palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8);

		bufplce[0] = lwal[x] + globalxpanning;
		if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; }
		if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy;

		vince[0] = swal[x]*globalyscale;
		vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1);

		mvlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],(void *)(bufplce[0]+waloff[globalpicnum]),(void *)(p+ylookup[y1ve[0]]));
	}

#else	// USING_A_C
	(void)i; (void)u4; (void)d4; (void)dax; (void)z; (void)bad;

	p = startx+frameoffset;
	for(x=startx;x<=x2;x++,p++)
	{
		y1ve[0] = max(uwal[x],startumost[x+windowx1]-windowy1);
		y2ve[0] = min(dwal[x],startdmost[x+windowx1]-windowy1);
		if (y2ve[0] <= y1ve[0]) continue;

		palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8);

		bufplce[0] = lwal[x] + globalxpanning;
		if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; }
		if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy;

		vince[0] = swal[x]*globalyscale;
		vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1);

		mvlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],(void *)(bufplce[0]+waloff[globalpicnum]),(void *)(p+ylookup[y1ve[0]]));
	}

#endif

	faketimerhandler();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movswq 0x3ebcc7(%rip), %rcx    # 0x44ad70
leaq 0x3ebcd0(%rip), %rax    # 0x44ad80
movswl (%rax,%rcx,2), %eax
movl %eax, -0x84(%rbp)
movswq 0x3ebcae(%rip), %rcx    # 0x44ad70
leaq 0x3dd477(%rip), %rax    # 0x43c540
movswl (%rax,%rcx,2), %eax
movl %eax, -0x88(%rbp)
movswl 0x3ebc96(%rip), %edi    # 0x44ad70
callq 0x44d80
cmpl $0x0, -0x84(%rbp)
jle 0x5f0f1
cmpl $0x0, -0x88(%rbp)
jg 0x5f0f6
jmp 0x5f4ca
movq -0x10(%rbp), %rax
movslq -0x4(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl 0x2594ec(%rip), %eax    # 0x2b85f4
jle 0x5f123
movq -0x10(%rbp), %rax
movslq -0x8(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl 0x2594d8(%rip), %eax    # 0x2b85f4
jle 0x5f123
jmp 0x5f4ca
movq -0x18(%rbp), %rax
movslq -0x4(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jge 0x5f14a
movq -0x18(%rbp), %rax
movslq -0x8(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jge 0x5f14a
jmp 0x5f4ca
movswq 0x3ebc1e(%rip), %rcx    # 0x44ad70
leaq 0x376ce7(%rip), %rax    # 0x3d5e40
cmpq $0x0, (%rax,%rcx,8)
jne 0x5f16c
movswl 0x3ebc09(%rip), %edi    # 0x44ad70
callq 0x44df0
movl -0x4(%rbp), %eax
movl %eax, -0x30(%rbp)
movswq 0x3ebbf6(%rip), %rcx    # 0x44ad70
leaq 0x3f042f(%rip), %rax    # 0x44f5b0
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0x81b0e(%rip), %rax     # 0xe0ca0
movl (%rax,%rcx,4), %eax
cmpl -0x84(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x5f1bb
movl -0x84(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x84(%rbp)
movswq 0x3ebbad(%rip), %rcx    # 0x44ad70
leaq 0x3f03e6(%rip), %rax    # 0x44f5b0
movzbl (%rax,%rcx), %eax
sarl $0x4, %eax
movslq %eax, %rcx
leaq 0x81ac5(%rip), %rax     # 0xe0ca0
movl (%rax,%rcx,4), %eax
cmpl -0x88(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x5f211
movswq 0x3ebb73(%rip), %rcx    # 0x44ad70
leaq 0x3f03ac(%rip), %rax    # 0x44f5b0
movzbl (%rax,%rcx), %eax
sarl $0x4, %eax
movl %eax, -0x88(%rbp)
movslq 0x3ebb4c(%rip), %rcx    # 0x44ad64
leaq 0x376421(%rip), %rax    # 0x3d5640
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movswl 0x42971a(%rip), %edi    # 0x488948
callq 0xa7930
movslq -0x30(%rbp), %rax
addq 0x3b32b2(%rip), %rax    # 0x4124f0
movq %rax, -0x50(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jg 0x5f4c5
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl -0x2c(%rbp), %ecx
addl 0x3aeee7(%rip), %ecx    # 0x40e150
movslq %ecx, %rdx
leaq 0x3ad85d(%rip), %rcx    # 0x40cad0
movswl (%rcx,%rdx,2), %ecx
subl 0x3b0563(%rip), %ecx    # 0x40f7e0
cmpl %ecx, %eax
jle 0x5f295
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x90(%rbp)
jmp 0x5f2b8
movl -0x2c(%rbp), %eax
addl 0x3aeeb2(%rip), %eax    # 0x40e150
movslq %eax, %rcx
leaq 0x3ad828(%rip), %rax    # 0x40cad0
movswl (%rax,%rcx,2), %eax
subl 0x3b052e(%rip), %eax    # 0x40f7e0
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl -0x2c(%rbp), %ecx
addl 0x3aee7a(%rip), %ecx    # 0x40e150
movslq %ecx, %rdx
leaq 0x3aee80(%rip), %rcx    # 0x40e160
movswl (%rcx,%rdx,2), %ecx
subl 0x3b04f6(%rip), %ecx    # 0x40f7e0
cmpl %ecx, %eax
jge 0x5f302
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x94(%rbp)
jmp 0x5f325
movl -0x2c(%rbp), %eax
addl 0x3aee45(%rip), %eax    # 0x40e150
movslq %eax, %rcx
leaq 0x3aee4b(%rip), %rax    # 0x40e160
movswl (%rax,%rcx,2), %eax
subl 0x3b04c1(%rip), %eax    # 0x40f7e0
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x60(%rbp), %eax
jg 0x5f33b
jmp 0x5f4ab
movq -0x48(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movl 0x3f0239(%rip), %esi    # 0x44f590
callq 0x39010
movl %eax, %edi
movl 0x3f0228(%rip), %esi    # 0x44f58c
callq 0x5ec70
movl %eax, %ecx
movq -0xa0(%rbp), %rax
shll $0x8, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x42957e(%rip)    # 0x488900
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl 0x4295ad(%rip), %eax    # 0x488940
cltq
movq %rax, 0x429584(%rip)    # 0x488920
movq 0x42957d(%rip), %rax    # 0x488920
movslq -0x84(%rbp), %rcx
cmpq %rcx, %rax
jl 0x5f3e8
cmpl $0x0, -0x34(%rbp)
jne 0x5f3d1
movslq -0x84(%rbp), %rcx
movq 0x42955d(%rip), %rax    # 0x488920
cqto
idivq %rcx
movq %rdx, 0x429551(%rip)    # 0x488920
jmp 0x5f3e6
movslq -0x84(%rbp), %rax
andq 0x429541(%rip), %rax    # 0x488920
movq %rax, 0x42953a(%rip)    # 0x488920
jmp 0x5f3e8
cmpl $0x0, -0x38(%rbp)
jne 0x5f406
movslq -0x88(%rbp), %rax
imulq 0x429523(%rip), %rax    # 0x488920
movq %rax, 0x42951c(%rip)    # 0x488920
jmp 0x5f41f
movl -0x88(%rbp), %ecx
movq 0x42950d(%rip), %rax    # 0x488920
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, 0x429501(%rip)    # 0x488920
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
imull 0x42951f(%rip), %eax    # 0x488950
movl %eax, 0x4294b9(%rip)    # 0x4888f0
movl 0x42950f(%rip), %eax    # 0x48894c
movl 0x4294ad(%rip), %ecx    # 0x4888f0
movl -0x60(%rbp), %edx
subl 0x2591b0(%rip), %edx    # 0x2b85fc
addl $0x1, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, 0x429486(%rip)    # 0x4888e0
movl 0x429490(%rip), %edi    # 0x4888f0
movq 0x429499(%rip), %rsi    # 0x488900
movl -0x70(%rbp), %edx
subl -0x60(%rbp), %edx
subl $0x1, %edx
movl 0x42946a(%rip), %ecx    # 0x4888e0
movq 0x4294a3(%rip), %r8     # 0x488920
movswq 0x3eb8eb(%rip), %r9     # 0x44ad70
leaq 0x3769b4(%rip), %rax    # 0x3d5e40
addq (%rax,%r9,8), %r8
movq -0x50(%rbp), %r9
movslq -0x60(%rbp), %r10
leaq 0x3f25e1(%rip), %rax    # 0x451a80
movslq (%rax,%r10,4), %rax
addq %rax, %r9
callq 0xa7950
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x5f248
callq 0xc220
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)