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

	if (x2 >= xdim) x2 = xdim-1;

	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);

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

	fpalookup = (intptr_t)palookup[globalpal];

	setupvlineasm(globalshiftval);

#ifndef USING_A_C

	x = x1;
	while ((umost[x] > dmost[x]) && (x <= x2)) x++;

	for(;(x<=x2)&&((x+frameoffset)&3);x++)
	{
		y1ve[0] = max(uwal[x],umost[x]);
		y2ve[0] = min(dwal[x],dmost[x]);
		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);

		vlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],(void *)(bufplce[0]+waloff[globalpicnum]),(void *)(x+frameoffset+ylookup[y1ve[0]]));
	}
	for(;x<=x2-3;x+=4)
	{
		bad = 0;
		for(z=3;z>=0;z--)
		{
			y1ve[z] = max(uwal[x+z],umost[x+z]);
			y2ve[z] = min(dwal[x+z],dmost[x+z])-1;
			if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; }

			i = lwal[x+z] + 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[x+z]*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)) prevlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-y1ve[0],vplce[0],(void *)bufplce[0],(void *)(ylookup[y1ve[0]]+x+frameoffset+0));
			if (!(bad&2)) prevlineasm1(vince[1],(void *)palookupoffse[1],y2ve[1]-y1ve[1],vplce[1],(void *)bufplce[1],(void *)(ylookup[y1ve[1]]+x+frameoffset+1));
			if (!(bad&4)) prevlineasm1(vince[2],(void *)palookupoffse[2],y2ve[2]-y1ve[2],vplce[2],(void *)bufplce[2],(void *)(ylookup[y1ve[2]]+x+frameoffset+2));
			if (!(bad&8)) prevlineasm1(vince[3],(void *)palookupoffse[3],y2ve[3]-y1ve[3],vplce[3],(void *)bufplce[3],(void *)(ylookup[y1ve[3]]+x+frameoffset+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]]+x+frameoffset+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]]+x+frameoffset+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]]+x+frameoffset+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]]+x+frameoffset+3));

		if (d4 >= u4) vlineasm4(d4-u4+1,(void *)(ylookup[u4]+x+frameoffset));

		i = x+frameoffset+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));
	}
	for(;x<=x2;x++)
	{
		y1ve[0] = max(uwal[x],umost[x]);
		y2ve[0] = min(dwal[x],dmost[x]);
		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);

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

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

	for(x=x1;x<=x2;x++)
	{
		y1ve[0] = max(uwal[x],umost[x]);
		y2ve[0] = min(dwal[x],dmost[x]);
		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);

		vlineasm1(vince[0],(void *)palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],(void *)(bufplce[0]+waloff[globalpicnum]),(void *)(x+frameoffset+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)
