// File: /workspace/github_cpp_makefile_star2_O3/wichtounet[P]articles/plf_colony_alpha/plf_colony.h
// Function: void plf::colony<Trivial<32>, std::allocator<Trivial<32>>, unsigned short>::sort<plf::colony<Trivial<32>, std::allocator<Trivial<32>>, unsigned short>::less>(plf::colony<Trivial<32>, std::allocator<Trivial<32>>, 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 0x71110
movq %rdi, %rbx
addq $0x48, %rdi
xorl %edx, %edx
callq 0xee96
movq %rax, %r14
movq 0x20(%rbx), %rax
movq %r14, %r13
cmpq 0x8(%rbx), %rax
je 0x7104a
movq 0x18(%rbx), %rdx
movq 0x28(%rbx), %rcx
movq %r14, %r13
movq %rax, (%r13)
movzwl 0x2(%rcx), %esi
leaq 0x2(%rcx,%rsi,2), %rcx
shll $0x5, %esi
leaq 0x20(%rax,%rsi), %rax
cmpq (%rdx), %rax
jne 0x71040
movq 0x8(%rdx), %rsi
testq %rsi, %rsi
je 0x71040
movq 0x18(%rsi), %rax
movzwl (%rax), %edx
leaq (%rax,%rdx,2), %rcx
movl %edx, %eax
shll $0x5, %eax
addq 0x10(%rsi), %rax
movq %rsi, %rdx
addq $0x8, %r13
cmpq 0x8(%rbx), %rax
jne 0x71006
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x71078
lzcntq %rax, %rdx
leaq (%r14,%rax,8), %r15
movq %r14, %rdi
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rsi
callq 0x7145f
movq %r14, %rdi
movq %r15, %rsi
callq 0x7154a
vxorps %xmm0, %xmm0, %xmm0
movq %rsp, %rdi
vmovups %zmm0, (%rdi)
vxorps %xmm0, %xmm0, %xmm0
movl $0xffff000c, 0x40(%rdi) # imm = 0xFFFF000C
vmovups %ymm0, 0x48(%rdi)
vmovups %ymm0, 0x58(%rdi)
movq $0x8, 0x78(%rdi)
movzwl 0x42(%rbx), %edx
movzwl 0x40(%rbx), %esi
vzeroupper
callq 0x71138
movq 0x38(%rbx), %rax
movl $0xffff, %esi           # imm = 0xFFFF
cmpq %rsi, %rax
cmovbq %rax, %rsi
movq %rsp, %rdi
callq 0xf65a
cmpq %r13, %r14
je 0x710f5
leaq 0x80(%rsp), %r15
movq %rsp, %r12
movq %r14, %rbp
movq (%rbp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x711be
addq $0x8, %rbp
cmpq %r13, %rbp
jne 0x710dd
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xf7f4
movq %r14, %rdi
callq 0x41a0
movq %rsp, %rdi
callq 0xf184
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x71124
movq %rsp, %rdi
movq %rax, %rbx
callq 0xf184
movq %rbx, %rdi
callq 0x42d0
nop