// File: davmac314[P]dinit/src/../dasynq/include/dasynq/btree_set.h
// Function: dasynq::btree_set<void*, int, std::less<int>, 8>::remove(dasynq::btree_set<void*, int, std::less<int>, 8>::heapnode&)
void remove(handle_t & hndl) noexcept
    {
        // we have to remove from the Btree itself
        // Pull nodes from a child, all the way down
        // the tree. Then re-balance back up the tree,
        // merging nodes if necessary.
        septnode * sept = hndl.parent;

        int i;
        for (i = 0; i < N; i++) {
            if (sept->hn_p[i] == &hndl) {
                // Ok, go right, then as far as we can to the left:
                septnode * lsrch = sept->children[i+1];
                septnode * prev = sept;
                while (lsrch != nullptr) {
                    prev = lsrch;
                    lsrch = lsrch->children[0];
                }

                if (prev != sept) {
                    sept->hn_p[i] = prev->hn_p[0];
                    sept->prio[i] = prev->prio[0];
                    sept->hn_p[i]->parent = sept;
                    prev->hn_p[0] = &hndl;
                    sept = prev;
                    i = 0;
                }

                // Now we have:
                // - sept is a leaf in the BTree
                // - i is the index of the child to remove from it

                for ( ; i < (N-1); i++) {
                    sept->hn_p[i] = sept->hn_p[i+1];
                    sept->prio[i] = sept->prio[i+1];
                    if (sept->hn_p[i] == nullptr) {
                        break;
                    }
                }

                sept->hn_p[N-1] = nullptr;

                // Now if the node is underpopulated, we need to merge with or
                // borrow from a sibling
                if (i < N/2) {
                    repop_node(sept, i);
                }

                return;
            }
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x8, -0x1c(%rbp)
jge 0x909c
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x20(%rax,%rcx,8), %rax
cmpq -0x10(%rbp), %rax
jne 0x908c
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq 0x60(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x8fa7
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x8f8a
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0x9007
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
movq -0x30(%rbp), %rax
movl (%rax), %edx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rcx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rdx
movq 0x20(%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
jmp 0x9009
cmpl $0x7, -0x1c(%rbp)
jge 0x9068
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cmpq $0x0, 0x20(%rax,%rcx,8)
jne 0x905b
jmp 0x9068
jmp 0x905d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x9009
movq -0x18(%rbp), %rax
movq $0x0, 0x58(%rax)
cmpl $0x4, -0x1c(%rbp)
jge 0x908a
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x90b0
jmp 0x909c
jmp 0x908e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x8f4b
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)