// File: /workspace/github_cpp_makefile_star2_O2/wichtounet[P]articles/plf_colony_alpha/plf_colony.h
// Function: void plf::colony<Trivial<8>, std::allocator<Trivial<8>>, unsigned short>::sort<plf::colony<Trivial<8>, std::allocator<Trivial<8>>, unsigned short>::less>(plf::colony<Trivial<8>, std::allocator<Trivial<8>>, unsigned short>::less)
void sort(comparison_function compare)
	{
		if (total_number_of_elements < 2)
		{
			return;
		}

		element_pointer_type * const element_pointers = PLF_COLONY_ALLOCATE(element_pointer_allocator_type, erased_locations, total_number_of_elements, NULL);
		element_pointer_type *element_pointer = element_pointers;

		try
		{
			for (iterator current_element = begin_iterator; current_element != end_iterator; ++current_element)
			{
				PLF_COLONY_CONSTRUCT(element_pointer_allocator_type, erased_locations, element_pointer++, &*current_element);
			}
		}
		catch (...)
		{
			#ifdef PLF_COLONY_TYPE_TRAITS_SUPPORT
				if (!std::is_trivially_destructible<element_pointer_type>::value)
			#endif
			{
				for(element_pointer_type *current_element_pointer = element_pointers; current_element_pointer != element_pointer; ++current_element_pointer)
				{
					PLF_COLONY_DESTROY(element_pointer_allocator_type, erased_locations, current_element_pointer);
				}
			}

			PLF_COLONY_DEALLOCATE(element_pointer_allocator_type, erased_locations, element_pointers, total_number_of_elements);
			throw;
		}

        std::sort(element_pointers, element_pointers + total_number_of_elements, sort_dereferencer<comparison_function>(compare));


		colony new_location;
		new_location.change_group_sizes(min_elements_per_group, group_allocator_pair.max_elements_per_group);
		new_location.reserve(static_cast<skipfield_type>((total_number_of_elements > std::numeric_limits<skipfield_type>::max()) ? std::numeric_limits<skipfield_type>::max() : total_number_of_elements));

		#if defined(PLF_COLONY_TYPE_TRAITS_SUPPORT) && defined(PLF_COLONY_MOVE_SEMANTICS_SUPPORT)
			if (std::is_move_assignable<element_type>::value)
			{
				for(element_pointer_type *current_element_pointer = element_pointers; current_element_pointer != element_pointer; ++current_element_pointer)
				{
					new_location.insert(std::move(*(*current_element_pointer)));
				}
			}
			else
		#endif
		{
			for(element_pointer_type *current_element_pointer = element_pointers; current_element_pointer != element_pointer; ++current_element_pointer)
			{
				new_location.insert(*(*current_element_pointer));
			}
		}


		#ifdef PLF_COLONY_MOVE_SEMANTICS_SUPPORT
			*this = std::move(new_location); // avoid generating temporary
		#else
			swap(new_location);
		#endif


		#ifdef PLF_COLONY_TYPE_TRAITS_SUPPORT
			if (!std::is_trivially_destructible<element_pointer_type>::value)
		#endif
		{
			for(element_pointer_type *current_element_pointer = element_pointers; current_element_pointer != element_pointer; ++current_element_pointer)
			{
				PLF_COLONY_DESTROY(element_pointer_allocator_type, erased_locations, current_element_pointer);
			}
		}

		PLF_COLONY_DEALLOCATE(element_pointer_allocator_type, erased_locations, element_pointers, total_number_of_elements);
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq 0x38(%rdi), %rsi
cmpq $0x2, %rsi
jb 0x51f86
movq %rdi, %rbx
addq $0x48, %rdi
xorl %edx, %edx
xorl %r13d, %r13d
callq 0x8dcc
vmovups 0x18(%rbx), %xmm0
movq %rax, %r14
movq 0x20(%rbx), %rax
movq %rsp, %r15
vmovaps %xmm0, (%r15)
movq 0x28(%rbx), %rcx
movq %rcx, 0x10(%r15)
cmpq 0x8(%rbx), %rax
je 0x51edd
movq %r15, %rdi
movq %rax, (%r14,%r13)
callq 0x98a2
movq 0x8(%rsp), %rax
addq $0x8, %r13
jmp 0x51ec0
movq 0x38(%rbx), %rax
movq %r14, %rdi
leaq (%r14,%rax,8), %rsi
callq 0x5226b
vxorps %xmm0, %xmm0, %xmm0
movq %rsp, %rdi
vmovups %zmm0, (%rdi)
vxorps %xmm0, %xmm0, %xmm0
movl $0xffff002f, 0x40(%rdi) # imm = 0xFFFF002F
vmovups %ymm0, 0x48(%rdi)
vmovups %ymm0, 0x58(%rdi)
movq $0x8, 0x78(%rdi)
movzwl 0x42(%rbx), %edx
movzwl 0x40(%rbx), %esi
vzeroupper
callq 0x51fae
movq 0x38(%rbx), %rax
movl $0xffff, %esi           # imm = 0xFFFF
cmpq %rsi, %rax
cmovbq %rax, %rsi
movq %rsp, %rdi
callq 0x95e8
leaq 0x80(%rsp), %r15
movq %rsp, %r12
movq %r14, %rbp
testq %r13, %r13
je 0x51f6b
movq (%rbp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x51fea
addq $0x8, %rbp
addq $-0x8, %r13
jmp 0x51f4d
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x979a
movq %r14, %rdi
callq 0x4180
movq %rsp, %rdi
callq 0x9124
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x51f9a
movq %rsp, %rdi
movq %rax, %rbx
callq 0x9124
movq %rbx, %rdi
callq 0x42c0
nop