// File: /workspace/github_cpp_makefile_star2_O1/f18m[P]boost-intrusive-pool/tests/tutorial.cpp
// Function: showcase_boost_intrusive_pool()
void showcase_boost_intrusive_pool()
{
    print_header();

    {
        std::cout << "  Now allocating a new memorypool::boost_intrusive_pool<>. A large malloc will happen."
                  << std::endl;

        memorypool::boost_intrusive_pool<DummyClass> pool(4, 1);
        // you will see a memory malloc traced when running this line

        std::cout << "  Boost Intrusive Pool for DummyClass has size: " << sizeof(pool) << std::endl;

        {
            std::cout << "  Now allocating dummy class of size: " << sizeof(DummyClass)
                      << " from the memory pool. This time no mallocs will happen!" << std::endl;
            boost::intrusive_ptr<DummyClass> hdummy = pool.allocate();

            // of course copying pointers around does not trigger any memory allocation:
            boost::intrusive_ptr<DummyClass> hdummy2 = hdummy;
            std::cout << "  Value from allocated dummy class constructed via default ctor: " << hdummy2->dummy()
                      << std::endl;

            observe_pool(pool);

            std::cout << "  Going to release the references to the boost::intrusive_ptr<> created so far. This time no "
                         "free() will happen!"
                      << std::endl;

        } // this time no memory free() will happen!

        observe_pool(pool);

        std::cout << "  Going to release the whole memory pool. You will see a bunch of dtor and memory free happen!"
                  << std::endl;
    } // you will see a memory free traced when running this line

    print_header();

    // now showcase a memory pool of objects having the following class hierarchy:
    //   boost_intrusive_pool_item
    //   \--- DummyClass
    //        \--- DummyDerivedClass

    {
        std::cout << "  Now allocating a new memorypool::boost_intrusive_pool<>. A large malloc will happen."
                  << std::endl;
        memorypool::boost_intrusive_pool<DummyDerivedClass> pool(4, 1);

        {
            std::cout << "  Now allocating derived dummy class of size: " << sizeof(DummyDerivedClass)
                      << " from the memory pool. This time no mallocs will happen but the ctor will get called again!"
                      << std::endl;

            size_t initializer_value = 3;

            auto custom_init_fn
                = [&initializer_value](DummyDerivedClass& object) { object.yet_another_init_fun(initializer_value); };

            // just for fun this time we allocate the object using non-default constructor:
            boost::intrusive_ptr<DummyDerivedClass> hdummy = pool.allocate_through_function(custom_init_fn);

            std::cout << "  Value from allocated dummy class constructed via NON default ctor: " << hdummy->dummy()
                      << std::endl;

            observe_pool(pool);

            std::cout << "  Going to release the references to the boost::intrusive_ptr<> created so far. This time no "
                         "free() will happen, just a dtor call!"
                      << std::endl;

        } // this time no memory free() will happen!

        observe_pool(pool);

        std::cout << "  Going to release the whole memory pool. You will see a bunch of dtor and memory free happen!"
                  << std::endl;
    } // you will see a memory free traced when running this line

    std::cout << "Note that the overhead of memory pool support is sizeof(memorypool::boost_intrusive_pool_item)="
              << sizeof(memorypool::boost_intrusive_pool_item) << "bytes" << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
callq 0x25a5
movq 0x841e(%rip), %rbx      # 0xafd0
leaq 0x36a3(%rip), %rsi      # 0x625c
movl $0x56, %edx
movq %rbx, %rdi
callq 0x2100
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
xorps %xmm0, %xmm0
leaq -0xa0(%rbp), %r9
movaps %xmm0, (%r9)
movaps %xmm0, 0x10(%r9)
leaq -0x30(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x33e0
movq -0x90(%rbp), %rax
testq %rax, %rax
je 0x2c35
leaq -0xa0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x8394(%rip), %rdi      # 0xafd0
leaq 0x3670(%rip), %rsi      # 0x62b3
movl $0x30, %edx
callq 0x2100
movq 0x837c(%rip), %rdi      # 0xafd0
movl $0x10, %esi
callq 0x2090
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movq 0x8341(%rip), %rdi      # 0xafd0
leaq 0x3438(%rip), %rsi      # 0x60ce
movl $0x26, %edx
callq 0x2100
movq 0x8329(%rip), %rdi      # 0xafd0
movl $0x420, %esi            # imm = 0x420
callq 0x2090
movq %rax, %rbx
leaq 0x3629(%rip), %rsi      # 0x62e4
movl $0x38, %edx
movq %rax, %rdi
callq 0x2100
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x34a6
movq -0x38(%rbp), %rax
movq %rax, -0x20(%rbp)
testq %rax, %rax
je 0x2d21
movq 0x8(%rax), %rcx
cmpq $0x3ff, %rcx            # imm = 0x3FF
jae 0x3149
incq %rcx
movq %rcx, 0x8(%rax)
movq 0x82a8(%rip), %rdi      # 0xafd0
leaq 0x35ee(%rip), %rsi      # 0x631d
movl $0x41, %edx
callq 0x2100
movq -0x20(%rbp), %rdi
testq %rdi, %rdi
je 0x3113
movq (%rdi), %rax
callq *0x18(%rax)
leaq -0x11(%rbp), %rsi
movb %al, (%rsi)
movq 0x8277(%rip), %rdi      # 0xafd0
movl $0x1, %edx
callq 0x2100
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x30(%rbp), %rdi
callq 0x3544
movq 0x8233(%rip), %rbx      # 0xafd0
leaq 0x35bb(%rip), %rsi      # 0x635f
movl $0x70, %edx
movq %rbx, %rdi
callq 0x2100
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq 0x8201(%rip), %rdi      # 0xafd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x20(%rbp), %rdi
callq 0x3394
leaq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x3394
leaq -0x30(%rbp), %rdi
callq 0x3544
movq 0x81cf(%rip), %r14      # 0xafd0
leaq 0x35c8(%rip), %rsi      # 0x63d0
movl $0x5e, %edx
movq %r14, %rdi
callq 0x2100
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq 0x819d(%rip), %r14      # 0xafd0
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x30(%rbp), %rdi
callq 0x3612
callq 0x25a5
leaq 0x3404(%rip), %rsi      # 0x625c
movl $0x56, %edx
movq %r14, %rdi
callq 0x2100
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
xorps %xmm0, %xmm0
leaq -0x80(%rbp), %r9
movaps %xmm0, (%r9)
movaps %xmm0, 0x10(%r9)
leaq -0x30(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3660
movq -0x70(%rbp), %rax
testq %rax, %rax
je 0x2ecb
leaq -0x80(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x80fe(%rip), %rdi      # 0xafd0
leaq 0x3556(%rip), %rsi      # 0x642f
movl $0x2e, %edx
callq 0x2100
movq 0x80e6(%rip), %rdi      # 0xafd0
movl $0x4420, %esi           # imm = 0x4420
callq 0x2090
movq %rax, %r14
leaq 0x3560(%rip), %rsi      # 0x645e
movl $0x5b, %edx
movq %rax, %rdi
callq 0x2100
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movq $0x3, -0x38(%rbp)
xorps %xmm0, %xmm0
leaq -0x60(%rbp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movq %rbx, (%rdx)
leaq 0x330(%rip), %rax       # 0x3282
movq %rax, 0x18(%rdx)
leaq 0x33b(%rip), %rax       # 0x3298
movq %rax, 0x10(%rdx)
leaq -0x20(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3726
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x2f85
leaq -0x60(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x8044(%rip), %rdi      # 0xafd0
leaq 0x3527(%rip), %rsi      # 0x64ba
movl $0x45, %edx
callq 0x2100
movq -0x20(%rbp), %rdi
testq %rdi, %rdi
je 0x312a
movq (%rdi), %rax
callq *0x18(%rax)
leaq -0x11(%rbp), %rsi
movb %al, (%rsi)
movq 0x8013(%rip), %rdi      # 0xafd0
movl $0x1, %edx
callq 0x2100
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x30(%rbp), %rdi
callq 0x3849
movq 0x7fcf(%rip), %rbx      # 0xafd0
leaq 0x34f8(%rip), %rsi      # 0x6500
movl $0x82, %edx
movq %rbx, %rdi
callq 0x2100
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq 0x7f9d(%rip), %rdi      # 0xafd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x20(%rbp), %rdi
callq 0x3916
leaq -0x30(%rbp), %rdi
callq 0x3849
movq 0x7f77(%rip), %rbx      # 0xafd0
leaq 0x3370(%rip), %rsi      # 0x63d0
movl $0x5e, %edx
movq %rbx, %rdi
callq 0x2100
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq 0x7f45(%rip), %rdi      # 0xafd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x30(%rbp), %rdi
callq 0x3962
movq 0x7f28(%rip), %rbx      # 0xafd0
leaq 0x34d4(%rip), %rsi      # 0x6583
movl $0x5f, %edx
movq %rbx, %rdi
callq 0x2100
movl $0x20, %esi
movq %rbx, %rdi
callq 0x2090
movq %rax, %rbx
leaq 0x3510(%rip), %rsi      # 0x65e3
movl $0x5, %edx
movq %rax, %rdi
callq 0x2100
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x3725(%rip), %rdi      # 0x683f
leaq 0x3726(%rip), %rsi      # 0x6847
leaq 0x37cf(%rip), %rcx      # 0x68f7
jmp 0x313f
leaq 0x370e(%rip), %rdi      # 0x683f
leaq 0x370f(%rip), %rsi      # 0x6847
leaq 0x4428(%rip), %rcx      # 0x7567
movl $0xc7, %edx
callq 0x2080
leaq 0x3502(%rip), %rdi      # 0x6652
leaq 0x354c(%rip), %rsi      # 0x66a3
leaq 0x3566(%rip), %rcx      # 0x66c4
movl $0xdc, %edx
callq 0x2080
jmp 0x31ce
jmp 0x31ce
jmp 0x31ce
movq %rax, %rbx
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x31e7
leaq -0x60(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x31e7
jmp 0x31ce
movq %rax, %rbx
movq -0x70(%rbp), %rax
testq %rax, %rax
je 0x3215
leaq -0x80(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3215
jmp 0x31ce
jmp 0x3209
movq %rax, %rbx
movq -0x90(%rbp), %rax
testq %rax, %rax
je 0x3215
leaq -0xa0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3215
movq %rax, %rdi
callq 0x3a1c
movq %rax, %rbx
leaq -0x20(%rbp), %rdi
callq 0x3916
jmp 0x31e7
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x3962
jmp 0x3215
movq %rax, %rbx
leaq -0x20(%rbp), %rdi
callq 0x3394
leaq -0x38(%rbp), %rdi
callq 0x3394
jmp 0x320c
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x3612
movq %rbx, %rdi
callq 0x21a0