// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: drawmaskwall
static void drawmaskwall(short damaskwallcnt)
{
	int i, j, k, x, z, sectnum, z1, z2, lx, rx;
	sectortype *sec, *nsec;
	walltype *wal;

	//============================================================================= //POLYMOST BEGINS
#if USE_POLYMOST
	if (rendmode) { polymost_drawmaskwall(damaskwallcnt); return; }
#endif
	//============================================================================= //POLYMOST ENDS

	z = maskwall[damaskwallcnt];
	wal = &wall[thewall[z]];
	sectnum = thesector[z]; sec = &sector[sectnum];
	nsec = &sector[wal->nextsector];
	z1 = max(nsec->ceilingz,sec->ceilingz);
	z2 = min(nsec->floorz,sec->floorz);

	wallmost(uwall,z,sectnum,(char)0);
	wallmost(uplc,z,(int)wal->nextsector,(char)0);
	for(x=xb1[z];x<=xb2[z];x++) if (uplc[x] > uwall[x]) uwall[x] = uplc[x];
	wallmost(dwall,z,sectnum,(char)1);
	wallmost(dplc,z,(int)wal->nextsector,(char)1);
	for(x=xb1[z];x<=xb2[z];x++) if (dplc[x] < dwall[x]) dwall[x] = dplc[x];
	prepwall(z,wal);

	globalorientation = (int)wal->cstat;
	globalpicnum = wal->overpicnum;
	if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0;
	globalxpanning = (int)wal->xpanning;
	globalypanning = (int)wal->ypanning;
	if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)thewall[z]+16384);
	globalshade = (int)wal->shade;
	globvis = globalvisibility;
	if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16)));
	globalpal = (int)wal->pal;
	if (palookup[globalpal] == 0) globalpal = 0;
	globalshiftval = (picsiz[globalpicnum]>>4);
	if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++;
	globalshiftval = 32-globalshiftval;
	globalyscale = (wal->yrepeat<<(globalshiftval-19));
	if ((globalorientation&4) == 0)
		globalzd = (((globalposz-z1)*globalyscale)<<8);
	else
		globalzd = (((globalposz-z2)*globalyscale)<<8);
	globalzd += (globalypanning<<24);
	if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd;

	for(i=smostwallcnt-1;i>=0;i--)
	{
		j = smostwall[i];
		if ((xb1[j] > xb2[z]) || (xb2[j] < xb1[z])) continue;
		if (wallfront(j,z)) continue;

		lx = max(xb1[j],xb1[z]); rx = min(xb2[j],xb2[z]);

		switch(smostwalltype[i])
		{
			case 0:
				if (lx <= rx)
				{
					if ((lx == xb1[z]) && (rx == xb2[z])) return;
					//clearbufbyte(&dwall[lx],(rx-lx+1)*sizeof(dwall[0]),0L);
					for (x=lx; x<=rx; x++) dwall[x] = 0;
				}
				break;
			case 1:
				k = smoststart[i] - xb1[j];
				for(x=lx;x<=rx;x++)
					if (smost[k+x] > uwall[x]) uwall[x] = smost[k+x];
				break;
			case 2:
				k = smoststart[i] - xb1[j];
				for(x=lx;x<=rx;x++)
					if (smost[k+x] < dwall[x]) dwall[x] = smost[k+x];
				break;
		}
	}

		//maskwall
	if ((searchit >= 1) && (searchx >= xb1[z]) && (searchx <= xb2[z]))
		if ((searchy >= uwall[searchx]) && (searchy <= dwall[searchx]))
		{
			searchsector = sectnum; searchwall = thewall[z];
			searchstat = 4; searchit = 1;
		}

	if ((globalorientation&128) == 0)
		maskwallscan(xb1[z],xb2[z],uwall,dwall,swall,lwall);
	else
	{
		if (globalorientation&128)
		{
			if (globalorientation&512) settransreverse(); else settransnormal();
		}
		transmaskwallscan(xb1[z],xb2[z]);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
leaq 0x5c91aa(%rip), %rax    # 0x5f3950
cmpl $0x0, (%rax)
je 0x2a7c1
movswl %di, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4f8cd
movswq %di, %rax
leaq 0x3d4814(%rip), %rcx    # 0x3fefe0
movswq (%rcx,%rax,2), %r14
leaq 0x207278(%rip), %rax    # 0x231a50
movswq (%rax,%r14,2), %rbx
shlq $0x5, %rbx
leaq 0x187268(%rip), %r15    # 0x1b1a50
leaq (%r15,%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x41c678(%rip), %rax    # 0x446e70
movswq (%rax,%r14,2), %rdx
imulq $0x28, %rdx, %rax
leaq 0x212258(%rip), %rcx    # 0x23ca60
leaq (%rcx,%rax), %rsi
movq %rsi, 0x28(%rsp)
movswq 0xc(%rbx,%r15), %rsi
imulq $0x28, %rsi, %rsi
movl 0x4(%rsi,%rcx), %ebp
movl 0x8(%rsi,%rcx), %esi
movl %esi, 0x18(%rsp)
movl 0x4(%rax,%rcx), %r13d
movl 0x8(%rax,%rcx), %eax
movl %eax, 0xc(%rsp)
leaq 0x572ce5(%rip), %r12    # 0x59d520
movq %r12, %rdi
movl %r14d, %esi
movq %rdx, 0x20(%rsp)
xorl %ecx, %ecx
callq 0x2169d
movswl 0xc(%rbx,%r15), %edx
movq %r12, %rbx
leaq 0x41e613(%rip), %r12    # 0x448e70
movq %r12, %rdi
movl %r14d, %esi
xorl %ecx, %ecx
callq 0x2169d
movq %r14, %rsi
leaq 0x23a1fc(%rip), %rax    # 0x264a70
movslq (%rax,%r14,4), %rax
leaq 0x23e201(%rip), %rcx    # 0x268a80
movslq (%rcx,%r14,4), %rcx
leaq (%rax,%rax), %rdx
cmpq %rcx, %rax
jg 0x2a8a4
movzwl (%rdx,%r12), %edi
cmpw (%rdx,%rbx), %di
jle 0x2a89b
movw %di, (%rdx,%rbx)
incq %rax
addq $0x2, %rdx
jmp 0x2a887
cmpl %r13d, %ebp
cmovgl %ebp, %r13d
movl %r13d, 0x1c(%rsp)
leaq 0x477659(%rip), %rbx    # 0x4a1f10
pushq $0x1
popq %r14
movq %rbx, %rdi
movq 0x20(%rsp), %rdx
movl %r14d, %ecx
movq %rsi, 0x10(%rsp)
callq 0x2169d
movq 0x30(%rsp), %r12
movswl 0xc(%r12), %edx
leaq 0x42038e(%rip), %rbp    # 0x44ac70
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
movl %r14d, %ecx
callq 0x2169d
movq 0x10(%rsp), %rdi
leaq 0x23a172(%rip), %rax    # 0x264a70
movslq (%rax,%rdi,4), %rax
leaq 0x23e177(%rip), %rcx    # 0x268a80
movslq (%rcx,%rdi,4), %rcx
leaq (%rax,%rax), %rdx
movl 0xc(%rsp), %r14d
cmpq %rcx, %rax
jg 0x2a932
movzwl (%rdx,%rbp), %esi
cmpw (%rdx,%rbx), %si
jge 0x2a929
movw %si, (%rdx,%rbx)
incq %rax
addq $0x2, %rdx
jmp 0x2a916
movl 0x18(%rsp), %eax
cmpl %r14d, %eax
cmovll %eax, %r14d
movq %r12, %rsi
callq 0x3ae5a
movswl 0xe(%r12), %ebx
movl %ebx, 0x3de6af(%rip)    # 0x409000
movzwl 0x12(%r12), %eax
xorl %r15d, %r15d
cmpw $0x2400, %ax            # imm = 0x2400
cmovbl %eax, %r15d
movw %r15w, 0x3de6a6(%rip)   # 0x409010
movzbl 0x18(%r12), %eax
movl %eax, 0x42216a(%rip)    # 0x44cae0
movzbl 0x19(%r12), %ebp
movl %ebp, 0x422162(%rip)    # 0x44cae4
movswq %r15w, %rax
leaq 0x2090d3(%rip), %rcx    # 0x233a60
testb $-0x40, (%rcx,%rax,4)
je 0x2a9a9
movswl %r15w, %edi
xorl %esi, %esi
callq 0x2163b
addl %eax, %r15d
movw %r15w, 0x3de667(%rip)   # 0x409010
movsbl 0x14(%r12), %eax
movl %eax, 0x3e2e77(%rip)    # 0x40d82c
movslq 0x39d384(%rip), %rax    # 0x3c7d40
movl %eax, 0x3e2e6e(%rip)    # 0x40d830
movq 0x28(%rsp), %rcx
movb 0x20(%rcx), %cl
testb %cl, %cl
movq 0x10(%rsp), %rsi
leaq 0x23a098(%rip), %r11    # 0x264a70
je 0x2a9ee
addb $0x10, %cl
movzbl %cl, %ecx
imulq %rax, %rcx
shrq $0x4, %rcx
movl %ecx, 0x3e2e42(%rip)    # 0x40d830
movzbl 0x15(%r12), %eax
leaq 0x3670e5(%rip), %rcx    # 0x391ae0
xorl %edx, %edx
cmpq $0x0, (%rcx,%rax,8)
cmovnel %eax, %edx
movswq %r15w, %rax
leaq 0x3e2e40(%rip), %rcx    # 0x40d850
movzbl (%rax,%rcx), %ecx
shrl $0x4, %ecx
leaq 0x72d92(%rip), %r8      # 0x9d7b0
leaq 0x3cfdbb(%rip), %rdi    # 0x3fa7e0
movswl (%rdi,%rax,2), %eax
xorl %edi, %edi
cmpl %eax, (%r8,%rcx,4)
movl %edx, 0x3de5cf(%rip)    # 0x409004
setne %dil
addl %ecx, %edi
pushq $0x20
popq %rcx
subl %edi, %ecx
movw %cx, 0x4220a1(%rip)     # 0x44cae8
movzbl 0x17(%r12), %eax
addb $-0x13, %cl
shll %cl, %eax
movl %eax, 0x422098(%rip)    # 0x44caf0
testb $0x4, %bl
cmovel 0x1c(%rsp), %r14d
movl 0x239ff9(%rip), %ecx    # 0x264a60
subl %r14d, %ecx
imull %eax, %ecx
shll $0x8, %ecx
shll $0x18, %ebp
addl %ecx, %ebp
movl %ebp, 0x422071(%rip)    # 0x44caec
movl %ebx, 0xc(%rsp)
btl $0x8, %ebx
jae 0x2aa95
negl %eax
movl %eax, 0x422063(%rip)    # 0x44caf0
negl %ebp
movl %ebp, 0x422057(%rip)    # 0x44caec
movl 0x731b8(%rip), %r13d    # 0x9dc54
leaq 0x47246d(%rip), %r9     # 0x49cf10
leaq 0x23dfd6(%rip), %r8     # 0x268a80
movq %r13, %r14
testl %r14d, %r14d
jle 0x2ac50
leaq -0x1(%r14), %r13
movslq -0x4(%r9,%r14,4), %rdi
movl (%r11,%rdi,4), %ebp
movl (%r8,%rsi,4), %r12d
cmpl %r12d, %ebp
jg 0x2aaaa
movl (%r8,%rdi,4), %ebx
movl (%r11,%rsi,4), %r15d
cmpl %r15d, %ebx
jl 0x2aaaa
callq 0x214a3
leaq 0x47242b(%rip), %r9     # 0x49cf10
leaq 0x23df94(%rip), %r8     # 0x268a80
leaq 0x239f7d(%rip), %r11    # 0x264a70
movq 0x10(%rsp), %rsi
testl %eax, %eax
jne 0x2aaaa
cmpl %r12d, %ebx
movl %r12d, %ecx
cmovll %ebx, %ecx
leaq 0x476404(%rip), %rax    # 0x4a0f10
movzbl (%r13,%rax), %edx
movslq %ecx, %rax
cmpl $0x2, %edx
je 0x2abd9
cmpl $0x1, %edx
je 0x2ab71
testl %edx, %edx
jne 0x2aaaa
cmpl %r15d, %ebp
movl %r15d, %edx
cmovgl %ebp, %edx
cmpl %ecx, %edx
jg 0x2aaaa
cmpl %ebx, %r12d
jg 0x2ab46
cmpl %ebp, %r15d
jge 0x2ad22
cmpl %r15d, %ebp
cmovgl %ebp, %r15d
movslq %r15d, %rcx
leaq 0x4773b9(%rip), %rdx    # 0x4a1f10
leaq (%rdx,%rcx,2), %rdx
cmpq %rax, %rcx
jg 0x2aaaa
andw $0x0, (%rdx)
incq %rcx
addq $0x2, %rdx
jmp 0x2ab5b
leaq 0x4809a8(%rip), %rcx    # 0x4ab520
movswl -0x2(%rcx,%r14,2), %edx
subl %ebp, %edx
cmpl %r15d, %ebp
cmovgl %ebp, %r15d
movslq %r15d, %rcx
movslq %edx, %rdx
addq %rcx, %rdx
addq %rdx, %rdx
leaq (%rcx,%rcx), %r10
xorl %edi, %edi
leaq 0x572980(%rip), %rbx    # 0x59d520
leaq 0x482979(%rip), %r14    # 0x4ad520
leaq (%rcx,%rdi), %r8
cmpq %rax, %r8
jg 0x2ac3d
leaq (%rdx,%rdi,2), %r8
movzwl (%r14,%r8), %r8d
leaq (%r10,%rdi,2), %r9
cmpw (%rbx,%r9), %r8w
jle 0x2abd4
leaq (%rdi,%rdi), %r9
addq %r10, %r9
movw %r8w, (%rbx,%r9)
incq %rdi
jmp 0x2aba7
leaq 0x480940(%rip), %rcx    # 0x4ab520
movswl -0x2(%rcx,%r14,2), %edx
subl %ebp, %edx
cmpl %r15d, %ebp
cmovgl %ebp, %r15d
movslq %r15d, %rcx
movslq %edx, %rdx
addq %rcx, %rdx
addq %rdx, %rdx
leaq (%rcx,%rcx), %r10
xorl %edi, %edi
leaq 0x477308(%rip), %rbx    # 0x4a1f10
leaq 0x482911(%rip), %r14    # 0x4ad520
leaq (%rcx,%rdi), %r8
cmpq %rax, %r8
jg 0x2ac3d
leaq (%rdx,%rdi,2), %r8
movzwl (%r14,%r8), %r8d
leaq (%r10,%rdi,2), %r9
cmpw (%rbx,%r9), %r8w
jge 0x2ac38
leaq (%rdi,%rdi), %r9
addq %r10, %r9
movw %r8w, (%rbx,%r9)
incq %rdi
jmp 0x2ac0f
leaq 0x23de3c(%rip), %r8     # 0x268a80
leaq 0x4722c5(%rip), %r9     # 0x49cf10
jmp 0x2aaaa
cmpw $0x0, 0x366e78(%rip)    # 0x391ad0
jle 0x2acc1
movslq 0x72fdf(%rip), %rax     # 0x9dc40
cmpl (%r11,%rsi,4), %eax
jl 0x2acc1
cmpl (%r8,%rsi,4), %eax
jg 0x2acc1
movl 0x3e71f5(%rip), %ecx    # 0x411e68
leaq 0x5728a6(%rip), %rdx    # 0x59d520
movswl (%rdx,%rax,2), %edx
cmpl %edx, %ecx
jl 0x2acc1
leaq 0x477287(%rip), %rdx    # 0x4a1f10
movswl (%rdx,%rax,2), %eax
cmpl %eax, %ecx
jg 0x2acc1
movq 0x20(%rsp), %rax
movw %ax, 0x424253(%rip)     # 0x44eef0
leaq 0x206dac(%rip), %rax    # 0x231a50
movzwl (%rax,%rsi,2), %eax
movw %ax, 0x424243(%rip)     # 0x44eef2
movw $0x4, 0x366e1a(%rip)    # 0x391ad2
movw $0x1, 0x366e0f(%rip)    # 0x391ad0
movl 0xc(%rsp), %eax
testb %al, %al
js 0x2ace4
movl (%r11,%rsi,4), %edi
movl (%r8,%rsi,4), %esi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3b6d2
btl $0x9, %eax
jb 0x2acf1
callq 0x641a7
jmp 0x2acf6
callq 0x641af
movq 0x10(%rsp), %rax
leaq 0x239d6e(%rip), %rcx    # 0x264a70
movl (%rcx,%rax,4), %edi
leaq 0x23dd74(%rip), %rcx    # 0x268a80
movl (%rcx,%rax,4), %esi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3b9c4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq