// 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>::try_dequeue_bulk<std::function<void ()>*&>(moodycamel::ConsumerToken&, std::function<void ()>*&, unsigned long)
size_t try_dequeue_bulk(consumer_token_t& token, It itemFirst, size_t max)
	{
		if (token.desiredProducer == nullptr || token.lastKnownGlobalOffset != globalExplicitConsumerOffset.load(std::memory_order_relaxed)) {
			if (!update_current_producer_after_rotation(token)) {
				return 0;
			}
		}
		
		size_t count = static_cast<ProducerBase*>(token.currentProducer)->dequeue_bulk(itemFirst, max);
		if (count == max) {
			if ((token.itemsConsumedFromCurrent += static_cast<std::uint32_t>(max)) >= EXPLICIT_CONSUMER_CONSUMPTION_QUOTA_BEFORE_ROTATE) {
				globalExplicitConsumerOffset.fetch_add(1, std::memory_order_relaxed);
			}
			return max;
		}
		token.itemsConsumedFromCurrent += static_cast<std::uint32_t>(count);
		max -= count;
		
		auto tail = producerListTail.load(std::memory_order_acquire);
		auto ptr = static_cast<ProducerBase*>(token.currentProducer)->next_prod();
		if (ptr == nullptr) {
			ptr = tail;
		}
		while (ptr != static_cast<ProducerBase*>(token.currentProducer)) {
			auto dequeued = ptr->dequeue_bulk(itemFirst, max);
			count += dequeued;
			if (dequeued != 0) {
				token.currentProducer = ptr;
				token.itemsConsumedFromCurrent = static_cast<std::uint32_t>(dequeued);
			}
			if (dequeued == max) {
				break;
			}
			max -= dequeued;
			ptr = ptr->next_prod();
			if (ptr == nullptr) {
				ptr = tail;
			}
		}
		return count;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
cmpq $0x0, 0x18(%rsi)
je 0x43c4
movl 0x260(%r12), %eax
cmpl %eax, 0x4(%r14)
je 0x448d
movq (%r12), %rdi
movq 0x18(%r14), %rax
movq %rdi, %rcx
orq %rax, %rcx
setne %cl
je 0x44a8
movl 0x8(%r12), %r8d
movl 0x260(%r12), %esi
testq %rax, %rax
jne 0x442f
movl (%r14), %eax
xorl %edx, %edx
divl %r8d
leaq 0x8(%rdi), %rax
testq %rdi, %rdi
notl %edx
cmoveq %rdi, %rax
movq %rax, 0x18(%r14)
addl %r8d, %edx
je 0x442f
movq %rax, %r9
movq (%r9), %r10
leaq -0x8(%r10), %r9
testq %r10, %r10
cmoveq %r10, %r9
addq $0x8, %r9
testq %r10, %r10
cmoveq %rax, %r9
decl %edx
jne 0x440e
movq %r9, 0x18(%r14)
movl %esi, %eax
subl 0x4(%r14), %eax
cmpl %r8d, %eax
jb 0x4441
xorl %edx, %edx
divl %r8d
movl %edx, %eax
testl %eax, %eax
je 0x4475
leaq 0x8(%rdi), %rdx
testq %rdi, %rdi
movq 0x18(%r14), %r8
cmoveq %rdi, %rdx
movq (%r8), %rdi
leaq -0x8(%rdi), %r8
testq %rdi, %rdi
cmoveq %rdi, %r8
addq $0x8, %r8
testq %rdi, %rdi
cmoveq %rdx, %r8
decl %eax
jne 0x4454
movq %r8, 0x18(%r14)
movl %esi, 0x4(%r14)
movq 0x18(%r14), %rax
movq %rax, 0x10(%r14)
movl $0x0, 0x8(%r14)
testb %cl, %cl
je 0x44a8
movq 0x10(%r14), %rax
leaq -0x8(%rax), %rdi
cmpb $0x1, 0x40(%rax)
jne 0x44bc
movq %r15, %rsi
movq %rbx, %rdx
callq 0x47d8
jmp 0x44c7
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rsi
movq %rbx, %rdx
callq 0x49c2
movq %rbx, %r13
movl 0x8(%r14), %ecx
subq %rax, %r13
jne 0x44ec
addl %ebx, %ecx
movl %ecx, 0x8(%r14)
cmpl $0x100, %ecx            # imm = 0x100
jb 0x44aa
lock
incl 0x260(%r12)
jmp 0x44aa
addl %eax, %ecx
movl %ecx, 0x8(%r14)
movq (%r12), %rbp
movq 0x10(%r14), %rcx
movq (%rcx), %rcx
leaq -0x8(%rcx), %r12
testq %rcx, %rcx
cmoveq %rbp, %r12
movq %rax, %rbx
movq 0x10(%r14), %rax
leaq -0x8(%rax), %rcx
testq %rax, %rax
cmoveq %rax, %rcx
cmpq %rcx, %r12
je 0x44aa
cmpb $0x1, 0x48(%r12)
jne 0x4537
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x47d8
jmp 0x4545
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x49c2
testq %rax, %rax
je 0x4557
leaq 0x8(%r12), %rcx
movq %rcx, 0x10(%r14)
movl %eax, 0x8(%r14)
movq %r13, %rcx
subq %rax, %rcx
jne 0x4564
movq %r13, %rcx
jmp 0x4574
movq 0x8(%r12), %rdx
leaq -0x8(%rdx), %r12
testq %rdx, %rdx
cmoveq %rbp, %r12
addq %rax, %rbx
cmpq %rax, %r13
movq %rcx, %r13
jne 0x450b
jmp 0x44aa