// File: /workspace/github_cpp_makefile_star2_O3/wichtounet[P]articles/plf_colony_alpha/plf_colony.h
// Function: plf::colony<Trivial<8>, std::allocator<Trivial<8>>, unsigned short>::insert(unsigned long, Trivial<8> const&)
iterator insert(const size_type number_of_elements, const element_type &element)
	{
		if (number_of_elements == 0)
		{
			return end_iterator;
		}

		if (first_group == NULL) // Empty colony, no groups created yet
		{
			if (number_of_elements > group_allocator_pair.max_elements_per_group)
			{
				// Create and fill first group:
				initialize(group_allocator_pair.max_elements_per_group); // Construct first group
				group_fill(element, group_allocator_pair.max_elements_per_group);

				// Create and fill all remaining groups:
				size_type multiples = (number_of_elements / static_cast<size_type>(group_allocator_pair.max_elements_per_group));
				const skipfield_type element_remainder = static_cast<const skipfield_type>(number_of_elements - (multiples * static_cast<size_type>(group_allocator_pair.max_elements_per_group)));

				while (--multiples != 0)
				{
					group_create(group_allocator_pair.max_elements_per_group);
					group_fill(element, group_allocator_pair.max_elements_per_group);
				}

				if (element_remainder != 0)
				{
					group_create(group_allocator_pair.max_elements_per_group);
					group_fill(element, element_remainder);
				}
			}
			else
			{
				initialize((number_of_elements < min_elements_per_group) ? min_elements_per_group : static_cast<skipfield_type>(number_of_elements)); // Construct first group
				group_fill(element, static_cast<skipfield_type>(number_of_elements));
			}

			end_iterator.skipfield_pointer = end_iterator.group_pointer->skipfield + end_iterator.group_pointer->number_of_elements;
			total_number_of_elements += number_of_elements;
			return begin_iterator;
		}
		else
		{
			const iterator return_iterator = insert(element);
			size_type num_elements = number_of_elements - 1;
			size_type capacity_available = (reinterpret_cast<element_pointer_type>(end_iterator.group_pointer->skipfield) - end_iterator.element_pointer) + erased_locations.total_number_of_elements;

			// Use up erased locations and remainder of current group first:
			while (capacity_available-- != 0 && num_elements-- != 0)
			{
				insert(element);
			}

			// If still some left over, create new groups and fill:
			if (num_elements > group_allocator_pair.max_elements_per_group)
			{
				size_type multiples = (num_elements / static_cast<size_type>(group_allocator_pair.max_elements_per_group));
				const skipfield_type element_remainder = static_cast<const skipfield_type>(num_elements - (multiples * static_cast<size_type>(group_allocator_pair.max_elements_per_group)));

				while (multiples-- != 0)
				{
					group_create(group_allocator_pair.max_elements_per_group);
					group_fill(element, group_allocator_pair.max_elements_per_group);
				}

				if (element_remainder != 0)
				{
					group_create(group_allocator_pair.max_elements_per_group);
					group_fill(element, element_remainder);
				}
			}
			else if (num_elements > total_number_of_elements)
			{
				group_create(static_cast<skipfield_type>(num_elements));
				group_fill(element, static_cast<skipfield_type>(num_elements));
			}

			end_iterator.skipfield_pointer = end_iterator.group_pointer->skipfield + end_iterator.group_pointer->number_of_elements;
			total_number_of_elements += num_elements; // Adds the remainder - the insert functions above will already have incremented total_number_of_elements

			return return_iterator;
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
testq %rdx, %rdx
je 0x8f1ba
cmpq $0x0, 0x30(%r14)
movq %rcx, %r12
movq %rdx, %r15
je 0x8f1cc
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0xc700
movq (%r14), %rax
decq %r15
movq %rbx, 0x8(%rsp)
movq 0x18(%rax), %rbp
subq 0x8(%r14), %rbp
sarq $0x3, %rbp
addq 0x70(%r14), %rbp
je 0x8f127
negq %rbp
leaq 0x10(%rsp), %r13
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0x8f2fa
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0xc700
incq %rbx
movq %rbp, %rax
addq %rbx, %rax
jne 0x8f0fd
subq %rbx, %r15
movq 0x8(%rsp), %rbx
movzwl 0x42(%r14), %ecx
movzwl %cx, %esi
cmpq %rsi, %r15
ja 0x8f309
cmpq 0x38(%r14), %r15
jbe 0x8f563
movzwl %r15w, %esi
movq %r14, %rdi
callq 0x8f594
vpbroadcastq (%r12), %zmm1
vpmovsxbq 0x28551(%rip), %zmm2 # 0xb76b0
movq 0x8(%r14), %rcx
movabsq $0x1fffffffffffffff, %rdx # imm = 0x1FFFFFFFFFFFFFFF
movb $0x3d, %sil
addq %r15, %rdx
bzhiq %rsi, %rdx, %rsi
andl $0x7, %edx
negq %rdx
vpbroadcastq %rsi, %zmm0
leaq 0x8(%rsi,%rdx), %rdx
xorl %esi, %esi
leaq (%rcx,%r15,8), %rax
vpbroadcastq %rsi, %zmm3
vporq %zmm2, %zmm3, %zmm3
vpcmpleuq %zmm0, %zmm3, %k1
vmovdqu64 %zmm1, (%rcx,%rsi,8) {%k1}
addq $0x8, %rsi
cmpq %rsi, %rdx
jne 0x8f18f
movl %r15d, %ebp
jmp 0x8f41e
vmovdqu (%r14), %xmm0
vmovdqu %xmm0, (%rbx)
movq 0x10(%r14), %rax
jmp 0x8f558
movzwl 0x42(%r14), %eax
cmpq %r15, %rax
jae 0x8f431
movzwl %ax, %esi
movq %r14, %rdi
movq %rbx, 0x8(%rsp)
movabsq $0x1fffffffffffffff, %r13 # imm = 0x1FFFFFFFFFFFFFFF
callq 0xc9d0
movzwl 0x42(%r14), %ecx
vpbroadcastq (%r12), %zmm1
vpmovsxbq 0x284a6(%rip), %zmm3 # 0xb76b0
movq 0x8(%r14), %rdx
movb $0x3d, %dil
leaq (%rcx,%r13), %rsi
leaq (%rdx,%rcx,8), %rax
bzhiq %rdi, %rsi, %rdi
andl $0x7, %esi
negq %rsi
vpbroadcastq %rdi, %zmm0
leaq 0x8(%rdi,%rsi), %rsi
xorl %edi, %edi
vpbroadcastq %rdi, %zmm2
vporq %zmm3, %zmm2, %zmm2
vpcmpleuq %zmm0, %zmm2, %k1
vmovdqu64 %zmm1, (%rdx,%rdi,8) {%k1}
addq $0x8, %rdi
cmpq %rdi, %rsi
jne 0x8f231
movq %rax, 0x8(%r14)
xorl %edx, %edx
movq (%r14), %rsi
movq %rax, (%rsi)
movw %cx, 0x30(%rsi)
movq %r15, %rax
divq %rcx
movq %rdx, %rbx
movq %rax, %rbp
decq %rbp
je 0x8f4b1
movzwl %cx, %esi
movq %r14, %rdi
vzeroupper
callq 0x8f594
movzwl 0x42(%r14), %ecx
vpmovsxbq 0x2841a(%rip), %zmm3 # 0xb76b0
vpbroadcastq (%r12), %zmm1
movq 0x8(%r14), %rdx
movq %rcx, %rsi
addq %r13, %rsi
leaq (%rdx,%rcx,8), %rax
movq %rsi, %rdi
andl $0x7, %esi
andq %r13, %rdi
negq %rsi
vpbroadcastq %rdi, %zmm0
leaq 0x8(%rdi,%rsi), %rsi
xorl %edi, %edi
vpbroadcastq %rdi, %zmm2
vporq %zmm3, %zmm2, %zmm2
vpcmpleuq %zmm0, %zmm2, %k1
vmovdqu64 %zmm1, (%rdx,%rdi,8) {%k1}
addq $0x8, %rdi
cmpq %rdi, %rsi
jne 0x8f2c4
movq %rax, 0x8(%r14)
movq (%r14), %rsi
movq %rax, (%rsi)
movw %cx, 0x30(%rsi)
jmp 0x8f270
movzwl 0x42(%r14), %ecx
movq $-0x1, %r15
movzwl %cx, %esi
movq %r15, %rax
xorl %edx, %edx
divq %rsi
movabsq $0x1fffffffffffffff, %r13 # imm = 0x1FFFFFFFFFFFFFFF
movq %rdx, %rbx
movq %rax, %rbp
movzwl %cx, %esi
movq %r14, %rdi
vzeroupper
callq 0x8f594
movzwl 0x42(%r14), %ecx
vpmovsxbq 0x28372(%rip), %zmm3 # 0xb76b0
vpbroadcastq (%r12), %zmm1
movq 0x8(%r14), %rdx
movq %rcx, %rsi
addq %r13, %rsi
leaq (%rdx,%rcx,8), %rax
movq %rsi, %rdi
andl $0x7, %esi
andq %r13, %rdi
negq %rsi
vpbroadcastq %rdi, %zmm0
leaq 0x8(%rdi,%rsi), %rsi
xorl %edi, %edi
vpbroadcastq %rdi, %zmm2
vporq %zmm3, %zmm2, %zmm2
vpcmpleuq %zmm0, %zmm2, %k1
vmovdqu64 %zmm1, (%rdx,%rdi,8) {%k1}
addq $0x8, %rdi
cmpq %rdi, %rsi
jne 0x8f36c
movq %rax, 0x8(%r14)
decq %rbp
movq (%r14), %rdx
movq %rax, (%rdx)
movw %cx, 0x30(%rdx)
jne 0x8f321
movq %rbx, %rbp
andq $0xffff, %rbx           # imm = 0xFFFF
je 0x8f55e
movzwl %cx, %esi
movq %r14, %rdi
vzeroupper
callq 0x8f594
movq 0x8(%r14), %rcx
vpmovsxbq 0x282de(%rip), %zmm3 # 0xb76b0
vpbroadcastq (%r12), %zmm1
xorl %esi, %esi
leaq (%rcx,%rbx,8), %rax
addq %r13, %rbx
andq %rbx, %r13
andl $0x7, %ebx
negq %rbx
vpbroadcastq %r13, %zmm0
leaq 0x8(%r13,%rbx), %rdx
vpbroadcastq %rsi, %zmm2
vporq %zmm3, %zmm2, %zmm2
vpcmpleuq %zmm0, %zmm2, %k1
vmovdqu64 %zmm1, (%rcx,%rsi,8) {%k1}
addq $0x8, %rsi
cmpq %rsi, %rdx
jne 0x8f3f6
movq 0x8(%rsp), %rbx
movq %rax, 0x8(%r14)
movq (%r14), %rcx
movq %rax, (%rcx)
movw %bp, 0x30(%rcx)
jmp 0x8f563
movzwl 0x40(%r14), %eax
movq %r14, %rdi
cmpq %r15, %rax
cmovbel %r15d, %eax
movzwl %ax, %esi
callq 0xc9d0
vpbroadcastq (%r12), %zmm1
vpmovsxbq 0x28257(%rip), %zmm2 # 0xb76b0
movq 0x8(%r14), %rcx
movabsq $0x1fffffffffffffff, %rdx # imm = 0x1FFFFFFFFFFFFFFF
movb $0x3d, %sil
addq %r15, %rdx
bzhiq %rsi, %rdx, %rsi
andl $0x7, %edx
negq %rdx
vpbroadcastq %rsi, %zmm0
leaq 0x8(%rsi,%rdx), %rdx
xorl %esi, %esi
leaq (%rcx,%r15,8), %rax
vpbroadcastq %rsi, %zmm3
vporq %zmm2, %zmm3, %zmm3
vpcmpleuq %zmm0, %zmm3, %k1
vmovdqu64 %zmm1, (%rcx,%rsi,8) {%k1}
addq $0x8, %rsi
cmpq %rsi, %rdx
jne 0x8f489
movl %r15d, %ebp
jmp 0x8f529
movq %rbx, %rbp
andq $0xffff, %rbx           # imm = 0xFFFF
je 0x8f58d
movzwl %cx, %esi
movq %r14, %rdi
vzeroupper
callq 0x8f594
movq 0x8(%r14), %rcx
vpmovsxbq 0x281d3(%rip), %zmm3 # 0xb76b0
vpbroadcastq (%r12), %zmm1
xorl %esi, %esi
leaq (%rcx,%rbx,8), %rax
addq %r13, %rbx
andq %rbx, %r13
andl $0x7, %ebx
negq %rbx
vpbroadcastq %r13, %zmm0
leaq 0x8(%r13,%rbx), %rdx
vpbroadcastq %rsi, %zmm2
vporq %zmm3, %zmm2, %zmm2
vpcmpleuq %zmm0, %zmm2, %k1
vmovdqu64 %zmm1, (%rcx,%rsi,8) {%k1}
addq $0x8, %rsi
cmpq %rsi, %rdx
jne 0x8f501
movq 0x8(%rsp), %rbx
movq %rax, 0x8(%r14)
movq (%r14), %rsi
movl %ebp, %ecx
movq %rax, (%rsi)
movw %bp, 0x30(%rsi)
movzwl %cx, %eax
addl %eax, %eax
addq 0x18(%rsi), %rax
movq %rax, 0x10(%r14)
addq %r15, 0x38(%r14)
vmovdqu 0x18(%r14), %xmm0
vmovdqu %xmm0, (%rbx)
movq 0x28(%r14), %rax
movq %rax, 0x10(%rbx)
jmp 0x8f578
movq 0x8(%rsp), %rbx
movq (%r14), %rax
movzwl 0x30(%rax), %ecx
addl %ecx, %ecx
addq 0x18(%rax), %rcx
movq %rcx, 0x10(%r14)
addq %r15, 0x38(%r14)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
movq 0x8(%rsp), %rbx
jmp 0x8f539