// File: /workspace/github_cpp_makefile_star2_O3/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 0x4e69
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 0x4e64
cmpq %r8, %rdx
cmovbq %rdx, %r8
jbe 0x4d33
subq %r8, %rdx
lock
addq %rdx, 0x38(%rdi)
movq %r8, %r13
lock
xaddq %r13, 0x28(%rdi)
movq 0x58(%rdi), %rdi
movq 0x8(%rdi), %rax
movq (%rdi), %r9
movq 0x10(%rdi), %rcx
movq %rax, %rdx
shlq $0x4, %rdx
movq %r13, %rsi
andq $-0x20, %rsi
subq (%rcx,%rdx), %rsi
shrq $0x5, %rsi
addq %rax, %rsi
decq %r9
andq %rsi, %r9
movq %r8, 0x18(%rsp)
leaq (%r8,%r13), %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
movq %rdi, 0x8(%rsp)
movq %rcx, (%rsp)
movq %r13, %rbp
andq $-0x20, %rbp
addq $0x20, %rbp
movq %rcx, %rax
subq %rbp, %rax
cmpq %rdx, %rax
cmovaq %rcx, %rbp
cmpq %rbp, %r13
jne 0x4da8
jmp 0x4e48
movq 0x10(%rdi), %rax
movq %r9, 0x10(%rsp)
movq %r9, %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rbx
movq %r13, 0x20(%rsp)
movl %r13d, %r12d
andl $0x1f, %r12d
shll $0x5, %r12d
leaq (%rbx,%r12), %r15
movq (%r14), %rdi
leaq 0x20(%rdi), %rax
movq %rax, (%r14)
movq %r15, %rsi
callq 0x5130
movq 0x10(%rbx,%r12), %rax
testq %rax, %rax
je 0x4dfa
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
incq %r13
cmpq %r13, %rbp
jne 0x4dc2
movq 0x20(%rsp), %rcx
movq %rcx, %rax
subq %rbp, %rax
je 0x4e2d
andl $0x1f, %ecx
subq %rcx, %rbx
addq $0x430, %rbx            # imm = 0x430
movb (%rbx,%rax), %cl
testb $0x1, %cl
jne 0x4e7a
movb $0x1, (%rbx,%rax)
incq %rax
jne 0x4e1c
movq %rbp, %r13
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %r9
movq (%rsp), %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
incq %r9
movq (%rdi), %rax
decq %rax
andq %rax, %r9
cmpq %rcx, %r13
jne 0x4d86
movq 0x18(%rsp), %rax
jmp 0x4e6b
lock
addq %rdx, 0x38(%rdi)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2547(%rip), %rdi      # 0x73c8
leaq 0x2256(%rip), %rsi      # 0x70de
leaq 0x256c(%rip), %rcx      # 0x73fb
movl $0x642, %edx            # imm = 0x642
callq 0x3150
movq %rax, %rdi
callq 0x3ae9
nop