// File: 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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x40(%rbp)
movq %rsi, -0x48(%rbp)
movq %rdx, -0x50(%rbp)
movq %rcx, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x7311
movq -0x80(%rbp), %rax
movq -0x48(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, -0x94(%rbp)
addq $0x260, %rax            # imm = 0x260
movq %rax, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0xc(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x58d0
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x84(%rbp)
decl %eax
subl $0x2, %eax
jb 0x72ec
jmp 0x72d1
movl -0x84(%rbp), %eax
subl $0x5, %eax
je 0x72fa
jmp 0x72de
movq -0x90(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x7306
movq -0x90(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x7306
movq -0x90(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x7331
movq -0x80(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x8fc0
testb $0x1, %al
jne 0x732f
movq $0x0, -0x38(%rbp)
jmp 0x75f5
jmp 0x7331
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x735a
movq -0xa0(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0xa8(%rbp)
jmp 0x7365
xorl %eax, %eax
movq %rax, -0xa8(%rbp)
jmp 0x7365
movq -0xa8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x9380
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jne 0x7465
movq -0x58(%rbp), %rax
movq -0x48(%rbp), %rcx
addl 0x8(%rcx), %eax
movl %eax, 0x8(%rcx)
cmpl $0x100, %eax            # imm = 0x100
jb 0x7458
movq -0x80(%rbp), %rax
addq $0x260, %rax            # imm = 0x260
movq %rax, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl -0x28(%rbp), %eax
movl -0x24(%rbp), %ecx
movl %ecx, -0x2c(%rbp)
decl %eax
movl %eax, %ecx
movq %rcx, -0xb0(%rbp)
subl $0x4, %eax
ja 0x73fb
movq -0xb0(%rbp), %rax
leaq 0x10c32(%rip), %rcx     # 0x18024
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0xb8(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
jmp 0x7458
movq -0xb8(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
jmp 0x7458
movq -0xb8(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
jmp 0x7458
movq -0xb8(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
jmp 0x7458
movq -0xb8(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x75f5
movq -0x80(%rbp), %rdi
movq -0x60(%rbp), %rax
movl %eax, %ecx
movq -0x48(%rbp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movq -0x60(%rbp), %rcx
movq -0x58(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x2, %esi
callq 0x6080
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, %rax
je 0x74bf
movq -0xc0(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0xc8(%rbp)
jmp 0x74ca
xorl %eax, %eax
movq %rax, -0xc8(%rbp)
jmp 0x74ca
movq -0xc8(%rbp), %rdi
callq 0x6100
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x74e9
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x74eb
movq -0x70(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xd0(%rbp)
cmpq $0x0, %rax
je 0x751f
movq -0xd0(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0xe0(%rbp)
jmp 0x752a
xorl %eax, %eax
movq %rax, -0xe0(%rbp)
jmp 0x752a
movq -0xd8(%rbp), %rax
movq -0xe0(%rbp), %rcx
cmpq %rcx, %rax
je 0x75ed
movq -0x70(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x9380
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x75b1
movq -0x70(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movq %rax, -0xe8(%rbp)
je 0x7595
movq -0xf0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x78(%rbp), %rax
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x78(%rbp), %rax
cmpq -0x58(%rbp), %rax
jne 0x75bd
jmp 0x75ed
movq -0x78(%rbp), %rcx
movq -0x58(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x70(%rbp), %rdi
callq 0x6100
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x75e8
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x74eb
movq -0x60(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)