// File: /workspace/github_cpp_makefile_star2_O2/HQarroum[P]thread-pool/examples/one-producer-many-consumers/./../../includes/concurrent_queue.hpp
// Function: unsigned long moodycamel::ConcurrentQueue<std::function<void ()>, moodycamel::ConcurrentQueueDefaultTraits>::ExplicitProducer::dequeue_bulk<std::function<void ()>*>(std::function<void ()>*&, unsigned long)
size_t dequeue_bulk(It& itemFirst, size_t max)
		{
			auto tail = this->tailIndex.load(std::memory_order_relaxed);
			auto overcommit = this->dequeueOvercommit.load(std::memory_order_relaxed);
			auto desiredCount = static_cast<size_t>(tail - (this->dequeueOptimisticCount.load(std::memory_order_relaxed) - overcommit));
			if (details::circular_less_than<size_t>(0, desiredCount)) {
				desiredCount = desiredCount < max ? desiredCount : max;
				std::atomic_thread_fence(std::memory_order_acquire);
				
				auto myDequeueCount = this->dequeueOptimisticCount.fetch_add(desiredCount, std::memory_order_relaxed);
				
				tail = this->tailIndex.load(std::memory_order_acquire);
				auto actualCount = static_cast<size_t>(tail - (myDequeueCount - overcommit));
				if (details::circular_less_than<size_t>(0, actualCount)) {
					actualCount = desiredCount < actualCount ? desiredCount : actualCount;
					if (actualCount < desiredCount) {
						this->dequeueOvercommit.fetch_add(desiredCount - actualCount, std::memory_order_release);
					}
					
					// Get the first index. Note that since there's guaranteed to be at least actualCount elements, this
					// will never exceed tail.
					auto firstIndex = this->headIndex.fetch_add(actualCount, std::memory_order_acq_rel);
					
					// Determine which block the first element is in
					auto localBlockIndex = blockIndex.load(std::memory_order_acquire);
					auto localBlockIndexHead = localBlockIndex->front.load(std::memory_order_acquire);
					
					auto headBase = localBlockIndex->entries[localBlockIndexHead].base;
					auto firstBlockBaseIndex = firstIndex & ~static_cast<index_t>(BLOCK_SIZE - 1);
					auto offset = static_cast<size_t>(static_cast<typename std::make_signed<index_t>::type>(firstBlockBaseIndex - headBase) / BLOCK_SIZE);
					auto indexIndex = (localBlockIndexHead + offset) & (localBlockIndex->size - 1);
					
					// Iterate the blocks and dequeue
					auto index = firstIndex;
					do {
						auto firstIndexInBlock = index;
						index_t endIndex = (index & ~static_cast<index_t>(BLOCK_SIZE - 1)) + static_cast<index_t>(BLOCK_SIZE);
						endIndex = details::circular_less_than<index_t>(firstIndex + static_cast<index_t>(actualCount), endIndex) ? firstIndex + static_cast<index_t>(actualCount) : endIndex;
						auto block = localBlockIndex->entries[indexIndex].block;
						if (MOODYCAMEL_NOEXCEPT_ASSIGN(T, T&&, details::deref_noexcept(itemFirst) = std::move((*(*block)[index])))) {
							while (index != endIndex) {
								auto& el = *((*block)[index]);
								*itemFirst++ = std::move(el);
								el.~T();
								++index;
							}
						}
						else {
							MOODYCAMEL_TRY {
								while (index != endIndex) {
									auto& el = *((*block)[index]);
									*itemFirst = std::move(el);
									++itemFirst;
									el.~T();
									++index;
								}
							}
							MOODYCAMEL_CATCH (...) {
								// It's too late to revert the dequeue, but we can make sure that all
								// the dequeued objects are properly destroyed and the block index
								// (and empty count) are properly updated before we propagate the exception
								do {
									block = localBlockIndex->entries[indexIndex].block;
									while (index != endIndex) {
										(*block)[index++]->~T();
									}
									block->ConcurrentQueue::Block::template set_many_empty<explicit_context>(firstIndexInBlock, static_cast<size_t>(endIndex - firstIndexInBlock));
									indexIndex = (indexIndex + 1) & (localBlockIndex->size - 1);
									
									firstIndexInBlock = index;
									endIndex = (index & ~static_cast<index_t>(BLOCK_SIZE - 1)) + static_cast<index_t>(BLOCK_SIZE);
									endIndex = details::circular_less_than<index_t>(firstIndex + static_cast<index_t>(actualCount), endIndex) ? firstIndex + static_cast<index_t>(actualCount) : endIndex;
								} while (index != firstIndex + actualCount);
								
								MOODYCAMEL_RETHROW;
							}
						}
						block->ConcurrentQueue::Block::template set_many_empty<explicit_context>(firstIndexInBlock, static_cast<size_t>(endIndex - firstIndexInBlock));
						indexIndex = (indexIndex + 1) & (localBlockIndex->size - 1);
					} while (index != firstIndex + actualCount);
					
					return actualCount;
				}
				else {
					// Wasn't anything to dequeue after all; make the effective dequeue count eventually consistent
					this->dequeueOvercommit.fetch_add(desiredCount, std::memory_order_release);
				}
			}
			
			return 0;
		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq 0x20(%rdi), %rcx
movq 0x38(%rdi), %r8
movq 0x30(%rdi), %rsi
movq %r8, %rax
subq %rsi, %rax
addq %rcx, %rax
testq %rax, %rax
jle 0x4761
cmpq %rdx, %rax
cmovbq %rax, %rdx
movq %rdx, %rax
lock
xaddq %rax, 0x30(%rdi)
movq 0x20(%rdi), %rcx
subq %rax, %r8
addq %rcx, %r8
testq %r8, %r8
jle 0x475c
cmpq %r8, %rdx
cmovbq %rdx, %r8
jbe 0x466d
subq %r8, %rdx
lock
addq %rdx, 0x38(%rdi)
movq %r8, %rbp
lock
xaddq %rbp, 0x28(%rdi)
movq 0x58(%rdi), %rdi
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
movq %rax, %rdx
shlq $0x4, %rdx
movq %rbp, %rsi
andq $-0x20, %rsi
subq (%rcx,%rdx), %rsi
movq (%rdi), %rbx
shrq $0x5, %rsi
addq %rax, %rsi
decq %rbx
andq %rsi, %rbx
movq %r8, 0x8(%rsp)
leaq (%r8,%rbp), %rcx
movq %rbp, %r15
movq %rdi, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
andq $-0x20, %r15
addq $0x20, %r15
movq %rcx, %rax
subq %r15, %rax
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
cmpq %rdx, %rax
cmovaq %rcx, %r15
movq 0x10(%rdi), %rax
movq %rbx, %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %r12
movq %rbp, 0x20(%rsp)
cmpq %rbp, %r15
je 0x4720
movl %ebp, %r13d
andl $0x1f, %r13d
shll $0x5, %r13d
addq %r12, %r13
movq (%r14), %rdi
leaq 0x20(%rdi), %rax
movq %rax, (%r14)
movq %r13, %rsi
callq 0x48e6
movq %r13, %rdi
callq 0x5276
incq %rbp
jmp 0x46ee
movq %r15, %rdx
movq 0x20(%rsp), %rsi
subq %rsi, %rdx
movq %r12, %rdi
callq 0x4948
incq %rbx
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
decq %rax
andq %rax, %rbx
movq %r15, %rbp
movq 0x10(%rsp), %rcx
cmpq %rcx, %r15
jne 0x46ba
movq 0x8(%rsp), %rax
jmp 0x4763
lock
addq %rdx, 0x38(%rdi)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq