// File: 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
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0xf0(%rbp)
movq %rsi, -0xe8(%rbp)
movq %rdx, -0xe0(%rbp)
callq 0x31d0
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq %rax, %rdi
addq $0x38, %rdi
movq -0x10(%rbp), %rsi
movq 0xb8(%rax), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x6620
movq -0xd8(%rbp), %rax
movq 0xb8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0xb8(%rax)
cmpq $0x0, (%rax)
jne 0x6271
jmp 0x6602
movq -0xd8(%rbp), %rsi
movq (%rsi), %rax
movq %rax, -0x108(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x100(%rbp)
addq $0x38, %rsi
leaq -0x38(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x3100
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
callq 0x6720
jmp 0x62bd
leaq -0x38(%rbp), %rdi
callq 0x3180
movq -0xd8(%rbp), %rax
cmpq $0x2, 0xb8(%rax)
jb 0x62f6
jmp 0x6602
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3180
jmp 0x660b
movq -0xd8(%rbp), %rdi
callq 0x5680
movq -0xd8(%rbp), %rdi
movq (%rax), %rsi
callq 0x6850
testb $0x1, %al
jne 0x631a
jmp 0x63ee
movq -0xd8(%rbp), %rdi
callq 0x5680
movq (%rax), %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x6930
movq -0xd8(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x68c0
jmp 0x634e
leaq -0x68(%rbp), %rdi
callq 0x3180
movq -0xd8(%rbp), %rsi
movq (%rsi), %rax
movq %rax, -0x128(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x120(%rbp)
addq $0x38, %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x3100
movq -0x128(%rbp), %rdi
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdx
callq 0x6720
jmp 0x63a6
leaq -0x88(%rbp), %rdi
callq 0x3180
jmp 0x6602
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3180
jmp 0x660b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x3180
jmp 0x660b
movq -0xd8(%rbp), %rdi
callq 0x56b0
movq -0xd8(%rbp), %rdi
movq (%rax), %rsi
callq 0x6850
testb $0x1, %al
jne 0x6412
jmp 0x64fa
movq -0xd8(%rbp), %rdi
callq 0x56b0
movq (%rax), %rsi
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x69f0
movq -0xd8(%rbp), %rdi
movq -0x130(%rbp), %rsi
callq 0x6990
jmp 0x6449
leaq -0xa8(%rbp), %rdi
callq 0x3180
movq -0xd8(%rbp), %rdi
movq (%rdi), %rax
movq %rax, -0x148(%rbp)
movq -0x18(%rbp), %rax
incq %rax
movq %rax, -0x140(%rbp)
callq 0x56b0
movq (%rax), %rsi
addq $0x38, %rsi
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x3100
movq -0x148(%rbp), %rdi
movq -0x140(%rbp), %rsi
movq -0x138(%rbp), %rdx
callq 0x6720
jmp 0x64af
leaq -0xc8(%rbp), %rdi
callq 0x3180
jmp 0x6602
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3180
jmp 0x660b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x3180
jmp 0x660b
jmp 0x64fc
movq -0xd8(%rbp), %rdi
callq 0x5680
cmpq $0x0, (%rax)
je 0x6577
movq -0xd8(%rbp), %rdi
callq 0x5680
movq -0xd8(%rbp), %rcx
movq (%rax), %rax
movq (%rax), %rax
cmpq (%rcx), %rax
jne 0x6577
movq -0xd8(%rbp), %rdi
callq 0x5680
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
subq $0x1, %rsi
callq 0x6aa0
movq -0xd8(%rbp), %rax
cmpq $0x0, %rax
je 0x6572
movq -0xd8(%rbp), %rdi
callq 0x56e0
movq -0xd8(%rbp), %rdi
movl $0xc8, %esi
callq 0x3270
jmp 0x6602
movq -0xd8(%rbp), %rdi
callq 0x56b0
cmpq $0x0, (%rax)
je 0x6600
movq -0xd8(%rbp), %rdi
callq 0x56b0
movq -0xd8(%rbp), %rcx
movq (%rax), %rax
movq (%rax), %rax
cmpq (%rcx), %rax
jne 0x6600
movq -0xd8(%rbp), %rdi
callq 0x56b0
movq -0xd8(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rsi
callq 0x6aa0
movq -0xd0(%rbp), %rax
movq %rax, -0x150(%rbp)
cmpq $0x0, %rax
je 0x65fe
movq -0x150(%rbp), %rdi
callq 0x56e0
movq -0x150(%rbp), %rdi
movl $0xc8, %esi
callq 0x3270
jmp 0x6602
jmp 0x6602
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x33d0
nopw %cs:(%rax,%rax)
nop