// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movw %di, %ax
movw %ax, -0x2(%rbp)
movswq -0x2(%rbp), %rcx
leaq 0x3bf465(%rip), %rax    # 0x3e9070
movswl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jl 0x29c4e
cmpq $0x0, 0x1500e4(%rip)    # 0x179d00
je 0x29c37
movq 0x1500db(%rip), %rax    # 0x179d00
movswq -0x2(%rbp), %rdx
leaq 0x3bf43f(%rip), %rcx    # 0x3e9070
movswl (%rcx,%rdx,2), %edi
callq *%rax
movswq -0x2(%rbp), %rcx
leaq 0x3bf42d(%rip), %rax    # 0x3e9070
movswl (%rax,%rcx,2), %edi
callq 0x4f7f0
jmp 0x29bff
callq 0x19ed0
movswq -0x2(%rbp), %rcx
leaq 0x256961(%rip), %rax    # 0x2805c0
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movswl (%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movswq -0x2(%rbp), %rdx
leaq 0x256945(%rip), %rcx    # 0x2805c0
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movswl 0x2(%rcx), %ecx
addl %ecx, %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
movswq -0x2(%rbp), %rcx
leaq 0x256926(%rip), %rax    # 0x2805c0
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movswl 0x2(%rax), %eax
movl %eax, -0xc(%rbp)
movswl -0x2(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
leaq 0x3e2e07(%rip), %rcx    # 0x40cac0
movswl (%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x29d6f
movl -0x8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x3bf399(%rip), %rax    # 0x3e9070
movswl (%rax,%rcx,2), %eax
movl %eax, -0x10(%rbp)
cmpl $-0x1, -0x10(%rbp)
je 0x29d12
movslq -0x10(%rbp), %rcx
leaq 0x3c9391(%rip), %rax    # 0x3f3080
movswl (%rax,%rcx,2), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
movw %ax, %cx
movl -0x8(%rbp), %eax
movswl %cx, %edi
movswl %ax, %esi
callq 0x4f230
movl -0x14(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x29cde
movslq -0x8(%rbp), %rax
leaq 0x2568a3(%rip), %rdi    # 0x2805c0
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl -0x8(%rbp), %eax
addl $0x1, %eax
cltq
leaq 0x25688d(%rip), %rsi    # 0x2805c0
imulq $0x28, %rax, %rax
addq %rax, %rsi
movl $0x28, %edx
callq 0x60c0
movl -0xc(%rbp), %edx
movslq -0x8(%rbp), %rcx
leaq 0x25686e(%rip), %rax    # 0x2805c0
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movswl (%rax), %ecx
subl %edx, %ecx
movw %cx, (%rax)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x29caf
leaq 0x3e2d4a(%rip), %rax    # 0x40cac0
movw (%rax), %cx
addw $-0x1, %cx
leaq 0x3e2d3c(%rip), %rax    # 0x40cac0
movw %cx, (%rax)
movl -0x1c(%rbp), %eax
subl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x29e26
movslq -0x8(%rbp), %rcx
leaq 0x1cb800(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0xa(%rax), %eax
cmpl $-0x1, %eax
je 0x29e16
movslq -0x8(%rbp), %rcx
leaq 0x1cb7e5(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movswq 0xa(%rax), %rcx
leaq 0x1cb7d2(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0xa(%rax)      # imm = 0xFFFF
movslq -0x8(%rbp), %rcx
leaq 0x1cb7ba(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movswq 0xa(%rax), %rcx
leaq 0x1cb7a7(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0xc(%rax)      # imm = 0xFFFF
jmp 0x29e18
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x29d99
movl -0x18(%rbp), %edi
xorl %esi, %esi
subl -0xc(%rbp), %esi
callq 0x2b860
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
leaq 0x427b84(%rip), %rcx    # 0x4519c8
movswl (%rcx), %ecx
cmpl %ecx, %eax
jge 0x29e91
movslq -0x8(%rbp), %rcx
leaq 0x1cb75a(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0xa(%rax), %eax
cmpl -0x18(%rbp), %eax
jl 0x29e84
movslq -0x8(%rbp), %rcx
leaq 0x1cb73f(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movw 0xc(%rax), %cx
addw $-0x1, %cx
movw %cx, 0xc(%rax)
jmp 0x29e86
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x29e3a
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)