// File: /workspace/github_cpp_makefile_star2_O2/HQarroum[P]thread-pool/examples/working-with-tokens/./../../includes/concurrent_queue.hpp
// Function: bool moodycamel::ConcurrentQueue<std::function<void ()>, moodycamel::ConcurrentQueueDefaultTraits>::ExplicitProducer::enqueue_bulk<(moodycamel::ConcurrentQueue<std::function<void ()>, moodycamel::ConcurrentQueueDefaultTraits>::AllocationMode)0, std::function<void ()> const*>(std::function<void ()> const*, unsigned long)
bool MOODYCAMEL_NO_TSAN enqueue_bulk(It itemFirst, size_t count)
		{
			// First, we need to make sure we have enough room to enqueue all of the elements;
			// this means pre-allocating blocks and putting them in the block index (but only if
			// all the allocations succeeded).
			index_t startTailIndex = this->tailIndex.load(std::memory_order_relaxed);
			auto startBlock = this->tailBlock;
			auto originalBlockIndexFront = pr_blockIndexFront;
			auto originalBlockIndexSlotsUsed = pr_blockIndexSlotsUsed;
			
			Block* firstAllocatedBlock = nullptr;
			
			// Figure out how many blocks we'll need to allocate, and do so
			size_t blockBaseDiff = ((startTailIndex + count - 1) & ~static_cast<index_t>(BLOCK_SIZE - 1)) - ((startTailIndex - 1) & ~static_cast<index_t>(BLOCK_SIZE - 1));
			index_t currentTailIndex = (startTailIndex - 1) & ~static_cast<index_t>(BLOCK_SIZE - 1);
			if (blockBaseDiff > 0) {
				// Allocate as many blocks as possible from ahead
				while (blockBaseDiff > 0 && this->tailBlock != nullptr && this->tailBlock->next != firstAllocatedBlock && this->tailBlock->next->ConcurrentQueue::Block::template is_empty<explicit_context>()) {
					blockBaseDiff -= static_cast<index_t>(BLOCK_SIZE);
					currentTailIndex += static_cast<index_t>(BLOCK_SIZE);
					
					this->tailBlock = this->tailBlock->next;
					firstAllocatedBlock = firstAllocatedBlock == nullptr ? this->tailBlock : firstAllocatedBlock;
					
					auto& entry = blockIndex.load(std::memory_order_relaxed)->entries[pr_blockIndexFront];
					entry.base = currentTailIndex;
					entry.block = this->tailBlock;
					pr_blockIndexFront = (pr_blockIndexFront + 1) & (pr_blockIndexSize - 1);
				}
				
				// Now allocate as many blocks as necessary from the block pool
				while (blockBaseDiff > 0) {
					blockBaseDiff -= static_cast<index_t>(BLOCK_SIZE);
					currentTailIndex += static_cast<index_t>(BLOCK_SIZE);
					
					auto head = this->headIndex.load(std::memory_order_relaxed);
					assert(!details::circular_less_than<index_t>(currentTailIndex, head));
					bool full = !details::circular_less_than<index_t>(head, currentTailIndex + BLOCK_SIZE) || (MAX_SUBQUEUE_SIZE != details::const_numeric_max<size_t>::value && (MAX_SUBQUEUE_SIZE == 0 || MAX_SUBQUEUE_SIZE - BLOCK_SIZE < currentTailIndex - head));
					if (pr_blockIndexRaw == nullptr || pr_blockIndexSlotsUsed == pr_blockIndexSize || full) {
						MOODYCAMEL_CONSTEXPR_IF (allocMode == CannotAlloc) {
							// Failed to allocate, undo changes (but keep injected blocks)
							pr_blockIndexFront = originalBlockIndexFront;
							pr_blockIndexSlotsUsed = originalBlockIndexSlotsUsed;
							this->tailBlock = startBlock == nullptr ? firstAllocatedBlock : startBlock;
							return false;
						}
						else if (full || !new_block_index(originalBlockIndexSlotsUsed)) {
							// Failed to allocate, undo changes (but keep injected blocks)
							pr_blockIndexFront = originalBlockIndexFront;
							pr_blockIndexSlotsUsed = originalBlockIndexSlotsUsed;
							this->tailBlock = startBlock == nullptr ? firstAllocatedBlock : startBlock;
							return false;
						}
						
						// pr_blockIndexFront is updated inside new_block_index, so we need to
						// update our fallback value too (since we keep the new index even if we
						// later fail)
						originalBlockIndexFront = originalBlockIndexSlotsUsed;
					}
					
					// Insert a new block in the circular linked list
					auto newBlock = this->parent->ConcurrentQueue::template requisition_block<allocMode>();
					if (newBlock == nullptr) {
						pr_blockIndexFront = originalBlockIndexFront;
						pr_blockIndexSlotsUsed = originalBlockIndexSlotsUsed;
						this->tailBlock = startBlock == nullptr ? firstAllocatedBlock : startBlock;
						return false;
					}
					
#ifdef MCDBGQ_TRACKMEM
					newBlock->owner = this;
#endif
					newBlock->ConcurrentQueue::Block::template set_all_empty<explicit_context>();
					if (this->tailBlock == nullptr) {
						newBlock->next = newBlock;
					}
					else {
						newBlock->next = this->tailBlock->next;
						this->tailBlock->next = newBlock;
					}
					this->tailBlock = newBlock;
					firstAllocatedBlock = firstAllocatedBlock == nullptr ? this->tailBlock : firstAllocatedBlock;
					
					++pr_blockIndexSlotsUsed;
					
					auto& entry = blockIndex.load(std::memory_order_relaxed)->entries[pr_blockIndexFront];
					entry.base = currentTailIndex;
					entry.block = this->tailBlock;
					pr_blockIndexFront = (pr_blockIndexFront + 1) & (pr_blockIndexSize - 1);
				}
				
				// Excellent, all allocations succeeded. Reset each block's emptiness before we fill them up, and
				// publish the new block index front
				auto block = firstAllocatedBlock;
				while (true) {
					block->ConcurrentQueue::Block::template reset_empty<explicit_context>();
					if (block == this->tailBlock) {
						break;
					}
					block = block->next;
				}
				
				MOODYCAMEL_CONSTEXPR_IF (MOODYCAMEL_NOEXCEPT_CTOR(T, decltype(*itemFirst), new (static_cast<T*>(nullptr)) T(details::deref_noexcept(itemFirst)))) {
					blockIndex.load(std::memory_order_relaxed)->front.store((pr_blockIndexFront - 1) & (pr_blockIndexSize - 1), std::memory_order_release);
				}
			}
			
			// Enqueue, one block at a time
			index_t newTailIndex = startTailIndex + static_cast<index_t>(count);
			currentTailIndex = startTailIndex;
			auto endBlock = this->tailBlock;
			this->tailBlock = startBlock;
			assert((startTailIndex & static_cast<index_t>(BLOCK_SIZE - 1)) != 0 || firstAllocatedBlock != nullptr || count == 0);
			if ((startTailIndex & static_cast<index_t>(BLOCK_SIZE - 1)) == 0 && firstAllocatedBlock != nullptr) {
				this->tailBlock = firstAllocatedBlock;
			}
			while (true) {
				index_t stopIndex = (currentTailIndex & ~static_cast<index_t>(BLOCK_SIZE - 1)) + static_cast<index_t>(BLOCK_SIZE);
				if (details::circular_less_than<index_t>(newTailIndex, stopIndex)) {
					stopIndex = newTailIndex;
				}
				MOODYCAMEL_CONSTEXPR_IF (MOODYCAMEL_NOEXCEPT_CTOR(T, decltype(*itemFirst), new (static_cast<T*>(nullptr)) T(details::deref_noexcept(itemFirst)))) {
					while (currentTailIndex != stopIndex) {
						new ((*this->tailBlock)[currentTailIndex++]) T(*itemFirst++);
					}
				}
				else {
					MOODYCAMEL_TRY {
						while (currentTailIndex != stopIndex) {
							// Must use copy constructor even if move constructor is available
							// because we may have to revert if there's an exception.
							// Sorry about the horrible templated next line, but it was the only way
							// to disable moving *at compile time*, which is important because a type
							// may only define a (noexcept) move constructor, and so calls to the
							// cctor will not compile, even if they are in an if branch that will never
							// be executed
							new ((*this->tailBlock)[currentTailIndex]) T(details::nomove_if<!MOODYCAMEL_NOEXCEPT_CTOR(T, decltype(*itemFirst), new (static_cast<T*>(nullptr)) T(details::deref_noexcept(itemFirst)))>::eval(*itemFirst));
							++currentTailIndex;
							++itemFirst;
						}
					}
					MOODYCAMEL_CATCH (...) {
						// Oh dear, an exception's been thrown -- destroy the elements that
						// were enqueued so far and revert the entire bulk operation (we'll keep
						// any allocated blocks in our linked list for later, though).
						auto constructedStopIndex = currentTailIndex;
						auto lastBlockEnqueued = this->tailBlock;
						
						pr_blockIndexFront = originalBlockIndexFront;
						pr_blockIndexSlotsUsed = originalBlockIndexSlotsUsed;
						this->tailBlock = startBlock == nullptr ? firstAllocatedBlock : startBlock;
						
						if (!details::is_trivially_destructible<T>::value) {
							auto block = startBlock;
							if ((startTailIndex & static_cast<index_t>(BLOCK_SIZE - 1)) == 0) {
								block = firstAllocatedBlock;
							}
							currentTailIndex = startTailIndex;
							while (true) {
								stopIndex = (currentTailIndex & ~static_cast<index_t>(BLOCK_SIZE - 1)) + static_cast<index_t>(BLOCK_SIZE);
								if (details::circular_less_than<index_t>(constructedStopIndex, stopIndex)) {
									stopIndex = constructedStopIndex;
								}
								while (currentTailIndex != stopIndex) {
									(*block)[currentTailIndex++]->~T();
								}
								if (block == lastBlockEnqueued) {
									break;
								}
								block = block->next;
							}
						}
						MOODYCAMEL_RETHROW;
					}
				}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r12
movq %rdi, %r8
movq 0x20(%rdi), %r14
movq 0x40(%rdi), %rbp
movq 0x60(%rdi), %rax
movq %rax, 0x28(%rsp)
movq 0x70(%rdi), %r13
movq %rdx, 0x18(%rsp)
leaq (%r14,%rdx), %rcx
decq %rcx
andq $-0x20, %rcx
leaq -0x1(%r14), %rax
andq $-0x20, %rax
movq %rcx, %rbx
subq %rax, %rbx
movq %rdi, 0x20(%rsp)
je 0x43bf
movq %rcx, 0x10(%rsp)
movq %r13, 0x8(%rsp)
movq %rax, 0x30(%rsp)
leaq 0x20(%rax), %r13
xorl %r9d, %r9d
movq %rbp, %rax
movq $0x0, (%rsp)
cmpq %r9, %rbx
je 0x423f
testq %rax, %rax
je 0x423f
movq 0x400(%rax), %rdi
cmpq (%rsp), %rdi
je 0x423f
movq %r9, %r15
callq 0x3c8e
movq %r15, %r9
movq 0x20(%rsp), %r8
testb %al, %al
je 0x423f
leaq (%r9,%r13), %rcx
movq 0x40(%r8), %rax
movq 0x400(%rax), %rax
movq %rax, 0x40(%r8)
movq (%rsp), %rdx
testq %rdx, %rdx
cmoveq %rax, %rdx
movq %rdx, (%rsp)
movq 0x58(%r8), %rdx
movq 0x10(%rdx), %rdx
movq 0x70(%r8), %rsi
movq %rsi, %rdi
shlq $0x4, %rdi
movq %rcx, (%rdx,%rdi)
movq %rax, 0x8(%rdx,%rdi)
incq %rsi
movq 0x68(%r8), %rcx
decq %rcx
andq %rsi, %rcx
movq %rcx, 0x70(%r8)
addq $0x20, %r9
jmp 0x41bf
pushq $-0x40
popq %rax
movq 0x30(%rsp), %rsi
subq %rsi, %rax
movq %rax, 0x40(%rsp)
movq %rsi, %rax
subq 0x10(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x20(%r9), %rdi
negq %r9
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
incq %rax
movq %rax, 0x38(%rsp)
movq 0x8(%rsp), %r13
cmpq %r9, 0x48(%rsp)
je 0x443b
leaq (%rsi,%rdi), %r15
movq 0x28(%r8), %rax
movq %r15, %rcx
subq %rax, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
cmpq %rdx, %rcx
ja 0x4487
movq %rdi, 0x8(%rsp)
movq %r9, 0x10(%rsp)
movq 0x40(%rsp), %rcx
addq %r9, %rcx
addq %rcx, %rax
cmpq $0x0, 0x80(%r8)
je 0x42db
cmpq 0x38(%rsp), %rax
jb 0x42db
movq 0x68(%r8), %rcx
cmpq %rcx, 0x60(%r8)
je 0x42db
movq %r13, %rbx
jmp 0x4303
cmpq 0x38(%rsp), %rax
jb 0x441d
movq %r8, %rdi
movq 0x28(%rsp), %rbx
movq %rbx, %rsi
callq 0x3a30
movq 0x20(%rsp), %r8
testb %al, %al
je 0x441d
movq %r15, 0x50(%rsp)
movq %rbx, %r15
movq 0x50(%r8), %rdi
movq %r8, %rbx
callq 0x4642
testq %rax, %rax
je 0x445f
movq %rax, %r13
movq %rax, %rdi
callq 0x466a
movq 0x40(%rbx), %rax
testq %rax, %rax
movq %rbx, %r8
je 0x434d
movq 0x400(%rax), %rcx
addq $0x400, %rax            # imm = 0x400
movq %rcx, 0x400(%r13)
jmp 0x4354
leaq 0x400(%r13), %rax
movq 0x30(%rsp), %rsi
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %rdi
movq %r13, (%rax)
movq (%rsp), %rax
testq %rax, %rax
cmoveq %r13, %rax
movq %rax, (%rsp)
movq %r13, 0x40(%r8)
incq 0x60(%r8)
movq 0x58(%r8), %rax
movq 0x10(%rax), %rax
movq 0x70(%r8), %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
movq 0x50(%rsp), %r11
movq %r11, (%rax,%rdx)
movq %r13, 0x8(%rax,%rdx)
incq %rcx
movq 0x68(%r8), %rax
decq %rax
andq %rcx, %rax
movq %rax, 0x70(%r8)
addq $-0x20, %r9
addq $0x20, %rdi
movq %r15, %r13
jmp 0x427a
movq $0x0, (%rsp)
movq %rbp, %rbx
movq %rbp, 0x40(%r8)
cmpq $0x0, 0x18(%rsp)
je 0x43e9
movl %r14d, %eax
andl $0x1f, %eax
jne 0x43e9
cmpq $0x0, (%rsp)
je 0x44a6
movq %rbx, 0x10(%rsp)
movq %r13, 0x8(%rsp)
addq %r14, 0x18(%rsp)
testb $0x1f, %r14b
jne 0x4482
movq (%rsp), %rcx
movq %rcx, %rax
movq %r14, %rbx
movq %r14, %r13
testq %rcx, %rcx
jne 0x44c5
jmp 0x44cc
movq %r13, 0x70(%r8)
movq 0x28(%rsp), %rax
movq %rax, 0x60(%r8)
testq %rbp, %rbp
movq (%rsp), %rax
cmovneq %rbp, %rax
movq %rax, 0x40(%r8)
jmp 0x447b
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x4680
movq 0x20(%rsp), %r8
cmpq 0x40(%r8), %rbx
je 0x43ca
movq 0x400(%rbx), %rbx
jmp 0x443f
movq %r15, 0x70(%rbx)
movq 0x28(%rsp), %rax
movq %rax, 0x60(%rbx)
testq %rbp, %rbp
movq (%rsp), %rax
cmovneq %rbp, %rax
movq %rax, 0x40(%rbx)
xorl %eax, %eax
jmp 0x456a
movq %r14, %r13
jmp 0x44cc
leaq 0x166c(%rip), %rdi      # 0x5afa
leaq 0xbd2(%rip), %rsi       # 0x5067
leaq 0x169c(%rip), %rcx      # 0x5b38
movl $0x81c, %edx            # imm = 0x81C
callq 0x2100
leaq 0x17b0(%rip), %rdi      # 0x5c5d
leaq 0xbb3(%rip), %rsi       # 0x5067
leaq 0x167d(%rip), %rcx      # 0x5b38
movl $0x868, %edx            # imm = 0x868
callq 0x2100
movq %rax, 0x40(%r8)
movq %rbx, %r13
movq %r13, %rbx
andq $-0x20, %rbx
addq $0x20, %rbx
movq 0x18(%rsp), %rdx
movq %rdx, %rax
subq %rbx, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpq %rcx, %rax
cmovaq %rdx, %rbx
pushq $0x20
popq %r15
subq %r13, %r15
movq 0x40(%r8), %rdi
cmpq %r13, %rbx
je 0x4528
movl %r13d, %eax
andl $0x1f, %eax
shll $0x5, %eax
addq %rax, %rdi
movq %r12, %rsi
callq 0x4696
incq %r13
addq $0x20, %r12
decq %r15
movq 0x20(%rsp), %r8
jmp 0x44fa
cmpq 0x10(%rsp), %rdi
je 0x4538
movq 0x400(%rdi), %rax
jmp 0x44c5
cmpq 0x18(%rsp), %rbx
jne 0x4579
cmpq $0x0, (%rsp)
je 0x455f
movq 0x58(%r8), %rax
movq 0x68(%r8), %rcx
movq 0x70(%r8), %rdx
decq %rdx
decq %rcx
andq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq 0x18(%rsp), %rax
movq %rax, 0x20(%r8)
movb $0x1, %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x174a(%rip), %rdi      # 0x5cca
leaq 0xae0(%rip), %rsi       # 0x5067
leaq 0x15aa(%rip), %rcx      # 0x5b38
movl $0x8a9, %edx            # imm = 0x8A9
callq 0x2100
movq %rax, %rdi
callq 0x2090
testq %rbp, %rbp
movq %rbp, %rax
movq (%rsp), %rsi
cmoveq %rsi, %rax
testb $0x1f, %r14b
movq 0x20(%rsp), %rcx
movq 0x40(%rcx), %rbx
movq 0x8(%rsp), %rdx
movq %rdx, 0x70(%rcx)
movq 0x28(%rsp), %rdx
movq %rdx, 0x60(%rcx)
movq %rax, 0x40(%rcx)
cmoveq %rsi, %rbp
negq %r15
movq %r14, %rdi
andq $-0x20, %r14
movq %r15, %rax
subq %r14, %rax
addq $0x20, %r14
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpq %rcx, %rax
cmovaq %r13, %r14
cmpq %rdi, %r14
je 0x4616
leaq 0x1(%rdi), %r12
andl $0x1f, %edi
shll $0x5, %edi
addq %rbp, %rdi
callq 0x2514
movq %r12, %rdi
jmp 0x45fa
cmpq %rbx, %rbp
je 0x4624
movq 0x400(%rbp), %rbp
jmp 0x45d8
callq 0x21c0
movq %rax, %rbx
callq 0x21f0
movq %rbx, %rdi
callq 0x2230
movq %rax, %rdi
callq 0x269b
nop