// File: /workspace/github_c_makefile_star2_O3/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
movl %edi, %ebp
movslq %edi, %r15
leaq 0x39022f(%rip), %r12    # 0x3ac510
movzwl (%r12,%r15,2), %eax
testw %ax, %ax
js 0x1c30b
movq 0x1212ae(%rip), %rcx    # 0x13d5a0
testq %rcx, %rcx
je 0x1c301
movswl %ax, %edi
callq *%rcx
movzwl (%r12,%r15,2), %eax
movswl %ax, %edi
callq 0x36dab
jmp 0x1c2e1
movl $0x0, 0x15deb7(%rip)    # 0x17a1cc
xorl %eax, %eax
movl $0x1a, %ecx
leaq 0x26098d(%rip), %rdx    # 0x27ccb0
cmpw $0x3ff, (%rdx,%rcx)     # imm = 0x3FF
jg 0x1c333
incl %eax
movl %eax, 0x15de99(%rip)    # 0x17a1cc
addq $0x2c, %rcx
cmpq $0xb001a, %rcx          # imm = 0xB001A
jne 0x1c323
leaq (%r15,%r15,4), %rax
leaq 0x227715(%rip), %r13    # 0x243a60
movswl (%r13,%rax,8), %ecx
movq %rcx, 0x10(%rsp)
movswl 0x2(%r13,%rax,8), %eax
movq %rax, 0x8(%rsp)
movswl %bp, %ecx
leaq 0x3b3bf5(%rip), %rax    # 0x3cff60
movswl (%rax), %eax
movl %eax, %edx
decl %edx
cmpl %ecx, %edx
jle 0x1c3fa
leaq 0x39a19f(%rip), %rbx    # 0x3b6520
movzwl 0x2(%r12,%r15,2), %r14d
cmpw $-0x1, %r14w
je 0x1c3b6
movswl %r15w, %ebp
movswq %r14w, %rax
movzwl (%rbx,%rax,2), %r14d
movswl %ax, %edi
movl %ebp, %esi
callq 0x36a71
cmpw $-0x1, %r14w
jne 0x1c392
leaq 0x3b3bad(%rip), %rax    # 0x3cff60
movzwl (%rax), %eax
leaq (%r15,%r15,4), %rcx
incq %r15
leaq (%r15,%r15,4), %rdx
movups (%r13,%rdx,8), %xmm0
movups 0x10(%r13,%rdx,8), %xmm1
movups %xmm0, (%r13,%rcx,8)
movq 0x20(%r13,%rdx,8), %rdx
movq %rdx, 0x20(%r13,%rcx,8)
movq 0x8(%rsp), %rdx
subw %dx, (%r13,%rcx,8)
movups %xmm1, 0x10(%r13,%rcx,8)
movswq %ax, %rcx
decq %rcx
cmpq %rcx, %r15
jl 0x1c381
decl %eax
leaq 0x3b3b5d(%rip), %rcx    # 0x3cff60
movw %ax, (%rcx)
cmpw $0x0, 0x8(%rsp)
movq 0x10(%rsp), %rbx
jle 0x1c468
movq 0x8(%rsp), %rax
leal (%rax,%rbx), %ecx
movslq %ebx, %rax
movslq %ecx, %rcx
movq %rax, %rsi
shlq $0x5, %rsi
leaq 0x19c621(%rip), %rdx    # 0x1b8a50
addq %rdx, %rsi
addq $0xa, %rsi
movw $0xffff, %di            # imm = 0xFFFF
movswq (%rsi), %r8
cmpq $-0x1, %r8
je 0x1c45c
shlq $0x5, %r8
movw %di, 0xa(%rdx,%r8)
movswq (%rsi), %r8
shlq $0x5, %r8
movw %di, 0xc(%rdx,%r8)
incq %rax
addq $0x20, %rsi
cmpq %rcx, %rax
jl 0x1c43a
movq 0x8(%rsp), %rsi
negl %esi
movl %ebx, %edi
callq 0x1d6eb
leaq 0x3fa7eb(%rip), %rax    # 0x416c68
movswq (%rax), %rax
testq %rax, %rax
jle 0x1c4a8
shlq $0x5, %rax
xorl %ecx, %ecx
leaq 0x19c5bd(%rip), %rdx    # 0x1b8a50
cmpw %bx, 0xa(%rdx,%rcx)
jl 0x1c49f
decw 0xc(%rdx,%rcx)
addq $0x20, %rcx
cmpq %rcx, %rax
jne 0x1c493
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq