// File: /workspace/github_cpp_makefile_star2_O2/f18m[P]boost-intrusive-pool/tests/unit_tests.cpp
// Function: overwrite_pool_items_with_other_pool_items()
void overwrite_pool_items_with_other_pool_items()
{
    boost_intrusive_pool<DummyInt> pool(64, 16, 0, memorypool::RECYCLE_METHOD_DESTROY_FUNCTION);

    pool.check();

    {
        std::map<int, HDummyInt> helper_container;
        for (unsigned int j = 0; j < 1000; j++) {
            HDummyInt myInt = pool.allocate_through_init(j);
            assert(myInt);

            pool.check();

            // put the item inside a MAP container
            helper_container[j] = myInt;
        }

        pool.check();

        BOOST_REQUIRE(!pool.is_memory_exhausted());
        BOOST_REQUIRE_EQUAL(pool.inuse_count(), 1000);

        // now allocate an other block of items and check refcounting happens correctly so that
        // if we overwrite a filled map entry, the previous pointer is erased correctly
        for (unsigned int j = 0; j < 500; j++) {
            HDummyInt myInt = pool.allocate_through_init(j);
            assert(myInt);

            pool.check();

            // put the item inside a MAP container
            helper_container[j] = myInt;
        }

        pool.check();

        BOOST_REQUIRE(!pool.is_memory_exhausted());
        BOOST_REQUIRE_EQUAL(
            pool.inuse_count(), 1000); // should be still 1000: we allocated 500 more but released other 500 entries!

        helper_container.clear(); // all pointers it contains will be now released
    }

    BOOST_REQUIRE_EQUAL(pool.inuse_count(), 0);

    // repeat twice for test:
    pool.clear();
    pool.clear();

    pool.check();

    BOOST_REQUIRE_EQUAL(pool.inuse_count(), 0);
    BOOST_REQUIRE_EQUAL(pool.capacity(), 0);
    BOOST_REQUIRE(pool.empty());
    BOOST_REQUIRE_EQUAL(pool.unused_count(), 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
xorps %xmm0, %xmm0
leaq -0x140(%rbp), %r9
movaps %xmm0, (%r9)
movaps %xmm0, 0x10(%r9)
leaq -0x38(%rbp), %rdi
pushq $0x40
popq %rsi
pushq $0x10
popq %rdx
pushq $0x1
popq %r8
xorl %ecx, %ecx
callq 0x32326
leaq -0x140(%rbp), %rdi
callq 0x332be
leaq -0x38(%rbp), %rdi
callq 0x323dc
leaq -0xb0(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
xorl %eax, %eax
leaq -0x70(%rbp), %r14
leaq -0x38(%rbp), %r15
leaq -0x50(%rbp), %r12
leaq -0xb8(%rbp), %r13
leaq -0x88(%rbp), %rbx
movl %eax, -0x50(%rbp)
cmpl $0x3e8, %eax            # imm = 0x3E8
jae 0x284e7
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x323fa
cmpq $0x0, -0x70(%rbp)
je 0x28cb0
movq %r15, %rdi
callq 0x323dc
movl -0x50(%rbp), %eax
movl %eax, -0x88(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x324f8
movq %rax, %rdi
movq %r14, %rsi
callq 0x3254a
movq %r14, %rdi
callq 0x32584
movl -0x50(%rbp), %eax
incl %eax
jmp 0x2848e
leaq -0x38(%rbp), %rdi
callq 0x323dc
leaq 0x2a336(%rip), %rax     # 0x5282d
leaq -0x290(%rbp), %rsi
movq %rax, (%rsi)
leaq 0x2a339(%rip), %rax     # 0x52841
movq %rax, 0x8(%rsi)
leaq 0x32705(%rip), %rax     # 0x5ac18
leaq -0x280(%rbp), %rcx
movq %rax, (%rcx)
movq %rax, 0x8(%rcx)
movl $0x1d6, %edx            # imm = 0x1D6
callq 0x1c49e
leaq -0x38(%rbp), %rdi
callq 0x325a0
xorb $0x1, %al
leaq -0x50(%rbp), %rdi
movb %al, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
leaq 0x2a643(%rip), %rax     # 0x52b8d
movq %rax, -0x88(%rbp)
leaq 0x2a650(%rip), %rax     # 0x52ba8
movq %rax, -0x80(%rbp)
leaq -0x70(%rbp), %rsi
movb $0x0, 0x8(%rsi)
leaq 0x564a5(%rip), %rax     # 0x7ea10
addq $0x10, %rax
movq %rax, -0xc0(%rbp)
movq %rax, (%rsi)
leaq 0x57460(%rip), %rax     # 0x7f9e0
movq %rax, 0x10(%rsi)
movq %rbx, 0x18(%rsi)
leaq -0x270(%rbp), %rdx
leaq 0x2a297(%rip), %r14     # 0x5282d
movq %r14, (%rdx)
leaq 0x2a2a1(%rip), %r15     # 0x52841
movq %r15, 0x8(%rdx)
subq $0x10, %rsp
andq $0x0, (%rsp)
pushq $0x2
popq %r8
movl $0x1d6, %ecx            # imm = 0x1D6
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x18e5c
popq %rcx
popq %rdx
leaq -0x40(%rbp), %rdi
callq 0x35d22
leaq -0x260(%rbp), %rsi
movq %r14, (%rsi)
movq %r15, 0x8(%rsi)
leaq -0x250(%rbp), %rcx
leaq 0x32631(%rip), %rax     # 0x5ac18
movq %rax, (%rcx)
movq %rax, 0x8(%rcx)
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x1c49e
movb $0x0, -0x68(%rbp)
leaq 0x5644d(%rip), %rax     # 0x7ea50
addq $0x10, %rax
movq %rax, -0x78(%rbp)
movq %rax, -0x70(%rbp)
leaq 0x573ca(%rip), %rax     # 0x7f9e0
movq %rax, -0x60(%rbp)
leaq 0x29878(%rip), %rax     # 0x51e99
movq %rax, -0x58(%rbp)
movq %r14, -0x120(%rbp)
movq %r15, -0x118(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x326ce
leaq -0x50(%rbp), %r9
movq %rax, (%r9)
movl $0x3e8, -0x88(%rbp)     # imm = 0x3E8
subq $0x8, %rsp
leaq 0x2a564(%rip), %r10     # 0x52bbc
leaq 0x2a54a(%rip), %rax     # 0x52ba9
leaq -0x70(%rbp), %rdi
leaq -0x120(%rbp), %rsi
pushq $0x2
popq %rcx
movl $0x1d7, %edx            # imm = 0x1D7
movl %ecx, %r8d
pushq %r10
pushq %rbx
pushq %rax
callq 0x3286b
addq $0x20, %rsp
xorl %eax, %eax
leaq -0x70(%rbp), %rbx
leaq -0x38(%rbp), %r15
leaq -0x50(%rbp), %r12
leaq -0xb8(%rbp), %r13
leaq -0x88(%rbp), %r14
movl %eax, -0x50(%rbp)
cmpl $0x1f4, %eax            # imm = 0x1F4
jae 0x286f7
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x323fa
cmpq $0x0, -0x70(%rbp)
je 0x28ccf
movq %r15, %rdi
callq 0x323dc
movl -0x50(%rbp), %eax
movl %eax, -0x88(%rbp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x324f8
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3254a
movq %rbx, %rdi
callq 0x32584
movl -0x50(%rbp), %eax
incl %eax
jmp 0x2869e
leaq -0x38(%rbp), %rdi
callq 0x323dc
leaq 0x2a126(%rip), %rax     # 0x5282d
leaq 0x2a133(%rip), %rcx     # 0x52841
leaq -0x240(%rbp), %rsi
movq %rax, (%rsi)
movq %rcx, 0x8(%rsi)
leaq -0x230(%rbp), %rcx
leaq 0x324ee(%rip), %rax     # 0x5ac18
movq %rax, (%rcx)
movq %rax, 0x8(%rcx)
movl $0x1e7, %edx            # imm = 0x1E7
callq 0x1c49e
leaq -0x38(%rbp), %rdi
callq 0x325a0
xorb $0x1, %al
leaq -0x50(%rbp), %rdi
movb %al, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
leaq 0x2a433(%rip), %rax     # 0x52b8d
movq %rax, -0x88(%rbp)
leaq 0x2a440(%rip), %rax     # 0x52ba8
movq %rax, -0x80(%rbp)
leaq -0x70(%rbp), %rsi
movb $0x0, 0x8(%rsi)
movq -0xc0(%rbp), %rax
movq %rax, (%rsi)
leaq 0x5725b(%rip), %rax     # 0x7f9e0
movq %rax, 0x10(%rsi)
movq %r14, 0x18(%rsi)
leaq -0x220(%rbp), %rdx
leaq 0x2a092(%rip), %rbx     # 0x5282d
movq %rbx, (%rdx)
leaq 0x2a09c(%rip), %r15     # 0x52841
movq %r15, 0x8(%rdx)
subq $0x10, %rsp
andq $0x0, (%rsp)
pushq $0x2
popq %r8
movl $0x1e7, %ecx            # imm = 0x1E7
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x18e5c
popq %rcx
popq %rdx
leaq -0x40(%rbp), %rdi
callq 0x35d22
leaq -0x210(%rbp), %rsi
movq %rbx, (%rsi)
movq %r15, 0x8(%rsi)
leaq -0x200(%rbp), %rcx
leaq 0x3242c(%rip), %rax     # 0x5ac18
movq %rax, (%rcx)
movq %rax, 0x8(%rcx)
movl $0x1e9, %edx            # imm = 0x1E9
callq 0x1c49e
movb $0x0, -0x68(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0x571d0(%rip), %rax     # 0x7f9e0
movq %rax, -0x60(%rbp)
leaq 0x2967e(%rip), %rax     # 0x51e99
movq %rax, -0x58(%rbp)
movq %rbx, -0x110(%rbp)
movq %r15, -0x108(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x326ce
leaq -0x50(%rbp), %rbx
movq %rax, (%rbx)
movl $0x3e8, -0x88(%rbp)     # imm = 0x3E8
subq $0x8, %rsp
leaq -0x70(%rbp), %rdi
leaq -0x110(%rbp), %rsi
pushq $0x2
popq %rcx
movl $0x1e9, %edx            # imm = 0x1E9
movl %ecx, %r8d
movq %rbx, %r9
leaq 0x2a351(%rip), %rax     # 0x52bbc
pushq %rax
pushq %r14
leaq 0x2a334(%rip), %r15     # 0x52ba9
pushq %r15
callq 0x3286b
addq $0x20, %rsp
leaq -0xb8(%rbp), %r14
movq %r14, %rdi
callq 0x4df82
movq %r14, %rdi
callq 0x440e6
leaq -0x1f0(%rbp), %rsi
leaq 0x29f88(%rip), %rax     # 0x5282d
movq %rax, (%rsi)
leaq 0x29f92(%rip), %rax     # 0x52841
movq %rax, 0x8(%rsi)
leaq -0x1e0(%rbp), %rcx
leaq 0x32357(%rip), %rax     # 0x5ac18
movq %rax, (%rcx)
movq %rax, 0x8(%rcx)
movl $0x1ee, %edx            # imm = 0x1EE
callq 0x1c49e
movb $0x0, -0xb0(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq 0x570f5(%rip), %rax     # 0x7f9e0
movq %rax, -0xa8(%rbp)
leaq 0x295a0(%rip), %rax     # 0x51e99
movq %rax, -0xa0(%rbp)
leaq 0x29f26(%rip), %rax     # 0x5282d
movq %rax, -0x100(%rbp)
leaq 0x29f2c(%rip), %rax     # 0x52841
movq %rax, -0xf8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x326ce
leaq -0x70(%rbp), %r9
movq %rax, (%r9)
andl $0x0, -0x50(%rbp)
subq $0x8, %rsp
leaq 0x2edc4(%rip), %r14     # 0x576ff
leaq -0xb8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
pushq $0x2
popq %rcx
movl $0x1ee, %edx            # imm = 0x1EE
movl %ecx, %r8d
pushq %r14
pushq %rbx
pushq %r15
callq 0x3286b
addq $0x20, %rsp
leaq -0x38(%rbp), %rdi
callq 0x3274e
leaq -0x38(%rbp), %rdi
callq 0x3274e
leaq -0x38(%rbp), %rdi
callq 0x323dc
leaq -0x1d0(%rbp), %rsi
leaq 0x29ea2(%rip), %rax     # 0x5282d
movq %rax, (%rsi)
leaq 0x29eac(%rip), %rax     # 0x52841
movq %rax, 0x8(%rsi)
leaq -0x1c0(%rbp), %rcx
leaq 0x32271(%rip), %rax     # 0x5ac18
movq %rax, (%rcx)
movq %rax, 0x8(%rcx)
movl $0x1f6, %edx            # imm = 0x1F6
callq 0x1c49e
movb $0x0, -0xb0(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq 0x5700f(%rip), %rax     # 0x7f9e0
movq %rax, -0xa8(%rbp)
leaq 0x294ba(%rip), %rax     # 0x51e99
movq %rax, -0xa0(%rbp)
leaq 0x29e40(%rip), %rax     # 0x5282d
movq %rax, -0xf0(%rbp)
leaq 0x29e46(%rip), %rax     # 0x52841
movq %rax, -0xe8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x326ce
leaq -0x70(%rbp), %r9
movq %rax, (%r9)
andl $0x0, -0x50(%rbp)
subq $0x8, %rsp
leaq -0xb8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
pushq $0x2
popq %rcx
movl $0x1f6, %edx            # imm = 0x1F6
movl %ecx, %r8d
pushq %r14
pushq %rbx
pushq %r15
callq 0x3286b
addq $0x20, %rsp
leaq -0x1b0(%rbp), %rsi
leaq 0x29dde(%rip), %rax     # 0x5282d
movq %rax, (%rsi)
leaq 0x29de8(%rip), %rax     # 0x52841
movq %rax, 0x8(%rsi)
leaq -0x1a0(%rbp), %rcx
leaq 0x321ad(%rip), %rax     # 0x5ac18
movq %rax, (%rcx)
movq %rax, 0x8(%rcx)
movl $0x1f7, %edx            # imm = 0x1F7
callq 0x1c49e
movb $0x0, -0xb0(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq 0x56f4b(%rip), %rax     # 0x7f9e0
movq %rax, -0xa8(%rbp)
leaq 0x293f6(%rip), %rax     # 0x51e99
movq %rax, -0xa0(%rbp)
leaq 0x29d7c(%rip), %rax     # 0x5282d
movq %rax, -0xe0(%rbp)
leaq 0x29d82(%rip), %rax     # 0x52841
movq %rax, -0xd8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x326ec
leaq -0x70(%rbp), %r9
movq %rax, (%r9)
andl $0x0, -0x50(%rbp)
subq $0x8, %rsp
leaq 0x2a0dc(%rip), %rax     # 0x52bc1
leaq -0xb8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
pushq $0x2
popq %rcx
movl $0x1f7, %edx            # imm = 0x1F7
movl %ecx, %r8d
pushq %r14
pushq %rbx
pushq %rax
callq 0x3286b
addq $0x20, %rsp
leaq -0x190(%rbp), %rsi
leaq 0x29d14(%rip), %rax     # 0x5282d
movq %rax, (%rsi)
leaq 0x29d1e(%rip), %rax     # 0x52841
movq %rax, 0x8(%rsi)
leaq -0x180(%rbp), %rcx
leaq 0x320e3(%rip), %rax     # 0x5ac18
movq %rax, (%rcx)
movq %rax, 0x8(%rcx)
movl $0x1f8, %edx            # imm = 0x1F8
callq 0x1c49e
leaq -0x38(%rbp), %rdi
callq 0x3270a
leaq -0x70(%rbp), %rdi
movb %al, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
leaq 0x2a06e(%rip), %rax     # 0x52bd1
movq %rax, -0x50(%rbp)
leaq 0x2a06f(%rip), %rax     # 0x52bdd
movq %rax, -0x48(%rbp)
leaq -0xb8(%rbp), %rsi
movb $0x0, 0x8(%rsi)
movq -0xc0(%rbp), %rax
movq %rax, (%rsi)
leaq 0x56e52(%rip), %rax     # 0x7f9e0
movq %rax, 0x10(%rsi)
movq %rbx, 0x18(%rsi)
leaq -0x170(%rbp), %rdx
leaq 0x29c89(%rip), %r15     # 0x5282d
movq %r15, (%rdx)
leaq 0x29c93(%rip), %r12     # 0x52841
movq %r12, 0x8(%rdx)
subq $0x10, %rsp
andq $0x0, (%rsp)
pushq $0x2
popq %r8
movl $0x1f8, %ecx            # imm = 0x1F8
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x18e5c
popq %rcx
popq %rdx
leaq -0x60(%rbp), %rdi
callq 0x35d22
leaq -0x160(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, 0x8(%rsi)
leaq -0x150(%rbp), %rcx
leaq 0x32023(%rip), %rax     # 0x5ac18
movq %rax, (%rcx)
movq %rax, 0x8(%rcx)
movl $0x1f9, %edx            # imm = 0x1F9
callq 0x1c49e
movb $0x0, -0xb0(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq 0x56dc1(%rip), %rax     # 0x7f9e0
movq %rax, -0xa8(%rbp)
leaq 0x2926c(%rip), %rax     # 0x51e99
movq %rax, -0xa0(%rbp)
leaq 0x29bf2(%rip), %rax     # 0x5282d
movq %rax, -0xd0(%rbp)
leaq 0x29bf8(%rip), %rax     # 0x52841
movq %rax, -0xc8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x326b0
leaq -0x70(%rbp), %r9
movq %rax, (%r9)
andl $0x0, -0x50(%rbp)
subq $0x8, %rsp
leaq 0x29e8f(%rip), %rax     # 0x52afe
leaq -0xb8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
pushq $0x2
popq %rcx
movl $0x1f9, %edx            # imm = 0x1F9
movl %ecx, %r8d
pushq %r14
pushq %rbx
pushq %rax
callq 0x3286b
addq $0x20, %rsp
leaq -0x38(%rbp), %rdi
callq 0x32962
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x29d59(%rip), %rdi     # 0x52a10
leaq 0x29b6f(%rip), %rsi     # 0x5282d
leaq 0x29e96(%rip), %rcx     # 0x52b5b
movl $0x1cc, %edx            # imm = 0x1CC
callq 0xf340
leaq 0x29d3a(%rip), %rdi     # 0x52a10
leaq 0x29b50(%rip), %rsi     # 0x5282d
leaq 0x29e77(%rip), %rcx     # 0x52b5b
movl $0x1dd, %edx            # imm = 0x1DD
callq 0xf340
jmp 0x28d3d
jmp 0x28d3d
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x35d22
jmp 0x28d67
jmp 0x28d3d
jmp 0x28d3d
jmp 0x28d3d
jmp 0x28d3d
jmp 0x28d3d
jmp 0x28d3d
jmp 0x28d3d
jmp 0x28d48
jmp 0x28d48
jmp 0x28d1a
jmp 0x28d48
jmp 0x28d48
jmp 0x28d48
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x35d22
jmp 0x28d5b
jmp 0x28d48
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
callq 0x332be
jmp 0x28d70
jmp 0x28d48
movq %rax, %rbx
jmp 0x28d67
jmp 0x28d4f
jmp 0x28d48
jmp 0x28d4f
movq %rax, %rbx
jmp 0x28d5b
jmp 0x28d4f
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x32584
leaq -0xb8(%rbp), %rdi
callq 0x440e6
leaq -0x38(%rbp), %rdi
callq 0x32962
movq %rbx, %rdi
callq 0xf8a0