// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
leaq 0x5cd3aa(%rip), %rax    # 0x5fa950
cmpl $0x0, (%rax)
je 0x2d5c1
movswl %di, %edi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x598c1
movswq %di, %rax
leaq 0x3d8a14(%rip), %rcx    # 0x405fe0
movswq (%rcx,%rax,2), %rbp
leaq 0x20b478(%rip), %rax    # 0x238a50
movswq (%rax,%rbp,2), %rbx
shlq $0x5, %rbx
leaq 0x18b468(%rip), %r12    # 0x1b8a50
leaq (%r12,%rbx), %r13
leaq 0x42087d(%rip), %rax    # 0x44de70
movswq (%rax,%rbp,2), %rdx
leaq (%rdx,%rdx,4), %r14
leaq 0x21645d(%rip), %rdi    # 0x243a60
movswq 0xc(%rbx,%r12), %rax
leaq (%rax,%rax,4), %rax
movl 0x4(%rdi,%rax,8), %ecx
movl 0x8(%rdi,%rax,8), %eax
movl 0x4(%rdi,%r14,8), %esi
cmpl %esi, %ecx
cmovgl %ecx, %esi
movl %esi, 0xc(%rsp)
movl 0x8(%rdi,%r14,8), %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, 0x1c(%rsp)
leaq 0x576ee8(%rip), %r15    # 0x5a4520
movq %r15, %rdi
movl %ebp, %esi
movq %rdx, 0x20(%rsp)
xorl %ecx, %ecx
callq 0x2432f
movswl 0xc(%rbx,%r12), %edx
leaq 0x42281a(%rip), %r12    # 0x44fe70
movq %r12, %rdi
movl %ebp, %esi
xorl %ecx, %ecx
callq 0x2432f
leaq 0x23e407(%rip), %rax    # 0x26ba70
movslq (%rax,%rbp,4), %rax
leaq 0x24240c(%rip), %rcx    # 0x26fa80
movl (%rcx,%rbp,4), %ecx
cmpl %ecx, %eax
jg 0x2d6a9
movl %eax, %edx
addq %rax, %rax
subl %edx, %ecx
incl %ecx
xorl %edx, %edx
leaq (%rax,%rdx,2), %rdi
movzwl (%r12,%rdi), %r8d
cmpw (%r15,%rdi), %r8w
jle 0x2d6a2
leaq (%rdx,%rdx), %rdi
addq %rax, %rdi
movw %r8w, (%r15,%rdi)
incq %rdx
cmpl %edx, %ecx
jne 0x2d686
leaq 0x47b860(%rip), %rbx    # 0x4a8f10
movq %rbx, %rdi
movl %ebp, %esi
movq 0x20(%rsp), %rdx
movl $0x1, %ecx
movq %rbp, 0x10(%rsp)
callq 0x2432f
movswl 0xc(%r13), %edx
leaq 0x42459b(%rip), %rbp    # 0x451c70
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %ecx
callq 0x2432f
movq 0x10(%rsp), %rdi
leaq 0x23e37d(%rip), %rax    # 0x26ba70
movslq (%rax,%rdi,4), %rax
leaq 0x242382(%rip), %rcx    # 0x26fa80
movslq (%rcx,%rdi,4), %rcx
cmpl %ecx, %eax
jg 0x2d727
leaq -0x1(%rax), %rdx
addq %rax, %rax
movzwl (%rax,%rbp), %esi
cmpw (%rax,%rbx), %si
jge 0x2d71b
movw %si, (%rax,%rbx)
incq %rdx
addq $0x2, %rax
cmpq %rcx, %rdx
jl 0x2d70d
leaq 0x216332(%rip), %rax    # 0x243a60
leaq (%rax,%r14,8), %r15
movq %r13, %rsi
callq 0x3eead
movswl 0xe(%r13), %ebx
movl %ebx, 0x3e28bb(%rip)    # 0x410000
movzwl 0x12(%r13), %eax
xorl %r14d, %r14d
cmpl $0x2400, %eax           # imm = 0x2400
cmovbl %eax, %r14d
movw %r14w, 0x3e28b2(%rip)   # 0x410010
movzbl 0x18(%r13), %eax
movl %eax, 0x426377(%rip)    # 0x453ae0
movzbl 0x19(%r13), %ebp
movl %ebp, 0x426370(%rip)    # 0x453ae4
movswq %r14w, %rax
leaq 0x20d2e1(%rip), %rcx    # 0x23aa60
testb $-0x40, (%rcx,%rax,4)
je 0x2d79b
movswl %r14w, %edi
xorl %esi, %esi
callq 0x242cd
addl %eax, %r14d
movw %r14w, 0x3e2875(%rip)   # 0x410010
leaq 0x576d7e(%rip), %r11    # 0x5a4520
movsbl 0x14(%r13), %eax
movl %eax, 0x3e707f(%rip)    # 0x41482c
movslq 0x3a158c(%rip), %rax    # 0x3ced40
movl %eax, 0x3e7076(%rip)    # 0x414830
movb 0x20(%r15), %cl
testb %cl, %cl
movq 0x10(%rsp), %rsi
leaq 0x23e2a4(%rip), %r10    # 0x26ba70
je 0x2d7e2
addb $0x10, %cl
movzbl %cl, %ecx
imulq %rax, %rcx
shrq $0x4, %rcx
movl %ecx, 0x3e704e(%rip)    # 0x414830
movzbl 0x15(%r13), %eax
leaq 0x36b2f2(%rip), %rcx    # 0x398ae0
xorl %edx, %edx
cmpq $0x0, (%rcx,%rax,8)
cmovnel %eax, %edx
movswq %r14w, %rax
leaq 0x3e704d(%rip), %rcx    # 0x414850
movzbl (%rax,%rcx), %ecx
shrl $0x4, %ecx
leaq 0x76f9f(%rip), %r8      # 0xa47b0
leaq 0x3d3fc8(%rip), %rdi    # 0x4017e0
movswl (%rdi,%rax,2), %eax
xorl %edi, %edi
cmpl %eax, (%r8,%rcx,4)
movl %edx, 0x3e27dc(%rip)    # 0x410004
setne %dil
addl %ecx, %edi
movl $0x20, %ecx
subl %edi, %ecx
movw %cx, 0x4262ac(%rip)     # 0x453ae8
movzbl 0x17(%r13), %eax
addb $-0x13, %cl
shll %cl, %eax
movl %eax, 0x4262a4(%rip)    # 0x453af0
testb $0x4, %bl
movl 0x1c(%rsp), %edx
cmovel 0xc(%rsp), %edx
movl 0x23e202(%rip), %ecx    # 0x26ba60
subl %edx, %ecx
imull %eax, %ecx
shll $0x8, %ecx
shll $0x18, %ebp
addl %ecx, %ebp
movl %ebp, 0x42627b(%rip)    # 0x453aec
movl %ebx, 0xc(%rsp)
btl $0x8, %ebx
jae 0x2d88b
negl %eax
movl %eax, 0x42626d(%rip)    # 0x453af0
negl %ebp
movl %ebp, 0x426261(%rip)    # 0x453aec
movslq 0x773c2(%rip), %r15     # 0xa4c54
testq %r15, %r15
jle 0x2da4f
leaq 0x2421de(%rip), %rax    # 0x26fa80
movl (%rax,%rsi,4), %ebp
movq %r15, %r13
decq %r15
leaq 0x47665e(%rip), %rax    # 0x4a3f10
movslq -0x4(%rax,%r13,4), %rdi
movl (%r10,%rdi,4), %r12d
cmpl %ebp, %r12d
jg 0x2d8ef
leaq 0x2421b9(%rip), %rax    # 0x26fa80
movl (%rax,%rdi,4), %ebx
movl (%r10,%rsi,4), %r14d
cmpl %r14d, %ebx
jl 0x2d8ef
callq 0x24143
leaq 0x576c41(%rip), %r11    # 0x5a4520
leaq 0x23e18a(%rip), %r10    # 0x26ba70
movq 0x10(%rsp), %rsi
testl %eax, %eax
je 0x2d8fa
cmpq $0x1, %r13
jg 0x2d8a5
jmp 0x2da4f
cmpl %r14d, %r12d
movl %r14d, %ecx
cmovgl %r12d, %ecx
cmpl %ebp, %ebx
movl %ebp, %eax
cmovll %ebx, %eax
leaq 0x47a5fe(%rip), %rdx    # 0x4a7f10
movzbl (%r15,%rdx), %edx
cmpl $0x2, %edx
je 0x2d9df
cmpl $0x1, %edx
je 0x2d976
testl %edx, %edx
jne 0x2d8ef
subl %ecx, %eax
jl 0x2d8ef
cmpl %ebx, %ebp
jg 0x2d93a
cmpl %r12d, %r14d
jge 0x2db27
cmpl %r14d, %r12d
cmovgl %r12d, %r14d
movslq %r14d, %rcx
leaq 0x47b5c5(%rip), %rdx    # 0x4a8f10
leaq (%rdx,%rcx,2), %rdi
leaq 0x2(,%rax,2), %rdx
xorl %esi, %esi
callq 0x62f0
leaq 0x576bbb(%rip), %r11    # 0x5a4520
leaq 0x23e104(%rip), %r10    # 0x26ba70
movq 0x10(%rsp), %rsi
jmp 0x2d8ef
cmpl %ecx, %eax
jl 0x2d8ef
leaq 0x484b9b(%rip), %rcx    # 0x4b2520
movswl (%rcx,%r15,2), %ecx
subl %r12d, %ecx
cmpl %r14d, %r12d
cmovgl %r12d, %r14d
movslq %r14d, %rdi
movslq %ecx, %rcx
leaq (%rdi,%rdi), %rdx
addq %rdi, %rcx
addq %rcx, %rcx
subl %edi, %eax
incl %eax
xorl %r9d, %r9d
leaq (%rcx,%r9,2), %rdi
leaq 0x486b6a(%rip), %r8     # 0x4b4520
movzwl (%r8,%rdi), %edi
leaq (%rdx,%r9,2), %r8
cmpw (%r11,%r8), %di
jle 0x2d9d2
leaq (%r9,%r9), %r8
addq %rdx, %r8
movw %di, (%r11,%r8)
incq %r9
cmpl %r9d, %eax
jne 0x2d9ab
jmp 0x2d8ef
cmpl %ecx, %eax
jl 0x2d8ef
leaq 0x484b32(%rip), %rcx    # 0x4b2520
movswl (%rcx,%r15,2), %ecx
subl %r12d, %ecx
cmpl %r14d, %r12d
cmovgl %r12d, %r14d
movslq %r14d, %rdi
movslq %ecx, %rcx
leaq (%rdi,%rdi), %rdx
addq %rdi, %rcx
addq %rcx, %rcx
subl %edi, %eax
incl %eax
xorl %r9d, %r9d
leaq (%rcx,%r9,2), %rdi
leaq 0x486b01(%rip), %r8     # 0x4b4520
movzwl (%r8,%rdi), %edi
leaq (%rdx,%r9,2), %r8
leaq 0x47b4e1(%rip), %rbx    # 0x4a8f10
cmpw (%rbx,%r8), %di
jge 0x2da42
leaq (%r9,%r9), %r8
addq %rdx, %r8
movw %di, (%rbx,%r8)
incq %r9
cmpl %r9d, %eax
jne 0x2da14
jmp 0x2d8ef
cmpw $0x0, 0x36b079(%rip)    # 0x398ad0
jle 0x2dac0
movslq 0x771e0(%rip), %rax     # 0xa4c40
cmpl (%r10,%rsi,4), %eax
jl 0x2dac0
leaq 0x242013(%rip), %rcx    # 0x26fa80
cmpl (%rcx,%rsi,4), %eax
jg 0x2dac0
movl 0x3eb3f0(%rip), %ecx    # 0x418e68
movswl (%r11,%rax,2), %edx
cmpl %edx, %ecx
jl 0x2dac0
leaq 0x47b488(%rip), %rdx    # 0x4a8f10
movswl (%rdx,%rax,2), %eax
cmpl %eax, %ecx
jg 0x2dac0
movq 0x20(%rsp), %rax
movw %ax, 0x428454(%rip)     # 0x455ef0
leaq 0x20afad(%rip), %rax    # 0x238a50
movzwl (%rax,%rsi,2), %eax
movw %ax, 0x428444(%rip)     # 0x455ef2
movw $0x4, 0x36b01b(%rip)    # 0x398ad2
movw $0x1, 0x36b010(%rip)    # 0x398ad0
movl 0xc(%rsp), %eax
testb %al, %al
js 0x2dae9
movl (%r10,%rsi,4), %edi
leaq 0x241fad(%rip), %rax    # 0x26fa80
movl (%rax,%rsi,4), %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3f7f9
btl $0x9, %eax
jb 0x2daf6
callq 0x6fa57
jmp 0x2dafb
callq 0x6fa5f
movq 0x10(%rsp), %rax
leaq 0x23df69(%rip), %rcx    # 0x26ba70
movl (%rcx,%rax,4), %edi
leaq 0x241f6f(%rip), %rcx    # 0x26fa80
movl (%rcx,%rax,4), %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3fb34
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq