// File: /workspace/github_c_makefile_star2_O1/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 0x5cce9f(%rip), %rax    # 0x5f9950
cmpl $0x0, (%rax)
je 0x2cacc
movswl %di, %edi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x576a1
movswq %di, %rax
leaq 0x3d8509(%rip), %rcx    # 0x404fe0
movswq (%rcx,%rax,2), %rbp
leaq 0x20af6d(%rip), %rax    # 0x237a50
movswq (%rax,%rbp,2), %rbx
shlq $0x5, %rbx
leaq 0x18af5d(%rip), %r12    # 0x1b7a50
leaq (%r12,%rbx), %r13
leaq 0x420372(%rip), %rax    # 0x44ce70
movswq (%rax,%rbp,2), %rdx
leaq (%rdx,%rdx,4), %r14
leaq 0x215f52(%rip), %rdi    # 0x242a60
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 0x5769dd(%rip), %r15    # 0x5a3520
movq %r15, %rdi
movl %ebp, %esi
movq %rdx, 0x20(%rsp)
xorl %ecx, %ecx
callq 0x23dab
movswl 0xc(%rbx,%r12), %edx
leaq 0x42230f(%rip), %r12    # 0x44ee70
movq %r12, %rdi
movl %ebp, %esi
xorl %ecx, %ecx
callq 0x23dab
leaq 0x23defc(%rip), %rax    # 0x26aa70
movslq (%rax,%rbp,4), %rax
leaq 0x241f01(%rip), %rcx    # 0x26ea80
movl (%rcx,%rbp,4), %ecx
cmpl %ecx, %eax
jg 0x2cbb4
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 0x2cbad
leaq (%rdx,%rdx), %rdi
addq %rax, %rdi
movw %r8w, (%r15,%rdi)
incq %rdx
cmpl %edx, %ecx
jne 0x2cb91
leaq 0x47b355(%rip), %rbx    # 0x4a7f10
movq %rbx, %rdi
movl %ebp, %esi
movq 0x20(%rsp), %rdx
movl $0x1, %ecx
movq %rbp, 0x10(%rsp)
callq 0x23dab
movswl 0xc(%r13), %edx
leaq 0x424090(%rip), %rbp    # 0x450c70
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %ecx
callq 0x23dab
movq 0x10(%rsp), %rdi
leaq 0x23de72(%rip), %rax    # 0x26aa70
movslq (%rax,%rdi,4), %rax
leaq 0x241e77(%rip), %rcx    # 0x26ea80
cmpl (%rcx,%rdi,4), %eax
jg 0x2cc3a
leaq 0x241e6b(%rip), %rcx    # 0x26ea80
movslq (%rcx,%rdi,4), %rcx
leaq -0x1(%rax), %rdx
addq %rax, %rax
movzwl (%rax,%rbp), %esi
cmpw (%rax,%rbx), %si
jge 0x2cc2e
movw %si, (%rax,%rbx)
incq %rdx
addq $0x2, %rax
cmpq %rcx, %rdx
jl 0x2cc20
leaq 0x215e1f(%rip), %rax    # 0x242a60
leaq (%rax,%r14,8), %r14
movq %r13, %rsi
callq 0x3d9ee
movswl 0xe(%r13), %r15d
movl %r15d, 0x3e23a7(%rip)   # 0x40f000
movzwl 0x12(%r13), %eax
xorl %ebx, %ebx
cmpl $0x2400, %eax           # imm = 0x2400
cmovbl %eax, %ebx
movw %bx, 0x3e23a1(%rip)     # 0x40f010
movzbl 0x18(%r13), %eax
movl %eax, 0x425e66(%rip)    # 0x452ae0
movzbl 0x19(%r13), %ebp
movl %ebp, 0x425e5f(%rip)    # 0x452ae4
movswq %bx, %rax
leaq 0x20cdd0(%rip), %rcx    # 0x239a60
testb $-0x40, (%rcx,%rax,4)
je 0x2cca9
movswl %bx, %edi
xorl %esi, %esi
callq 0x23d49
addl %eax, %ebx
movw %bx, 0x3e2367(%rip)     # 0x40f010
movsbl 0x14(%r13), %eax
movl %eax, 0x3e6b78(%rip)    # 0x41382c
movslq 0x3a1085(%rip), %rax    # 0x3cdd40
movl %eax, 0x3e6b6f(%rip)    # 0x413830
movb 0x20(%r14), %cl
testb %cl, %cl
je 0x2ccdd
addb $0x10, %cl
movzbl %cl, %ecx
imulq %rax, %rcx
shrq $0x4, %rcx
movl %ecx, 0x3e6b53(%rip)    # 0x413830
movzbl 0x15(%r13), %eax
leaq 0x36adf7(%rip), %rcx    # 0x397ae0
xorl %edx, %edx
cmpq $0x0, (%rcx,%rax,8)
cmovnel %eax, %edx
movl %edx, 0x3e230b(%rip)    # 0x40f004
movswq 0x3e230f(%rip), %rcx    # 0x40f010
leaq 0x3e6b48(%rip), %rax    # 0x413850
movzbl (%rcx,%rax), %eax
shrl $0x4, %eax
movw %ax, 0x425dd2(%rip)     # 0x452ae8
leaq 0x76a93(%rip), %rdx     # 0xa37b0
leaq 0x3d3abc(%rip), %rsi    # 0x4007e0
movswl (%rsi,%rcx,2), %ecx
cmpl %ecx, (%rdx,%rax,4)
movq 0x10(%rsp), %rsi
leaq 0x23dd39(%rip), %r10    # 0x26aa70
leaq 0x5767e2(%rip), %r11    # 0x5a3520
je 0x2cd4c
movzwl %ax, %eax
incl %eax
movw %ax, 0x425d9c(%rip)     # 0x452ae8
movw $0x20, %cx
subw 0x425d91(%rip), %cx     # 0x452ae8
movw %cx, 0x425d8a(%rip)     # 0x452ae8
movzbl 0x17(%r13), %eax
addb $-0x13, %cl
shll %cl, %eax
movl %eax, 0x425d82(%rip)    # 0x452af0
testb $0x4, %r15b
movl 0x1c(%rsp), %edx
cmovel 0xc(%rsp), %edx
movl 0x23dcdf(%rip), %ecx    # 0x26aa60
subl %edx, %ecx
imull %eax, %ecx
shll $0x8, %ecx
shll $0x18, %ebp
addl %ecx, %ebp
movl %ebp, 0x425d58(%rip)    # 0x452aec
movl %r15d, 0xc(%rsp)
btl $0x8, %r15d
jae 0x2cdb0
negl %eax
movl %eax, 0x425d48(%rip)    # 0x452af0
negl %ebp
movl %ebp, 0x425d3c(%rip)    # 0x452aec
movslq 0x76e9d(%rip), %r15     # 0xa3c54
testq %r15, %r15
jle 0x2cf78
leaq 0x241cb9(%rip), %rax    # 0x26ea80
movl (%rax,%rsi,4), %ebp
movq %r15, %r13
decq %r15
leaq 0x476139(%rip), %rax    # 0x4a2f10
movslq -0x4(%rax,%r13,4), %rdi
movl (%r10,%rdi,4), %r12d
cmpl %ebp, %r12d
jg 0x2ce14
leaq 0x241c94(%rip), %rax    # 0x26ea80
movl (%rax,%rdi,4), %ebx
movl (%r10,%rsi,4), %r14d
cmpl %r14d, %ebx
jl 0x2ce14
callq 0x23bbf
leaq 0x57671c(%rip), %r11    # 0x5a3520
leaq 0x23dc65(%rip), %r10    # 0x26aa70
movq 0x10(%rsp), %rsi
testl %eax, %eax
je 0x2ce1f
cmpq $0x1, %r13
jg 0x2cdca
jmp 0x2cf78
cmpl %r14d, %r12d
movl %r14d, %ecx
cmovgl %r12d, %ecx
cmpl %ebp, %ebx
movl %ebp, %eax
cmovll %ebx, %eax
leaq 0x47a0d9(%rip), %rdx    # 0x4a6f10
movzbl (%r15,%rdx), %edx
cmpl $0x2, %edx
je 0x2cf08
cmpl $0x1, %edx
je 0x2ce9f
testl %edx, %edx
jne 0x2ce14
cmpl %ecx, %eax
jl 0x2ce14
cmpl %ebx, %ebp
jg 0x2ce5f
cmpl %r12d, %r14d
jge 0x2d050
subl %ecx, %eax
jl 0x2ce14
cmpl %r14d, %r12d
cmovgl %r12d, %r14d
movslq %r14d, %rcx
leaq 0x47b09c(%rip), %rdx    # 0x4a7f10
leaq (%rdx,%rcx,2), %rdi
leaq 0x2(,%rax,2), %rdx
xorl %esi, %esi
callq 0x62f0
leaq 0x576692(%rip), %r11    # 0x5a3520
leaq 0x23dbdb(%rip), %r10    # 0x26aa70
movq 0x10(%rsp), %rsi
jmp 0x2ce14
cmpl %ecx, %eax
jl 0x2ce14
leaq 0x484672(%rip), %rcx    # 0x4b1520
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 0x486641(%rip), %r8     # 0x4b3520
movzwl (%r8,%rdi), %edi
leaq (%rdx,%r9,2), %r8
cmpw (%r11,%r8), %di
jle 0x2cefb
leaq (%r9,%r9), %r8
addq %rdx, %r8
movw %di, (%r11,%r8)
incq %r9
cmpl %r9d, %eax
jne 0x2ced4
jmp 0x2ce14
cmpl %ecx, %eax
jl 0x2ce14
leaq 0x484609(%rip), %rcx    # 0x4b1520
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 0x4865d8(%rip), %r8     # 0x4b3520
movzwl (%r8,%rdi), %edi
leaq (%rdx,%r9,2), %r8
leaq 0x47afb8(%rip), %rbx    # 0x4a7f10
cmpw (%rbx,%r8), %di
jge 0x2cf6b
leaq (%r9,%r9), %r8
addq %rdx, %r8
movw %di, (%rbx,%r8)
incq %r9
cmpl %r9d, %eax
jne 0x2cf3d
jmp 0x2ce14
cmpw $0x0, 0x36ab50(%rip)    # 0x397ad0
jle 0x2cfe9
movslq 0x76cb7(%rip), %rax     # 0xa3c40
cmpl (%r10,%rsi,4), %eax
jl 0x2cfe9
leaq 0x241aea(%rip), %rcx    # 0x26ea80
cmpl (%rcx,%rsi,4), %eax
jg 0x2cfe9
movl 0x3eaec7(%rip), %ecx    # 0x417e68
movswl (%r11,%rax,2), %edx
cmpl %edx, %ecx
jl 0x2cfe9
leaq 0x47af5f(%rip), %rdx    # 0x4a7f10
movswl (%rdx,%rax,2), %eax
cmpl %eax, %ecx
jg 0x2cfe9
movq 0x20(%rsp), %rax
movw %ax, 0x427f2b(%rip)     # 0x454ef0
leaq 0x20aa84(%rip), %rax    # 0x237a50
movzwl (%rax,%rsi,2), %eax
movw %ax, 0x427f1b(%rip)     # 0x454ef2
movw $0x4, 0x36aaf2(%rip)    # 0x397ad2
movw $0x1, 0x36aae7(%rip)    # 0x397ad0
movl 0xc(%rsp), %eax
testb %al, %al
js 0x2d012
movl (%r10,%rsi,4), %edi
leaq 0x241a84(%rip), %rax    # 0x26ea80
movl (%rax,%rsi,4), %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3e396
btl $0x9, %eax
jb 0x2d01f
callq 0x6dccb
jmp 0x2d024
callq 0x6dcd3
movq 0x10(%rsp), %rax
leaq 0x23da40(%rip), %rcx    # 0x26aa70
movl (%rcx,%rax,4), %edi
leaq 0x241a46(%rip), %rcx    # 0x26ea80
movl (%rcx,%rax,4), %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3e6e6
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq