// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/build.c
// Function: deletesector
int deletesector(short sucksect)
{
	int i, j, k, nextk, startwall, endwall;

	while (headspritesect[sucksect] >= 0)
	{
		if (ExtDeleteSprite) ExtDeleteSprite(headspritesect[sucksect]);
		deletesprite(headspritesect[sucksect]);
	}
	updatenumsprites();

	startwall = sector[sucksect].wallptr;
	endwall = startwall + sector[sucksect].wallnum - 1;
	j = sector[sucksect].wallnum;

	for(i=sucksect;i<numsectors-1;i++)
	{
		k = headspritesect[i+1];
		while (k != -1)
		{
			nextk = nextspritesect[k];
			changespritesect((short)k,(short)i);
			k = nextk;
		}

		Bmemcpy(&sector[i],&sector[i+1],sizeof(sectortype));
		sector[i].wallptr -= j;
	}
	numsectors--;

	j = endwall-startwall+1;
	for (i=startwall;i<=endwall;i++)
		if (wall[i].nextwall != -1)
		{
			wall[wall[i].nextwall].nextwall = -1;
			wall[wall[i].nextwall].nextsector = -1;
		}
	movewalls(startwall,-j);
	for(i=0;i<numwalls;i++)
		if (wall[i].nextwall >= startwall)
			wall[i].nextsector--;
	return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movslq %edi, %r12
leaq 0x38b37e(%rip), %r15    # 0x3a5510
movzwl (%r15,%r12,2), %eax
testw %ax, %ax
js 0x1a1bc
movq 0x11c3fd(%rip), %rcx    # 0x1365a0
testq %rcx, %rcx
je 0x1a1b2
movswl %ax, %edi
callq *%rcx
movzwl (%r15,%r12,2), %eax
movswl %ax, %edi
callq 0x335fc
jmp 0x1a192
callq 0x11f8c
imulq $0x28, %r12, %rax
leaq 0x222894(%rip), %r13    # 0x23ca60
movswl (%r13,%rax), %ecx
movq %rcx, 0x10(%rsp)
movswl 0x2(%r13,%rax), %eax
movq %rax, 0x8(%rsp)
leaq 0x395337(%rip), %rbx    # 0x3af520
leaq 0x3aed70(%rip), %rax    # 0x3c8f60
movswq (%rax), %rax
leaq -0x1(%rax), %rcx
cmpq %rcx, %r12
jge 0x1a26e
leaq 0x1(%r12), %r14
movzwl 0x2(%r15,%r12,2), %eax
movswl %r12w, %ebp
cmpw $-0x1, %ax
je 0x1a22a
movswq %ax, %rcx
movzwl (%rbx,%rcx,2), %r15d
movswl %ax, %edi
movl %ebp, %esi
callq 0x332e1
movl %r15d, %eax
jmp 0x1a20c
imulq $0x28, %r12, %rax
imulq $0x28, %r14, %rcx
movups (%r13,%rcx), %xmm0
movups 0x10(%r13,%rcx), %xmm1
movups %xmm0, (%r13,%rax)
movq 0x20(%r13,%rcx), %rcx
movq %rcx, 0x20(%r13,%rax)
movups %xmm1, 0x10(%r13,%rax)
movq 0x8(%rsp), %rcx
subw %cx, (%r13,%rax)
movq %r14, %r12
leaq 0x38b2a7(%rip), %r15    # 0x3a5510
jmp 0x1a1e9
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rcx
addl %ebx, %ecx
decl %eax
leaq 0x3aecdd(%rip), %rdx    # 0x3c8f60
movw %ax, (%rdx)
movslq %ebx, %rax
movslq %ecx, %rcx
movq %rax, %rdx
shlq $0x5, %rdx
leaq 0x1977b6(%rip), %r15    # 0x1b1a50
addq %r15, %rdx
addq $0xa, %rdx
cmpq %rcx, %rax
jge 0x1a2d3
movswq (%rdx), %rsi
cmpq $-0x1, %rsi
je 0x1a2ca
shlq $0x5, %rsi
orw $-0x1, 0xa(%r15,%rsi)
movswq (%rdx), %rsi
shlq $0x5, %rsi
orw $-0x1, 0xc(%r15,%rsi)
incq %rax
addq $0x20, %rdx
jmp 0x1a2a1
movq 0x8(%rsp), %rsi
negl %esi
movl %ebx, %edi
callq 0x1b17a
leaq 0x3f5980(%rip), %rax    # 0x40fc68
movzwl (%rax), %ecx
xorl %eax, %eax
testw %cx, %cx
cmovlel %eax, %ecx
movzwl %cx, %ecx
shll $0x5, %ecx
cmpq %rax, %rcx
je 0x1a312
cmpw %bx, 0xa(%r15,%rax)
jl 0x1a30c
decw 0xc(%r15,%rax)
addq $0x20, %rax
jmp 0x1a2f9
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq