// File: /workspace/github_cpp_makefile_star2_O1/HQarroum[P]thread-pool/examples/one-producer-many-consumers/./../../includes/concurrent_queue.hpp
// Function: unsigned long moodycamel::ConcurrentQueue<std::function<void ()>, moodycamel::ConcurrentQueueDefaultTraits>::ImplicitProducer::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);
					
					// Iterate the blocks and dequeue
					auto index = firstIndex;
					BlockIndexHeader* localBlockIndex;
					auto indexIndex = get_block_index_index_for_index(index, localBlockIndex);
					do {
						auto blockStartIndex = 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 entry = localBlockIndex->index[indexIndex];
						auto block = entry->value.load(std::memory_order_relaxed);
						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 (...) {
								do {
									entry = localBlockIndex->index[indexIndex];
									block = entry->value.load(std::memory_order_relaxed);
									while (index != endIndex) {
										(*block)[index++]->~T();
									}
									
									if (block->ConcurrentQueue::Block::template set_many_empty<implicit_context>(blockStartIndex, static_cast<size_t>(endIndex - blockStartIndex))) {
#ifdef MCDBGQ_NOLOCKFREE_IMPLICITPRODBLOCKINDEX
										debug::DebugLock lock(mutex);
#endif
										entry->value.store(nullptr, std::memory_order_relaxed);
										this->parent->add_block_to_free_list(block);
									}
									indexIndex = (indexIndex + 1) & (localBlockIndex->capacity - 1);
									
									blockStartIndex = 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;
							}
						}
						if (block->ConcurrentQueue::Block::template set_many_empty<implicit_context>(blockStartIndex, static_cast<size_t>(endIndex - blockStartIndex))) {
							{
#ifdef MCDBGQ_NOLOCKFREE_IMPLICITPRODBLOCKINDEX
								debug::DebugLock lock(mutex);
#endif
								// Note that the set_many_empty above did a release, meaning that anybody who acquires the block
								// we're about to free can use it safely since our writes (and reads!) will have happened-before then.
								entry->value.store(nullptr, std::memory_order_relaxed);
							}
							this->parent->add_block_to_free_list(block);		// releases the above store
						}
						indexIndex = (indexIndex + 1) & (localBlockIndex->capacity - 1);
					} while (index != firstIndex + actualCount);
					
					return actualCount;
				}
				else {
					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 $0x48, %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 0x4beb
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 0x4be1
movq %r8, %r9
cmpq %r8, %rdx
cmovbq %rdx, %r9
jbe 0x4a28
subq %r9, %rdx
lock
addq %rdx, 0x38(%rdi)
movq %r9, %rbx
lock
xaddq %rbx, 0x28(%rdi)
movq 0x60(%rdi), %r10
movq 0x8(%r10), %rcx
movq 0x18(%r10), %rax
movq (%rax,%rcx,8), %rdx
movq (%rdx), %rdx
cmpq $0x1, %rdx
je 0x4c3a
movq %r8, 0x10(%rsp)
movq %rbx, %rsi
andq $-0x20, %rsi
movq %rsi, %r8
subq %rdx, %r8
shrq $0x5, %r8
addq %rcx, %r8
movq (%r10), %r11
decq %r11
andq %r8, %r11
movq (%rax,%r11,8), %rax
movq (%rax), %rcx
cmpq %rsi, %rcx
jne 0x4c1b
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x4c1b
movq %r9, 0x8(%rsp)
leaq (%rbx,%r9), %rsi
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
movq %rdi, 0x28(%rsp)
movq %r10, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rbx, %r13
andq $-0x20, %r13
addq $0x20, %r13
movq %rsi, %rax
subq %r13, %rax
cmpq %r8, %rax
cmovaq %rsi, %r13
movq 0x18(%r10), %rax
movq (%rax,%r11,8), %rcx
movq 0x8(%rcx), %r15
movq %r13, %rdx
subq %rbx, %rdx
je 0x4b52
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r11, 0x40(%rsp)
movl %ebx, %ebp
andl $0x1f, %ebp
shll $0x5, %ebp
leaq (%r15,%rbp), %r12
movq (%r14), %rdi
leaq 0x20(%rdi), %rax
movq %rax, (%r14)
movq %r12, %rsi
callq 0x4c62
movq 0x10(%r15,%rbp), %rax
testq %rax, %rax
je 0x4b1f
movq %r12, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq *%rax
incq %rbx
cmpq %rbx, %r13
jne 0x4aea
movq %r13, %rbx
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %r10
movq 0x40(%rsp), %r11
movq 0x18(%rsp), %rsi
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %rdx
movq %rdx, %rax
lock
xaddq %rax, 0x408(%r15)
addq %rdx, %rax
cmpq $0x21, %rax
jae 0x4bfc
cmpq $0x20, %rax
jne 0x4bc0
movq $0x0, 0x8(%rcx)
movq 0x50(%rdi), %rcx
movl $0x80000000, %eax       # imm = 0x80000000
lock
xaddl %eax, 0x430(%r15)
testl %eax, %eax
jne 0x4bc0
movq 0x28(%rcx), %rax
movq %rax, 0x438(%r15)
movl $0x1, 0x430(%r15)
lock
cmpxchgq %r15, 0x28(%rcx)
je 0x4bc0
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
lock
xaddl %edx, 0x430(%r15)
cmpl $0x1, %edx
je 0x4b93
incq %r11
movq (%r10), %rax
decq %rax
andq %rax, %r11
cmpq %rsi, %rbx
jne 0x4aaf
movq 0x10(%rsp), %r8
movq 0x8(%rsp), %rax
jmp 0x4be6
lock
addq %rdx, 0x38(%rdi)
testq %r8, %r8
jg 0x4bed
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x29f6(%rip), %rdi      # 0x75f9
leaq 0x2434(%rip), %rsi      # 0x703e
leaq 0x2a06(%rip), %rcx      # 0x7617
movl $0x64a, %edx            # imm = 0x64A
callq 0x3150
leaq 0x293c(%rip), %rdi      # 0x755e
leaq 0x2415(%rip), %rsi      # 0x703e
leaq 0x284c(%rip), %rcx      # 0x747c
movl $0xb81, %edx            # imm = 0xB81
callq 0x3150
leaq 0x281c(%rip), %rdi      # 0x745d
leaq 0x23f6(%rip), %rsi      # 0x703e
leaq 0x282d(%rip), %rcx      # 0x747c
movl $0xb7c, %edx            # imm = 0xB7C
callq 0x3150
movq %rax, %rdi
callq 0x3b0b
nop