// File: wichtounet[P]articles/plf_colony_alpha/plf_colony.h
// Function: plf::colony<Trivial<8>, std::allocator<Trivial<8>>, unsigned short>::reduced_stack::destroy_all_data()
void destroy_all_data()
		{
			#ifdef PLF_COLONY_TYPE_TRAITS_SUPPORT
				if (total_number_of_elements != 0 && !(std::is_trivially_destructible<stack_element_type>::value)) // Avoid iteration for trivially-destructible types eg. POD, structs, classes with ermpty destructor
			#else // If compiler doesn't support traits, iterate regardless - trivial destructors will not be called, hopefully compiler will optimise this loop out for POD types
				if (total_number_of_elements != 0)
			#endif
			{
				stack_group_pointer_type previous_group;
				stack_element_pointer_type past_end;

				while (first_group != current_group)
				{
					past_end = first_group->end + 1;

					for (stack_element_pointer_type element_pointer = first_group->elements; element_pointer != past_end; ++element_pointer)
					{
						PLF_COLONY_DESTROY(element_pointer_allocator_type, (*this), element_pointer);
					}

					previous_group = first_group;
					first_group = first_group->next_group;

					PLF_COLONY_DESTROY(stack_group_allocator_type, group_allocator_pair, previous_group);
					PLF_COLONY_DEALLOCATE(stack_group_allocator_type, group_allocator_pair, previous_group, 1);
				}

				// Special case for current group:
				past_end = top_element + 1;

				for (stack_element_pointer_type element_pointer = start_element; element_pointer != past_end; ++element_pointer)
				{
					PLF_COLONY_DESTROY(element_pointer_allocator_type, (*this), element_pointer);
				}

				first_group = first_group->next_group;
				PLF_COLONY_DESTROY(stack_group_allocator_type, group_allocator_pair, current_group);
				PLF_COLONY_DEALLOCATE(stack_group_allocator_type, group_allocator_pair, current_group, 1);
			}

			total_number_of_elements = 0;

			while (first_group != NULL)
			{
				current_group = first_group;
				first_group = first_group->next_group;
				PLF_COLONY_DESTROY(stack_group_allocator_type, group_allocator_pair, current_group);
				PLF_COLONY_DEALLOCATE(stack_group_allocator_type, group_allocator_pair, current_group, 1);
			}
		}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x28(%rax)
je 0x17a0f
movb $0x1, %al
testb $0x1, %al
jne 0x17a0f
jmp 0x178ea
jmp 0x178ec
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
je 0x17990
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x18(%rcx), %rcx
addq $0x8, %rcx
movq %rcx, 0x20(%rsp)
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x1794b
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x17a80
movq 0x18(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
jmp 0x17920
movq 0x8(%rsp), %rdi
movq 0x8(%rdi), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rdi)
addq $0x30, %rdi
movq 0x28(%rsp), %rsi
callq 0x17ab0
movq 0x8(%rsp), %rdi
addq $0x30, %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x17ae0
jmp 0x178ec
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x20(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x179d6
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x17a80
movq 0x10(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x10(%rsp)
jmp 0x179ab
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movq %rax, %rdi
addq $0x30, %rdi
movq (%rax), %rsi
callq 0x17ab0
movq 0x8(%rsp), %rax
movq %rax, %rdi
addq $0x30, %rdi
movq (%rax), %rsi
movl $0x1, %edx
callq 0x17ae0
movq 0x8(%rsp), %rax
movq $0x0, 0x28(%rax)
movq 0x8(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x17a6a
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rcx
movq %rcx, (%rax)
movq 0x8(%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movq %rax, %rdi
addq $0x30, %rdi
movq (%rax), %rsi
callq 0x17ab0
movq 0x8(%rsp), %rax
movq %rax, %rdi
addq $0x30, %rdi
movq (%rax), %rsi
movl $0x1, %edx
callq 0x17ae0
jmp 0x17a1c
addq $0x38, %rsp
retq
nop