// File: /workspace/github_c_makefile_star2_O1/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 0x38f322(%rip), %r12    # 0x3ab510
movzwl (%r12,%r15,2), %eax
testw %ax, %ax
js 0x1c215
movq 0x1203a1(%rip), %rcx    # 0x13c5a0
testq %rcx, %rcx
je 0x1c209
movswl %ax, %edi
callq *%rcx
movswl (%r12,%r15,2), %edi
callq 0x35b53
jmp 0x1c1ee
movl $0x0, 0x15cfad(%rip)    # 0x1791cc
xorl %eax, %eax
movl $0x1a, %ecx
leaq 0x25fa83(%rip), %rdx    # 0x27bcb0
cmpw $0x3ff, (%rdx,%rcx)     # imm = 0x3FF
jg 0x1c23d
incl %eax
movl %eax, 0x15cf8f(%rip)    # 0x1791cc
addq $0x2c, %rcx
cmpq $0xb001a, %rcx          # imm = 0xB001A
jne 0x1c22d
leaq (%r15,%r15,4), %rax
leaq 0x22680b(%rip), %r13    # 0x242a60
movswl (%r13,%rax,8), %ebx
movswl 0x2(%r13,%rax,8), %eax
movq %rax, 0x8(%rsp)
movswl %bp, %ecx
leaq 0x3b2cf0(%rip), %rax    # 0x3cef60
movswl (%rax), %eax
movl %eax, %edx
decl %edx
cmpl %ecx, %edx
jle 0x1c307
movq %rbx, 0x10(%rsp)
leaq 0x399295(%rip), %rbx    # 0x3b5520
movzwl 0x2(%r12,%r15,2), %r14d
cmpw $-0x1, %r14w
je 0x1c2b6
movswl %r15w, %ebp
movswq %r14w, %rax
movzwl (%rbx,%rax,2), %r14d
movswl %ax, %edi
movl %ebp, %esi
callq 0x35819
cmpw $-0x1, %r14w
jne 0x1c29c
leaq (%r15,%r15,4), %rax
incq %r15
leaq (%r15,%r15,4), %rcx
movups (%r13,%rcx,8), %xmm0
movups 0x10(%r13,%rcx,8), %xmm1
movups %xmm0, (%r13,%rax,8)
movq 0x20(%r13,%rcx,8), %rcx
movq %rcx, 0x20(%r13,%rax,8)
movq 0x8(%rsp), %rcx
subw %cx, (%r13,%rax,8)
movups %xmm1, 0x10(%r13,%rax,8)
leaq 0x3b2c6b(%rip), %rax    # 0x3cef60
movswq (%rax), %rax
leaq -0x1(%rax), %rcx
cmpq %rcx, %r15
jl 0x1c28b
movq 0x10(%rsp), %rbx
decl %eax
leaq 0x3b2c50(%rip), %rcx    # 0x3cef60
movw %ax, (%rcx)
cmpw $0x0, 0x8(%rsp)
jle 0x1c370
movq 0x8(%rsp), %rax
leal (%rax,%rbx), %ecx
movslq %ebx, %rax
movslq %ecx, %rcx
movq %rax, %rsi
shlq $0x5, %rsi
leaq 0x19b719(%rip), %rdx    # 0x1b7a50
addq %rdx, %rsi
addq $0xa, %rsi
movw $0xffff, %di            # imm = 0xFFFF
movswq (%rsi), %r8
cmpq $-0x1, %r8
je 0x1c364
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 0x1c342
movq 0x8(%rsp), %rsi
negl %esi
movl %ebx, %edi
callq 0x1d235
leaq 0x3f98e3(%rip), %rax    # 0x415c68
movswq (%rax), %rax
testq %rax, %rax
jle 0x1c3b0
shlq $0x5, %rax
xorl %ecx, %ecx
leaq 0x19b6b5(%rip), %rdx    # 0x1b7a50
cmpw %bx, 0xa(%rdx,%rcx)
jl 0x1c3a7
decw 0xc(%rdx,%rcx)
addq $0x20, %rcx
cmpq %rcx, %rax
jne 0x1c39b
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq