// File: /workspace/github_cpp_makefile_star2_O2/miniplane[P]mintree/./BpTree.h
// Function: BpTree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, 2ul>::Node::remove_from_leaf(unsigned long, unsigned long)
void remove_from_leaf(size_t value_pos, size_t pos_in_parent) {

			shift(keys, value_pos, elements, -1); // moves element to left, removes key
			elements--;

			if (!parent)
				return;
			
			parent->set_key_in_node(pos_in_parent, keys[0]);

			if (elements >= k) // if Node at least half full, or root, return
				return;

			// tries to borrow value from sibling
			if (can_borrow_from(previous())) {
				push_left(previous()->pop_right());
				parent->set_key_in_node(pos_in_parent, keys[0]); // update next()'s key in parent
				return;
			}
			else if (can_borrow_from(next())) {
				push_right(next()->pop_left());
				parent->set_key_in_node(pos_in_parent+1, next()->keys[0]); // update next()'s key in parent
				return;
			}

			// if borrowing not possible -> merge
			if (previous() && (previous()->parent==parent)) {
				previous()->merge_leaf(pos_in_parent-1);
				delete this;
				return;
			}
			else if (next() && (next()->parent==parent)) {
				Node *n = next();
				merge_leaf(pos_in_parent);
				delete n;
				return;
			}
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
callq 0x2170
leaq 0x38(%r14), %r12
movq 0xb8(%r14), %rdx
pushq $-0x1
popq %rcx
movq %r12, %rdi
movq %r15, %rsi
callq 0x3e02
decq 0xb8(%r14)
movq (%r14), %r13
testq %r13, %r13
je 0x3dd5
leaq -0xc8(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2240
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x3e9e
leaq -0xc8(%rbp), %rdi
callq 0x20e0
cmpq $0x1, 0xb8(%r14)
ja 0x3dd5
movq 0x8(%r14), %rsi
testq %rsi, %rsi
je 0x3d07
movq (%rsi), %rax
cmpq (%r14), %rax
jne 0x3d07
cmpq $0x3, 0xb8(%rsi)
jb 0x3d07
leaq -0xa8(%rbp), %r15
movq %r15, %rdi
callq 0x3f9c
movq %r14, %rdi
movq %r15, %rsi
callq 0x3f50
leaq -0xa8(%rbp), %rdi
callq 0x20e0
movq (%r14), %r14
leaq -0x88(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2240
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x3e9e
leaq -0x88(%rbp), %rdi
jmp 0x3d73
movq 0x28(%r14), %r12
testq %r12, %r12
je 0x3d7a
movq (%r12), %rax
cmpq (%r14), %rax
jne 0x3d7a
cmpq $0x3, 0xb8(%r12)
jb 0x3d7a
leaq -0x68(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x4018
movq %r14, %rdi
movq %r15, %rsi
callq 0x3fdc
leaq -0x68(%rbp), %rdi
callq 0x20e0
incq %rbx
movq (%r14), %r12
movq 0x28(%r14), %rsi
addq $0x38, %rsi
leaq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0x2240
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x3e9e
leaq -0x48(%rbp), %rdi
callq 0x20e0
jmp 0x3dd5
testq %rsi, %rsi
je 0x3d87
movq (%rsi), %rax
cmpq (%r14), %rax
je 0x3db2
testq %r12, %r12
je 0x3dd5
movq (%r12), %rax
cmpq (%r14), %rax
jne 0x3dd5
movq %r14, %rdi
movq %rbx, %rsi
callq 0x407c
movq %r12, %rdi
callq 0x364c
movl $0xc8, %esi
movq %r12, %rdi
jmp 0x3dd0
decq %rbx
movq %rsi, %rdi
movq %rbx, %rsi
callq 0x407c
movq %r14, %rdi
callq 0x364c
movl $0xc8, %esi
movq %r14, %rdi
callq 0x21f0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3def
jmp 0x3def
jmp 0x3def
jmp 0x3def
movq %rax, %rbx
movq %r15, %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x22b0