// File: /workspace/github_c_makefile_star2_O1/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, %r12d
callq 0x3bae9
leaq 0x3b2b85(%rip), %rcx    # 0x3cef60
movswq (%rcx), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq 0x226676(%rip), %rsi    # 0x242a60
movswq %ax, %rax
leaq (%rax,%rax,4), %rax
movq 0x20(%rsi,%rax,8), %rdx
movq %rdx, 0x20(%rsi,%rcx,8)
movups (%rsi,%rax,8), %xmm0
movups 0x10(%rsi,%rax,8), %xmm1
movups %xmm1, 0x10(%rsi,%rcx,8)
movups %xmm0, (%rsi,%rcx,8)
leaq 0x3f9853(%rip), %rax    # 0x415c68
movzwl (%rax), %r14d
movw %r14w, (%rsi,%rcx,8)
movw $0x0, 0x2(%rsi,%rcx,8)
leaq 0x19b624(%rip), %r15    # 0x1b7a50
leaq 0xa(%r15), %rax
movq %rax, (%rsp)
movl %r12d, %ebx
movswl %bx, %edi
callq 0x2e466
movl %eax, %ebp
cltq
shlq $0x5, %rax
cmpw $0x0, 0xa(%r15,%rax)
js 0x1c4ae
addq %r15, %rax
movswl 0x8(%rax), %ebp
leaq 0x3f980a(%rip), %rax    # 0x415c68
movswq (%rax), %rax
testq %rax, %rax
jle 0x1c4ae
movslq %ebp, %rdx
shlq $0x5, %rdx
leaq (%r15,%rdx), %rcx
movl (%r15,%rdx), %edx
movq (%rsp), %rdi
xorl %esi, %esi
movswq -0x2(%rdi), %r8
shlq $0x5, %r8
cmpl %edx, (%r15,%r8)
jne 0x1c49e
addq %r15, %r8
movl 0x4(%r8), %r8d
cmpl 0x4(%rcx), %r8d
jne 0x1c49e
cmpw $-0x1, (%rdi)
je 0x1c4ac
incq %rsi
addq $0x20, %rdi
cmpq %rsi, %rax
jne 0x1c47c
jmp 0x1c4ae
movl %esi, %ebp
movswq %r14w, %r13
shlq $0x5, %r13
movslq %ebx, %rax
shlq $0x5, %rax
movaps (%r15,%rax), %xmm0
movaps 0x10(%r15,%rax), %xmm1
movaps %xmm0, (%r15,%r13)
movaps %xmm1, 0x10(%r15,%r13)
movw %bp, 0xa(%r15,%r13)
movswl %bp, %edi
callq 0x3bae9
leaq 0x3b2a78(%rip), %rcx    # 0x3cef60
movswq (%rcx), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq 0x226569(%rip), %rdx    # 0x242a60
incw 0x2(%rdx,%rcx,8)
movw %ax, 0xc(%r15,%r13)
incl %r14d
movl %ebp, %ebx
cmpl %r12d, %ebp
jne 0x1c437
leaq 0x3f9751(%rip), %rax    # 0x415c68
movswl (%rax), %eax
movswl %r14w, %edx
decl %edx
movslq %edx, %rcx
cmpl %eax, %edx
jle 0x1c54c
movslq %eax, %rdx
movq %rdx, %rsi
shlq $0x5, %rsi
addq %r15, %rsi
addq $0x8, %rsi
leal 0x1(%rax), %edi
incq %rdx
movw %di, (%rsi)
addq $0x20, %rsi
incl %edi
cmpq %rcx, %rdx
jl 0x1c53b
shlq $0x5, %rcx
movw %ax, 0x8(%r15,%rcx)
movswl %ax, %edi
callq 0x1c7f5
xorl %ecx, %ecx
negl %eax
sbbl %ecx, %ecx
orl %r14d, %ecx
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq