// File: /workspace/github_cpp_makefile_star2_O3/f18m[P]boost-intrusive-pool/include/boost_intrusive_pool.hpp
// Function: memorypool::boost_intrusive_pool<DummyClass>::impl::allocate_safe_get_recycled_item()
Item* allocate_safe_get_recycled_item()
        {
#if BOOST_INTRUSIVE_POOL_DEBUG_THREAD_ACCESS
            if (m_allowed_thread == 0)
                m_allowed_thread = pthread_self();
            else
                assert(m_allowed_thread == pthread_self());
#endif

            if (m_free_count == 0) {
                assert(m_first_free_item == nullptr);
                size_t enlarge_step = get_effective_enlarge_step();
                if (enlarge_step == 0 || !enlarge(enlarge_step)) {
                    m_memory_exhausted = true;
                    return nullptr; // allocation by enlarge() failed or this is a fixed-size memory pool!
                }
            }

            // get first item from free list
            assert(m_first_free_item != nullptr);
            Item* recycled_item = dynamic_cast<Item*>(m_first_free_item); // downcast (base class -> derived class)
            assert(recycled_item != nullptr); // we always allocate all items of the same type,
                                              // so the dynamic cast cannot fail
            assert(
                recycled_item->_refcounted_item_get_pool().get() == this); // this was set during arena initialization
                                                                           // and must be valid at all times

            // update stats
            m_free_count--;
            m_inuse_count++;

            // update the pointer to the next free item available
            m_first_free_item = m_first_free_item->_refcounted_item_get_next();
            if (m_first_free_item == nullptr && m_enlarge_step > 0) {
                size_t enlarge_step = get_effective_enlarge_step();
                if (enlarge_step == 0) { // enlarge_step can be zero if we reach the max_size
                    m_memory_exhausted = true;
                } else {
                    // this is a memory pool which can be still enlarged:
                    // exit the function leaving the m_first_free_item as a valid pointer to a free item!
                    // this is just to simplify debugging and make more effective the check() function implementation!

                    assert(m_free_count == 0);
                    if (!enlarge(enlarge_step)) {
                        m_memory_exhausted = true;
                        // We tried to fetch memory from the O.S. but we failed. However we succeeded in getting the
                        // last available item. So fallback and provide that last item to the caller.
                    }
                }
            }

            // unlink the item to return
            recycled_item->_refcounted_item_set_next(nullptr);
            return recycled_item;
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x80(%rdi), %r14
callq 0x20d0
testq %r14, %r14
je 0x477a
cmpq %rax, %r14
je 0x4781
leaq 0x2560(%rip), %rdi      # 0x6cc2
leaq 0x1f3a(%rip), %rsi      # 0x66a3
leaq 0x2773(%rip), %rcx      # 0x6ee3
movl $0x253, %edx            # imm = 0x253
callq 0x2080
movq %rax, 0x80(%rbx)
cmpq $0x0, 0x60(%rbx)
je 0x485b
movq 0x50(%rbx), %r15
testq %r15, %r15
je 0x48d1
leaq 0x63a8(%rip), %rsi      # 0xab48
leaq 0x63b1(%rip), %rdx      # 0xab58
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x20f0
testq %rax, %rax
je 0x48f0
movq %rax, %r14
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x48b2
movl 0x8(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x8(%rdi)
cmpq %rbx, %rdi
jne 0x48b2
movl %eax, 0x8(%rdi)
testl %eax, %eax
jne 0x47ed
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x50(%rbx), %r15
movq 0x30(%rbx), %rsi
movq 0x60(%rbx), %rax
decq %rax
movq %rax, 0x60(%rbx)
incq 0x68(%rbx)
movq 0x10(%r15), %rcx
movq %rcx, 0x50(%rbx)
testq %rcx, %rcx
setne %cl
testq %rsi, %rsi
sete %dl
orb %cl, %dl
jne 0x4851
movq 0x38(%rbx), %rcx
testq %rcx, %rcx
je 0x4838
movq 0x70(%rbx), %rdx
movq %rsi, %rdi
addq %rdx, %rdi
cmpq %rcx, %rdi
jbe 0x4838
subq %rdx, %rcx
movq %rcx, %rsi
je 0x484d
testq %rax, %rax
jne 0x492e
movq %rbx, %rdi
callq 0x3f7c
testb %al, %al
jne 0x4851
movb $0x1, 0x58(%rbx)
movq $0x0, 0x10(%r14)
jmp 0x48a4
cmpq $0x0, 0x50(%rbx)
jne 0x490f
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x489d
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x488d
movq 0x70(%rbx), %rcx
leaq (%rcx,%rsi), %rdx
cmpq %rax, %rdx
jbe 0x488d
subq %rcx, %rax
movq %rax, %rsi
je 0x489d
movq %rbx, %rdi
callq 0x3f7c
testb %al, %al
jne 0x478c
movb $0x1, 0x58(%rbx)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x26ed(%rip), %rdi      # 0x6fa6
leaq 0x1de3(%rip), %rsi      # 0x66a3
leaq 0x261c(%rip), %rcx      # 0x6ee3
movl $0x265, %edx            # imm = 0x265
callq 0x2080
leaq 0x2698(%rip), %rdi      # 0x6f70
leaq 0x1dc4(%rip), %rsi      # 0x66a3
leaq 0x25fd(%rip), %rcx      # 0x6ee3
movl $0x260, %edx            # imm = 0x260
callq 0x2080
leaq 0x2696(%rip), %rdi      # 0x6f8d
leaq 0x1da5(%rip), %rsi      # 0x66a3
leaq 0x25de(%rip), %rcx      # 0x6ee3
movl $0x262, %edx            # imm = 0x262
callq 0x2080
leaq 0x263d(%rip), %rdi      # 0x6f53
leaq 0x1d86(%rip), %rsi      # 0x66a3
leaq 0x25bf(%rip), %rcx      # 0x6ee3
movl $0x257, %edx            # imm = 0x257
callq 0x2080
leaq 0x26aa(%rip), %rdi      # 0x6fdf
leaq 0x1d67(%rip), %rsi      # 0x66a3
leaq 0x25a0(%rip), %rcx      # 0x6ee3
movl $0x277, %edx            # imm = 0x277
callq 0x2080
nop