movl -0x8(%rbp), %eax
cmpl 0x3e4612(%rip), %eax    # 0x442d4c
jl 0x5e748
movl 0x3e460a(%rip), %eax    # 0x442d4c
subl $0x1, %eax
movl %eax, -0x8(%rbp)
movswq 0x3ec620(%rip), %rcx    # 0x44ad70
leaq 0x3ec629(%rip), %rax    # 0x44ad80
movswl (%rax,%rcx,2), %eax
movl %eax, -0x80(%rbp)
movswq 0x3ec60a(%rip), %rcx    # 0x44ad70
leaq 0x3dddd3(%rip), %rax    # 0x43c540
movswl (%rax,%rcx,2), %eax
movl %eax, -0x84(%rbp)
movswl 0x3ec5f2(%rip), %edi    # 0x44ad70
callq 0x44d80
cmpl $0x0, -0x80(%rbp)
jle 0x5e792
cmpl $0x0, -0x84(%rbp)
jg 0x5e797
jmp 0x5eb07
movq -0x10(%rbp), %rax
movslq -0x4(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl 0x259e4b(%rip), %eax    # 0x2b85f4
jle 0x5e7c4
movq -0x10(%rbp), %rax
movslq -0x8(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl 0x259e37(%rip), %eax    # 0x2b85f4
jle 0x5e7c4
jmp 0x5eb07
movq -0x18(%rbp), %rax
movslq -0x4(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jge 0x5e7eb
movq -0x18(%rbp), %rax
movslq -0x8(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jge 0x5e7eb
jmp 0x5eb07
movswq 0x3ec57d(%rip), %rcx    # 0x44ad70
leaq 0x377646(%rip), %rax    # 0x3d5e40
cmpq $0x0, (%rax,%rcx,8)
jne 0x5e80d
movswl 0x3ec568(%rip), %edi    # 0x44ad70
callq 0x44df0
movswq 0x3ec55b(%rip), %rcx    # 0x44ad70
leaq 0x3f0d94(%rip), %rax    # 0x44f5b0
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0x82473(%rip), %rax     # 0xe0ca0
movl (%rax,%rcx,4), %eax
cmpl -0x80(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x5e84d
movl -0x80(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x80(%rbp)
movswq 0x3ec51b(%rip), %rcx    # 0x44ad70
leaq 0x3f0d54(%rip), %rax    # 0x44f5b0
movzbl (%rax,%rcx), %eax
sarl $0x4, %eax
movslq %eax, %rcx
leaq 0x82433(%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 0x5e8a3
movswq 0x3ec4e1(%rip), %rcx    # 0x44ad70
leaq 0x3f0d1a(%rip), %rax    # 0x44f5b0
movzbl (%rax,%rcx), %eax
sarl $0x4, %eax
movl %eax, -0x84(%rbp)
movslq 0x3ec4ba(%rip), %rcx    # 0x44ad64
leaq 0x376d8f(%rip), %rax    # 0x3d5640
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movswl 0x42a088(%rip), %edi    # 0x488948
callq 0xa7870
movl -0x4(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jg 0x5eb02
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movslq -0x2c(%rbp), %rdx
leaq 0x3b0f02(%rip), %rcx    # 0x40f7f0
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jle 0x5e90a
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x8c(%rbp)
jmp 0x5e91f
movslq -0x2c(%rbp), %rcx
leaq 0x3b0edb(%rip), %rax    # 0x40f7f0
movswl (%rax,%rcx,2), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movslq -0x2c(%rbp), %rdx
leaq 0x3b2531(%rip), %rcx    # 0x410e70
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jge 0x5e95b
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x90(%rbp)
jmp 0x5e970
movslq -0x2c(%rbp), %rcx
leaq 0x3b250a(%rip), %rax    # 0x410e70
movswl (%rax,%rcx,2), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x60(%rbp), %eax
jg 0x5e986
jmp 0x5eaf4
movq -0x48(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movl 0x3f0bee(%rip), %esi    # 0x44f590
callq 0x39010
movl %eax, %edi
movl 0x3f0bdd(%rip), %esi    # 0x44f58c
callq 0x5ec70
movl %eax, %ecx
movq -0x98(%rbp), %rax
shll $0x8, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x429f33(%rip)    # 0x488900
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl 0x429f62(%rip), %eax    # 0x488940
cltq
movq %rax, 0x429f39(%rip)    # 0x488920
movq 0x429f32(%rip), %rax    # 0x488920
movslq -0x80(%rbp), %rcx
cmpq %rcx, %rax
jl 0x5ea2a
cmpl $0x0, -0x30(%rbp)
jne 0x5ea16
movslq -0x80(%rbp), %rcx
movq 0x429f18(%rip), %rax    # 0x488920
cqto
idivq %rcx
movq %rdx, 0x429f0c(%rip)    # 0x488920
jmp 0x5ea28
movslq -0x80(%rbp), %rax
andq 0x429eff(%rip), %rax    # 0x488920
movq %rax, 0x429ef8(%rip)    # 0x488920
jmp 0x5ea2a
cmpl $0x0, -0x34(%rbp)
jne 0x5ea48
movslq -0x84(%rbp), %rax
imulq 0x429ee1(%rip), %rax    # 0x488920
movq %rax, 0x429eda(%rip)    # 0x488920
jmp 0x5ea61
movl -0x84(%rbp), %ecx
movq 0x429ecb(%rip), %rax    # 0x488920
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, 0x429ebf(%rip)    # 0x488920
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
imull 0x429edd(%rip), %eax    # 0x488950
movl %eax, 0x429e77(%rip)    # 0x4888f0
movl 0x429ecd(%rip), %eax    # 0x48894c
movl 0x429e6b(%rip), %ecx    # 0x4888f0
movl -0x60(%rbp), %edx
subl 0x259b6e(%rip), %edx    # 0x2b85fc
addl $0x1, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, 0x429e44(%rip)    # 0x4888e0
movl 0x429e4e(%rip), %edi    # 0x4888f0
movq 0x429e57(%rip), %rsi    # 0x488900
movl -0x70(%rbp), %edx
subl -0x60(%rbp), %edx
subl $0x1, %edx
movl 0x429e28(%rip), %ecx    # 0x4888e0
movq 0x429e61(%rip), %r8     # 0x488920
movswq 0x3ec2a9(%rip), %r9     # 0x44ad70
leaq 0x377372(%rip), %rax    # 0x3d5e40
addq (%rax,%r9,8), %r8
movslq -0x2c(%rbp), %r9
addq 0x3b3a13(%rip), %r9     # 0x4124f0
movslq -0x60(%rbp), %r10
leaq 0x3f2f98(%rip), %rax    # 0x451a80
movslq (%rax,%r10,4), %rax
addq %rax, %r9
callq 0xa7890
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5e8cb
callq 0xc220
addq $0xa0, %rsp
popq %rbp
retq