// File: HQarroum[P]thread-pool/examples/one-producer-many-consumers/./../../includes/concurrent_queue.hpp
// Function: moodycamel::ConcurrentQueue<std::function<void ()>, moodycamel::ConcurrentQueueDefaultTraits>::ImplicitProducer::new_block_index()
bool new_block_index()
		{
			auto prev = blockIndex.load(std::memory_order_relaxed);
			size_t prevCapacity = prev == nullptr ? 0 : prev->capacity;
			auto entryCount = prev == nullptr ? nextBlockIndexCapacity : prevCapacity;
			auto raw = static_cast<char*>((Traits::malloc)(
				sizeof(BlockIndexHeader) +
				std::alignment_of<BlockIndexEntry>::value - 1 + sizeof(BlockIndexEntry) * entryCount +
				std::alignment_of<BlockIndexEntry*>::value - 1 + sizeof(BlockIndexEntry*) * nextBlockIndexCapacity));
			if (raw == nullptr) {
				return false;
			}
			
			auto header = new (raw) BlockIndexHeader;
			auto entries = reinterpret_cast<BlockIndexEntry*>(details::align_for<BlockIndexEntry>(raw + sizeof(BlockIndexHeader)));
			auto index = reinterpret_cast<BlockIndexEntry**>(details::align_for<BlockIndexEntry*>(reinterpret_cast<char*>(entries) + sizeof(BlockIndexEntry) * entryCount));
			if (prev != nullptr) {
				auto prevTail = prev->tail.load(std::memory_order_relaxed);
				auto prevPos = prevTail;
				size_t i = 0;
				do {
					prevPos = (prevPos + 1) & (prev->capacity - 1);
					index[i++] = prev->index[prevPos];
				} while (prevPos != prevTail);
				assert(i == prevCapacity);
			}
			for (size_t i = 0; i != entryCount; ++i) {
				new (entries + i) BlockIndexEntry;
				entries[i].key.store(INVALID_BLOCK_BASE, std::memory_order_relaxed);
				index[prevCapacity + i] = entries + i;
			}
			header->prev = prev;
			header->entries = entries;
			header->index = index;
			header->capacity = nextBlockIndexCapacity;
			header->tail.store((prevCapacity - 1) & (nextBlockIndexCapacity - 1), std::memory_order_relaxed);
			
			blockIndex.store(header, std::memory_order_release);
			
			nextBlockIndexCapacity <<= 1;
			
			return true;
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
addq $0x60, %rdi
xorl %esi, %esi
callq 0xb160
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x14eeb
xorl %eax, %eax
movq %rax, -0xd0(%rbp)
jmp 0x14ef9
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x14f1f
movq -0xc8(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0xd8(%rbp)
jmp 0x14f2a
movq -0x78(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xc8(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movq -0x80(%rbp), %rdi
shlq $0x4, %rdi
addq $0x2f, %rdi
addq $0x8, %rdi
subq $0x1, %rdi
movq 0x58(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x5b10
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
jne 0x14f7a
movb $0x0, -0x59(%rbp)
jmp 0x15301
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rdi
addq $0x28, %rdi
callq 0x3a20
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
movq -0x80(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x3a50
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x150fa
movq -0x70(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl -0xc(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x58d0
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0xdc(%rbp)
decl %eax
subl $0x2, %eax
jb 0x15025
jmp 0x15008
movl -0xdc(%rbp), %eax
subl $0x5, %eax
je 0x15035
jmp 0x15015
movq -0xe8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x15043
movq -0xe8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x15043
movq -0xe8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq $0x0, -0xb8(%rbp)
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq -0x70(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
andq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movq -0xb0(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0xa0(%rbp), %rax
movq -0xb8(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0xb8(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0xb0(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jne 0x15067
movq -0xb8(%rbp), %rax
cmpq -0x78(%rbp), %rax
jne 0x150d9
jmp 0x150f8
leaq 0x3cb5(%rip), %rdi      # 0x18d95
leaq 0x32bf(%rip), %rsi      # 0x183a6
movl $0xb9d, %edx            # imm = 0xB9D
leaq 0x3cb4(%rip), %rcx      # 0x18da7
callq 0x3180
jmp 0x150fa
movq $0x0, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
cmpq -0x80(%rbp), %rax
je 0x151ee
movq -0x98(%rbp), %rax
movq -0xc0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq $0x1, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl -0x2c(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x58d0
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0xec(%rbp)
movq -0x28(%rbp), %rcx
movq %rcx, -0x38(%rbp)
subl $0x3, %eax
je 0x1518e
jmp 0x15171
movl -0xec(%rbp), %eax
subl $0x5, %eax
je 0x1519e
jmp 0x1517e
movq -0xf8(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x151ac
movq -0xf8(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x151ac
movq -0xf8(%rbp), %rcx
movq -0x38(%rbp), %rax
xchgq %rax, (%rcx)
movq -0x98(%rbp), %rdx
movq -0xc0(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdx
movq -0xa0(%rbp), %rax
movq -0x78(%rbp), %rcx
addq -0xc0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
jmp 0x15105
movq -0xc8(%rbp), %rdx
movq -0x70(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x98(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xa0(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x18(%rax)
movq 0x58(%rdx), %rcx
movq -0x90(%rbp), %rax
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
addq $0x8, %rcx
movq -0x78(%rbp), %rax
decq %rax
movq 0x58(%rdx), %rdx
decq %rdx
andq %rdx, %rax
movq %rcx, -0x40(%rbp)
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x108(%rbp)
movl -0x4c(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x58d0
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0xfc(%rbp)
movq -0x48(%rbp), %rcx
movq %rcx, -0x58(%rbp)
subl $0x3, %eax
je 0x152b1
jmp 0x15294
movl -0xfc(%rbp), %eax
subl $0x5, %eax
je 0x152c1
jmp 0x152a1
movq -0x108(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x152cf
movq -0x108(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x152cf
movq -0x108(%rbp), %rcx
movq -0x58(%rbp), %rax
xchgq %rax, (%rcx)
movq -0xc8(%rbp), %rdi
addq $0x60, %rdi
movq -0x90(%rbp), %rsi
movl $0x3, %edx
callq 0x15640
movq -0xc8(%rbp), %rax
movq 0x58(%rax), %rcx
shlq %rcx
movq %rcx, 0x58(%rax)
movb $0x1, -0x59(%rbp)
movb -0x59(%rbp), %al
andb $0x1, %al
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nop