// File: HQarroum[P]thread-pool/examples/one-producer-many-consumers/./../../includes/concurrent_queue.hpp
// Function: moodycamel::ConcurrentQueue<std::function<void ()>, moodycamel::ConcurrentQueueDefaultTraits>::update_current_producer_after_rotation(moodycamel::ConsumerToken&)
inline bool update_current_producer_after_rotation(consumer_token_t& token)
	{
		// Ah, there's been a rotation, figure out where we should be!
		auto tail = producerListTail.load(std::memory_order_acquire);
		if (token.desiredProducer == nullptr && tail == nullptr) {
			return false;
		}
		auto prodCount = producerCount.load(std::memory_order_relaxed);
		auto globalOffset = globalExplicitConsumerOffset.load(std::memory_order_relaxed);
		if ((details::unlikely)(token.desiredProducer == nullptr)) {
			// Aha, first time we're dequeueing anything.
			// Figure out our local position
			// Note: offset is from start, not end, but we're traversing from end -- subtract from count first
			std::uint32_t offset = prodCount - 1 - (token.initialOffset % prodCount);
			token.desiredProducer = tail;
			for (std::uint32_t i = 0; i != offset; ++i) {
				token.desiredProducer = static_cast<ProducerBase*>(token.desiredProducer)->next_prod();
				if (token.desiredProducer == nullptr) {
					token.desiredProducer = tail;
				}
			}
		}
		
		std::uint32_t delta = globalOffset - token.lastKnownGlobalOffset;
		if (delta >= prodCount) {
			delta = delta % prodCount;
		}
		for (std::uint32_t i = 0; i != delta; ++i) {
			token.desiredProducer = static_cast<ProducerBase*>(token.desiredProducer)->next_prod();
			if (token.desiredProducer == nullptr) {
				token.desiredProducer = tail;
			}
		}
		
		token.lastKnownGlobalOffset = globalOffset;
		token.currentProducer = token.desiredProducer;
		token.itemsConsumedFromCurrent = 0;
		return true;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq %rdi, -0x68(%rbp)
movl $0x2, %esi
callq 0x6080
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x9004
cmpq $0x0, -0x48(%rbp)
jne 0x9004
movb $0x0, -0x2d(%rbp)
jmp 0x9372
movq -0x68(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0xc(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x58d0
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x6c(%rbp)
decl %eax
subl $0x2, %eax
jb 0x9053
jmp 0x903e
movl -0x6c(%rbp), %eax
subl $0x5, %eax
je 0x905e
jmp 0x9048
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x9067
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x9067
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x68(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, -0x4c(%rbp)
addq $0x260, %rax            # imm = 0x260
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x24(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x58d0
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x7c(%rbp)
decl %eax
subl $0x2, %eax
jb 0x90c4
jmp 0x90ac
movl -0x7c(%rbp), %eax
subl $0x5, %eax
je 0x90d2
jmp 0x90b6
movq -0x88(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x90de
movq -0x88(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x90de
movq -0x88(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
sete %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x37e0
testb $0x1, %al
jne 0x9104
jmp 0x9246
movl -0x4c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x9c(%rbp)
movq -0x40(%rbp), %rax
movl (%rax), %eax
xorl %edx, %edx
divl -0x4c(%rbp)
movl -0x9c(%rbp), %eax
subl %edx, %eax
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rcx
movq %rcx, -0x98(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movq %rax, -0x90(%rbp)
je 0x9152
movq -0x98(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
je 0x9244
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0x919d
movq -0xa8(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0xb0(%rbp)
jmp 0x91a8
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0x91a8
movq -0xb0(%rbp), %rdi
callq 0x6100
movq %rax, %rcx
movq %rcx, -0xc0(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movq %rax, -0xb8(%rbp)
je 0x91df
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x9234
movq -0x48(%rbp), %rcx
movq %rcx, -0xd0(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movq %rax, -0xc8(%rbp)
je 0x9225
movq -0xd0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x9236
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x9168
jmp 0x9246
movl -0x50(%rbp), %eax
movq -0x40(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jb 0x9266
movl -0x5c(%rbp), %eax
xorl %edx, %edx
divl -0x4c(%rbp)
movl %edx, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x5c(%rbp), %eax
je 0x9349
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xd8(%rbp)
cmpq $0x0, %rax
je 0x92a2
movq -0xd8(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0xe0(%rbp)
jmp 0x92ad
xorl %eax, %eax
movq %rax, -0xe0(%rbp)
jmp 0x92ad
movq -0xe0(%rbp), %rdi
callq 0x6100
movq %rax, %rcx
movq %rcx, -0xf0(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movq %rax, -0xe8(%rbp)
je 0x92e4
movq -0xf0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x9339
movq -0x48(%rbp), %rcx
movq %rcx, -0x100(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movq %rax, -0xf8(%rbp)
je 0x932a
movq -0x100(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x933b
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x926d
movl -0x50(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movl $0x0, 0x8(%rax)
movb $0x1, -0x2d(%rbp)
movb -0x2d(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq