// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/build.c
// Function: whitelinescan
short whitelinescan(short dalinehighlight)
{
	int i, j, k;
	short sucksect, newnumwalls;

	sucksect = sectorofwall(dalinehighlight);

	Bmemcpy(&sector[numsectors],&sector[sucksect],sizeof(sectortype));
	sector[numsectors].wallptr = numwalls;
	sector[numsectors].wallnum = 0;
	i = dalinehighlight;
	newnumwalls = numwalls;
	do
	{
		j = lastwall((short)i);
		if (wall[j].nextwall >= 0)
		{
			j = wall[j].point2;
			for(k=0;k<numwalls;k++)
			{
				if (wall[wall[k].point2].x == wall[j].x)
					if (wall[wall[k].point2].y == wall[j].y)
						if (wall[k].nextwall == -1)
						{
							j = k;
							break;
						}
			}
		}

		Bmemcpy(&wall[newnumwalls],&wall[i],sizeof(walltype));

		wall[newnumwalls].nextwall = j;
		wall[newnumwalls].nextsector = sectorofwall((short)j);

		newnumwalls++;
		sector[numsectors].wallnum++;

		i = j;
	}
	while (i != dalinehighlight);

	for(i=numwalls;i<newnumwalls-1;i++)
		wall[i].point2 = i+1;
	wall[newnumwalls-1].point2 = numwalls;

	if (clockdir(numwalls) == 1)
		return(-1);
	else
		return(newnumwalls);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebp
callq 0x39217
leaq 0x3aec24(%rip), %rcx    # 0x3c8f60
movswq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
leaq 0x222715(%rip), %rsi    # 0x23ca60
movswq %ax, %rax
imulq $0x28, %rax, %rax
movq 0x20(%rsi,%rax), %rdx
movq %rdx, 0x20(%rsi,%rcx)
movups (%rsi,%rax), %xmm0
movups 0x10(%rsi,%rax), %xmm1
movups %xmm1, 0x10(%rsi,%rcx)
movups %xmm0, (%rsi,%rcx)
leaq 0x3f58f2(%rip), %rax    # 0x40fc68
movzwl (%rax), %r15d
movw %r15w, (%rsi,%rcx)
andw $0x0, 0x2(%rsi,%rcx)
leaq 0x1976c4(%rip), %r12    # 0x1b1a50
leaq 0xa(%r12), %rax
movq %rax, (%rsp)
movl %ebp, %ebx
movswl %bx, %edi
callq 0x2bf2f
movl %eax, %r14d
cltq
shlq $0x5, %rax
cmpw $0x0, 0xa(%r12,%rax)
js 0x1a415
addq %r12, %rax
movswq 0x8(%rax), %r14
leaq 0x3f58a8(%rip), %rax    # 0x40fc68
movzwl (%rax), %ecx
movq %r14, %rax
shlq $0x5, %rax
addq %r12, %rax
testw %cx, %cx
movl $0x0, %edx
cmovlel %edx, %ecx
movzwl %cx, %ecx
movq (%rsp), %rsi
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x1a415
movswq -0x2(%rsi), %rdi
shlq $0x5, %rdi
movl (%r12,%rdi), %r8d
cmpl (%rax), %r8d
jne 0x1a409
addq %r12, %rdi
movl 0x4(%rdi), %edi
cmpl 0x4(%rax), %edi
jne 0x1a409
cmpw $-0x1, (%rsi)
je 0x1a412
incq %rdx
addq $0x20, %rsi
jmp 0x1a3e1
movl %edx, %r14d
movswq %r15w, %r13
shlq $0x5, %r13
movslq %ebx, %rax
shlq $0x5, %rax
movaps (%r12,%rax), %xmm0
movaps 0x10(%r12,%rax), %xmm1
movaps %xmm0, (%r12,%r13)
movaps %xmm1, 0x10(%r12,%r13)
movw %r14w, 0xa(%r12,%r13)
movswl %r14w, %edi
callq 0x39217
leaq 0x3aeb10(%rip), %rcx    # 0x3c8f60
movswq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
leaq 0x222601(%rip), %rdx    # 0x23ca60
incw 0x2(%rdx,%rcx)
movw %ax, 0xc(%r12,%r13)
incl %r15d
movl %r14d, %ebx
cmpl %ebp, %r14d
jne 0x1a397
leaq 0x3f57e8(%rip), %rax    # 0x40fc68
movzwl (%rax), %eax
movswq %r15w, %rcx
decq %rcx
movswq %ax, %rdx
movq %rdx, %rsi
shlq $0x5, %rsi
addq %r12, %rsi
addq $0x8, %rsi
movl %eax, %edi
incl %edi
cmpq %rcx, %rdx
jge 0x1a4b1
incq %rdx
movw %di, (%rsi)
addq $0x20, %rsi
jmp 0x1a49e
shlq $0x5, %rcx
movw %ax, 0x8(%r12,%rcx)
movswl %ax, %edi
callq 0x1a735
xorl %ecx, %ecx
negl %eax
sbbl %ecx, %ecx
orl %r15d, %ecx
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq