// 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>::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 0x48f7
movl 0x260(%r12), %eax
cmpl %eax, 0x4(%r14)
jne 0x48f7
movq 0x10(%r14), %rsi
jmp 0x49b9
movq (%r12), %rdi
movq 0x18(%r14), %rsi
movq %rdi, %rax
orq %rsi, %rax
je 0x495d
movl 0x8(%r12), %r8d
movl 0x260(%r12), %ecx
testq %rsi, %rsi
jne 0x4967
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 0x4964
movq %rax, %rsi
movq (%rsi), %r9
leaq -0x8(%r9), %rsi
testq %r9, %r9
cmoveq %r9, %rsi
addq $0x8, %rsi
testq %r9, %r9
cmoveq %rax, %rsi
decl %edx
jne 0x493a
movq %rsi, 0x18(%r14)
jmp 0x4967
xorl %ebx, %ebx
jmp 0x49fe
movq %rax, %rsi
movl %ecx, %eax
subl 0x4(%r14), %eax
cmpl %r8d, %eax
jb 0x4979
xorl %edx, %edx
divl %r8d
movl %edx, %eax
testl %eax, %eax
je 0x49a9
leaq 0x8(%rdi), %rdx
testq %rdi, %rdi
cmoveq %rdi, %rdx
movq (%rsi), %rdi
leaq -0x8(%rdi), %rsi
testq %rdi, %rdi
cmoveq %rdi, %rsi
addq $0x8, %rsi
testq %rdi, %rdi
cmoveq %rdx, %rsi
decl %eax
jne 0x4988
movq %rsi, 0x18(%r14)
movl %ecx, 0x4(%r14)
movq %rsi, 0x10(%r14)
movl $0x0, 0x8(%r14)
leaq -0x8(%rsi), %rdi
cmpb $0x1, 0x40(%rsi)
jne 0x49d0
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4cd0
jmp 0x49db
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4ea2
movq %rbx, %r13
movl 0x8(%r14), %ecx
subq %rax, %r13
jne 0x4a10
addl %ebx, %ecx
movl %ecx, 0x8(%r14)
cmpl $0x100, %ecx            # imm = 0x100
jb 0x49fe
lock
incl 0x260(%r12)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl %eax, %ecx
movl %ecx, 0x8(%r14)
movq (%r12), %rbp
movq 0x10(%r14), %rcx
movq (%rcx), %rdx
leaq -0x8(%rdx), %r12
testq %rdx, %rdx
cmoveq %rbp, %r12
addq $-0x8, %rcx
movq %rax, %rbx
cmpq %rcx, %r12
je 0x49fe
cmpb $0x1, 0x48(%r12)
jne 0x4a50
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x4cd0
jmp 0x4a5e
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x4ea2
testq %rax, %rax
je 0x4a70
leaq 0x8(%r12), %rcx
movq %rcx, 0x10(%r14)
movl %eax, 0x8(%r14)
addq %rax, %rbx
subq %rax, %r13
je 0x49fe
movq 0x8(%r12), %rax
leaq -0x8(%rax), %r12
testq %rax, %rax
cmoveq %rbp, %r12
movq 0x10(%r14), %rax
leaq -0x8(%rax), %rcx
testq %rax, %rax
cmoveq %rax, %rcx
jmp 0x4a33
nop