// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: prepwall
static void prepwall(int z, walltype *wal)
{
	int i, l=0, ol=0, splc, sinc, x, topinc, top, botinc, bot, walxrepeat;

	walxrepeat = (wal->xrepeat<<3);

		//lwall calculation
	i = xb1[z]-halfxdimen;
	topinc = -(ry1[z]>>2);
	botinc = ((ry2[z]-ry1[z])>>8);
	top = mulscale5(rx1[z],xdimen)+mulscale2(topinc,i);
	bot = mulscale11(rx1[z]-rx2[z],xdimen)+mulscale2(botinc,i);

	splc = mulscale19(ry1[z],xdimscale);
	sinc = mulscale16(ry2[z]-ry1[z],xdimscale);

	x = xb1[z];
	if (bot != 0)
	{
		l = divscale12(top,bot);
		swall[x] = mulscale21(l,sinc)+splc;
		l *= walxrepeat;
		lwall[x] = (l>>18);
	}
	while (x+4 <= xb2[z])
	{
		top += topinc; bot += botinc;
		if (bot != 0)
		{
			ol = l; l = divscale12(top,bot);
			swall[x+4] = mulscale21(l,sinc)+splc;
			l *= walxrepeat;
			lwall[x+4] = (l>>18);
		}
		i = ((ol+l)>>1);
		lwall[x+2] = (i>>18);
		lwall[x+1] = ((ol+i)>>19);
		lwall[x+3] = ((l+i)>>19);
		swall[x+2] = ((swall[x]+swall[x+4])>>1);
		swall[x+1] = ((swall[x]+swall[x+2])>>1);
		swall[x+3] = ((swall[x+4]+swall[x+2])>>1);
		x += 4;
	}
	if (x+2 <= xb2[z])
	{
		top += (topinc>>1); bot += (botinc>>1);
		if (bot != 0)
		{
			ol = l; l = divscale12(top,bot);
			swall[x+2] = mulscale21(l,sinc)+splc;
			l *= walxrepeat;
			lwall[x+2] = (l>>18);
		}
		lwall[x+1] = ((l+ol)>>19);
		swall[x+1] = ((swall[x]+swall[x+2])>>1);
		x += 2;
	}
	if (x+1 <= xb2[z])
	{
		bot += (botinc>>2);
		if (bot != 0)
		{
			l = divscale12(top+(topinc>>2),bot);
			swall[x+1] = mulscale21(l,sinc)+splc;
			lwall[x+1] = mulscale18(l,walxrepeat);
		}
	}

	if (lwall[xb1[z]] < 0) lwall[xb1[z]] = 0;
	if ((lwall[xb2[z]] >= walxrepeat) && (walxrepeat)) lwall[xb2[z]] = walxrepeat-1;
	if (wal->cstat&8)
	{
		walxrepeat--;
		for(x=xb1[z];x<=xb2[z];x++) lwall[x] = walxrepeat-lwall[x];
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, -0x10(%rsp)
movzbl 0x16(%rsi), %eax
movq %rax, -0x18(%rsp)
leal (,%rax,8), %r11d
movslq %edi, %r14
leaq 0x229bec(%rip), %rax    # 0x264a70
movslq (%rax,%r14,4), %r15
movslq 0x3d6fd5(%rip), %rax    # 0x411e64
movq %r15, %rdi
subq %rax, %rdi
leaq 0x3ca164(%rip), %rax    # 0x405000
movslq (%rax,%r14,4), %r12
movl %r12d, %ebp
sarl $0x2, %ebp
movl %ebp, %ecx
negl %ecx
leaq 0x45e05f(%rip), %rax    # 0x498f10
movslq (%rax,%r14,4), %rbx
subq %r12, %rbx
movl %ebx, %eax
sarl $0x8, %eax
leaq 0x3c613c(%rip), %rdx    # 0x401000
movslq (%rdx,%r14,4), %r9
movslq 0x62961(%rip), %rdx     # 0x9d830
movq %rdx, %rsi
imulq %r9, %rsi
shrq $0x5, %rsi
movq %rcx, -0x28(%rsp)
movslq %ecx, %r13
imulq %rdi, %r13
shrq $0x2, %r13
addl %esi, %r13d
leaq 0x45a01c(%rip), %rsi    # 0x494f10
movslq (%rsi,%r14,4), %rsi
subq %rsi, %r9
imulq %rdx, %r9
shrq $0xb, %r9
movslq %eax, %r10
imulq %r10, %rdi
shrq $0x2, %rdi
movslq 0x38ce1f(%rip), %rax    # 0x3c7d34
imulq %rax, %r12
shrq $0x13, %r12
movq %rbx, -0x20(%rsp)
imulq %rax, %rbx
shrq $0x10, %rbx
movl %edi, %esi
addl %r9d, %esi
movq %r11, -0x38(%rsp)
movq %r12, -0x30(%rsp)
je 0x3af84
movslq %r13d, %rax
shlq $0xc, %rax
movslq %esi, %r8
cqto
idivq %r8
movslq %eax, %rcx
movslq %ebx, %rdx
movq %rcx, %rax
movq %rdx, -0x40(%rsp)
imulq %rdx, %rax
shrq $0x15, %rax
addl %r12d, %eax
leaq 0x468da6(%rip), %rdx    # 0x4a3d10
movl %eax, (%rdx,%r15,4)
imull %r11d, %ecx
movl %ecx, %eax
sarl $0x12, %eax
leaq 0x46c992(%rip), %rdx    # 0x4a7910
movl %eax, (%rdx,%r15,4)
jmp 0x3af8e
movslq %ebx, %rax
movq %rax, -0x40(%rsp)
xorl %ecx, %ecx
leaq 0x22daeb(%rip), %rax    # 0x268a80
movslq (%rax,%r14,4), %rbx
movslq %r9d, %r14
movslq %edi, %rax
addq %r10, %r14
addq %rax, %r14
movq %r15, %rdi
shlq $0x20, %rdi
negq %rdi
movq %r15, -0x8(%rsp)
leaq 0x4(%r15), %r9
xorl %eax, %eax
leaq 0x468d4f(%rip), %r12    # 0x4a3d10
leaq 0x46c948(%rip), %r15    # 0x4a7910
cmpq %rbx, %r9
jg 0x3b08c
testq %r14, %r14
je 0x3b016
movq -0x28(%rsp), %rax
addl %r13d, %eax
cltq
shlq $0xc, %rax
cqto
idivq %r14
movslq %eax, %r8
movq %r8, %rdx
imulq -0x40(%rsp), %rdx
shrq $0x15, %rdx
addl -0x30(%rsp), %edx
movl %edx, (%r12,%r9,4)
imull -0x38(%rsp), %r8d
movl %ecx, %eax
movl %r8d, %ecx
sarl $0x12, %r8d
movl %r8d, (%r15,%r9,4)
jmp 0x3b01a
movl (%r12,%r9,4), %edx
subl %ebp, %r13d
leal (%rcx,%rax), %r8d
movl %r8d, %r11d
sarl %r11d
sarl $0x13, %r8d
movl %r8d, -0x8(%r15,%r9,4)
leal (%r11,%rax), %r8d
sarl $0x13, %r8d
movl %r8d, -0xc(%r15,%r9,4)
addl %ecx, %r11d
sarl $0x13, %r11d
movl %r11d, -0x4(%r15,%r9,4)
movl -0x10(%r12,%r9,4), %r8d
leal (%rdx,%r8), %r11d
sarl %r11d
movl %r11d, -0x8(%r12,%r9,4)
addl %r11d, %r8d
sarl %r8d
movl %r8d, -0xc(%r12,%r9,4)
addl %edx, %r11d
sarl %r11d
movl %r11d, -0x4(%r12,%r9,4)
addl %r10d, %esi
addq %r10, %r14
movabsq $-0x400000000, %rdx     # imm = 0xFFFFFFFC00000000
addq %rdx, %rdi
addq $0x4, %r9
jmp 0x3afc8
leaq -0x2(%r9), %r10
cmpl %ebx, %r10d
jle 0x3b0a7
addq $-0x4, %r9
movl %r9d, %r10d
movl %r13d, %r8d
movl %esi, %r9d
jmp 0x3b134
movq -0x28(%rsp), %rdx
movl %edx, %r8d
sarl %r8d
addl %r13d, %r8d
movq -0x20(%rsp), %rdx
movl %edx, %r9d
sarl $0x9, %r9d
addl %esi, %r9d
je 0x3b102
movslq %r8d, %rax
shlq $0xc, %rax
movslq %r9d, %rsi
cqto
idivq %rsi
movslq %eax, %rsi
movq %rsi, %rdx
imulq -0x40(%rsp), %rdx
shrq $0x15, %rdx
addl -0x30(%rsp), %edx
movslq %r10d, %r11
movl %edx, (%r12,%r11,4)
imull -0x38(%rsp), %esi
movl %ecx, %eax
movl %esi, %ecx
sarl $0x12, %esi
movl %esi, (%r15,%r11,4)
jmp 0x3b109
movslq %r10d, %rdx
movl (%r12,%rdx,4), %edx
addl %ecx, %eax
sarl $0x13, %eax
movabsq $0x100000000, %rcx      # imm = 0x100000000
subq %rdi, %rcx
sarq $0x1e, %rcx
movl %eax, (%rcx,%r15)
negq %rdi
sarq $0x1e, %rdi
addl (%rdi,%r12), %edx
sarl %edx
movl %edx, (%rcx,%r12)
movq -0x38(%rsp), %rsi
cmpl %ebx, %r10d
jge 0x3b191
movq -0x20(%rsp), %rax
sarl $0xa, %eax
addl %eax, %r9d
je 0x3b191
incl %r10d
movq -0x28(%rsp), %rax
sarl $0x2, %eax
addl %eax, %r8d
movslq %r8d, %rax
shlq $0xc, %rax
movslq %r9d, %rcx
cqto
idivq %rcx
cltq
movq -0x40(%rsp), %rdx
imulq %rax, %rdx
shrq $0x15, %rdx
addl -0x30(%rsp), %edx
movslq %r10d, %rcx
movl %edx, (%r12,%rcx,4)
movq %rsi, %rdx
imulq %rax, %rdx
shrq $0x12, %rdx
movl %edx, (%r15,%rcx,4)
movq -0x8(%rsp), %rdx
cmpl $0x0, (%r15,%rdx,4)
jns 0x3b1a2
andl $0x0, (%r15,%rdx,4)
cmpl %esi, (%r15,%rbx,4)
setge %al
cmpb $0x0, -0x18(%rsp)
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3b1bf
leal -0x1(%rsi), %eax
movl %eax, (%r15,%rbx,4)
movq -0x10(%rsp), %rax
testb $0x8, 0xe(%rax)
jne 0x3b1d5
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%r15,%rdx,4), %rax
cmpq %rbx, %rdx
jg 0x3b1ca
movl (%rax), %ecx
notl %ecx
addl %esi, %ecx
movl %ecx, (%rax)
incq %rdx
addq $0x4, %rax
jmp 0x3b1d9