// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../libcperciva/datastruct/ptrheap.c
// Function: ptrheap_delete
void
ptrheap_delete(struct ptrheap * H, size_t rc)
{

	/*
	 * If the element we're deleting is not at the end of the heap,
	 * replace it with the element which is currently at the end.
	 */
	if (rc != H->nelems - 1) {
		/* Move ptr from position H->nelems - 1 into position rc. */
		*ptrlist_get(H->elems, rc) =
		    *ptrlist_get(H->elems, H->nelems - 1);
		if (H->setreccookie != NULL)
			(H->setreccookie)(H->cookie,
			    *ptrlist_get(H->elems, rc), rc);

		/* Is this too small to be in position ${rc}? */
		if ((rc > 0) &&
		    (H->compar(H->cookie, *ptrlist_get(H->elems, rc),
			*ptrlist_get(H->elems, (rc - 1) / 2)) < 0)) {
			/* Swap with the parent, and keep moving up. */
			swap(H->elems, rc, (rc - 1) / 2,
			    H->setreccookie, H->cookie);
			heapifyup(H->elems, (rc - 1) / 2,
			    H->compar, H->setreccookie, H->cookie);
		} else {
			/* Maybe we need to move it down instead? */
			heapify(H->elems, rc, H->nelems,
			    H->compar, H->setreccookie, H->cookie);
		}
	}

	/*
	 * We've got everything we want to keep in positions 0 .. nelems - 2,
	 * and we have heap-nature, so all we need to do is strip off the
	 * final pointer.
	 */
	ptrlist_shrink(H->elems, 1);
	H->nelems--;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x90d3
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
subq $0x1, %rsi
callq 0x8bb0
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x8bb0
movq -0x18(%rbp), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x8fd9
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x8bb0
movq -0x28(%rbp), %rdi
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq (%rcx), %rsi
movq -0x10(%rbp), %rdx
callq *%rax
cmpq $0x0, -0x10(%rbp)
jbe 0x90a1
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x8bb0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
subq $0x1, %rsi
shrq %rsi
callq 0x8bb0
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq (%rcx), %rdx
callq *%rax
cmpl $0x0, %eax
jge 0x90a1
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rdx
subq $0x1, %rdx
shrq %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %r8
callq 0x9100
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
subq $0x1, %rsi
shrq %rsi
movq -0x8(%rbp), %rax
movq (%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %r8
callq 0x8e20
jmp 0x90d1
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %r8
movq -0x8(%rbp), %rax
movq 0x10(%rax), %r9
callq 0x8be0
jmp 0x90d3
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x1, %esi
callq 0x91f0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x20(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)