// File: /workspace/github_cpp_makefile_star2_O3/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 0x2595
movq 0x846d(%rip), %rbx      # 0xafd0
leaq 0x36f2(%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 -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 0x3390
movq -0x70(%rbp), %rax
testq %rax, %rax
je 0x2bdd
leaq -0x80(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x83ec(%rip), %rdi      # 0xafd0
leaq 0x36c8(%rip), %rsi      # 0x62b3
movl $0x30, %edx
callq 0x2100
movq 0x83d4(%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 0x8399(%rip), %rdi      # 0xafd0
leaq 0x3490(%rip), %rsi      # 0x60ce
movl $0x26, %edx
callq 0x2100
movq 0x8381(%rip), %rdi      # 0xafd0
movl $0x420, %esi            # imm = 0x420
callq 0x2090
movq %rax, %rbx
leaq 0x3681(%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 0x3456
movq -0x38(%rbp), %rax
movq %rax, -0x20(%rbp)
testq %rax, %rax
je 0x2cc9
movq 0x8(%rax), %rcx
cmpq $0x3ff, %rcx            # imm = 0x3FF
jae 0x30f8
incq %rcx
movq %rcx, 0x8(%rax)
movq 0x8300(%rip), %rdi      # 0xafd0
leaq 0x3646(%rip), %rsi      # 0x631d
movl $0x41, %edx
callq 0x2100
movq -0x20(%rbp), %rdi
testq %rdi, %rdi
je 0x30c2
movq (%rdi), %rax
callq *0x18(%rax)
leaq -0x11(%rbp), %rsi
movb %al, (%rsi)
movq 0x82cf(%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 0x34f4
movq 0x828b(%rip), %rbx      # 0xafd0
leaq 0x3613(%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 0x8259(%rip), %rdi      # 0xafd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x20(%rbp), %rdi
callq 0x3344
leaq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x3344
leaq -0x30(%rbp), %rdi
callq 0x34f4
movq 0x8227(%rip), %r14      # 0xafd0
leaq 0x3620(%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 0x81f5(%rip), %r14      # 0xafd0
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x30(%rbp), %rdi
callq 0x35c2
callq 0x2595
leaq 0x345c(%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 -0x60(%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 0x3610
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x2e73
leaq -0x60(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x8156(%rip), %rdi      # 0xafd0
leaq 0x35ae(%rip), %rsi      # 0x642f
movl $0x2e, %edx
callq 0x2100
movq 0x813e(%rip), %rdi      # 0xafd0
movl $0x4420, %esi           # imm = 0x4420
callq 0x2090
movq %rax, %r14
leaq 0x35b8(%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)
leaq -0xa0(%rbp), %rdx
movq $0x0, 0x8(%rdx)
movq %rbx, (%rdx)
leaq 0x337(%rip), %rax       # 0x3232
movq %rax, 0x18(%rdx)
leaq 0x342(%rip), %rax       # 0x3248
movq %rax, 0x10(%rdx)
leaq -0x20(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x36d6
movq -0x90(%rbp), %rax
testq %rax, %rax
je 0x2f34
leaq -0xa0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x8095(%rip), %rdi      # 0xafd0
leaq 0x3578(%rip), %rsi      # 0x64ba
movl $0x45, %edx
callq 0x2100
movq -0x20(%rbp), %rdi
testq %rdi, %rdi
je 0x30d9
movq (%rdi), %rax
callq *0x18(%rax)
leaq -0x11(%rbp), %rsi
movb %al, (%rsi)
movq 0x8064(%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 0x37f9
movq 0x8020(%rip), %rbx      # 0xafd0
leaq 0x3549(%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 0x7fee(%rip), %rdi      # 0xafd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x20(%rbp), %rdi
callq 0x38c6
leaq -0x30(%rbp), %rdi
callq 0x37f9
movq 0x7fc8(%rip), %rbx      # 0xafd0
leaq 0x33c1(%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 0x7f96(%rip), %rdi      # 0xafd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
leaq -0x30(%rbp), %rdi
callq 0x3912
movq 0x7f79(%rip), %rbx      # 0xafd0
leaq 0x3525(%rip), %rsi      # 0x6583
movl $0x5f, %edx
movq %rbx, %rdi
callq 0x2100
movl $0x20, %esi
movq %rbx, %rdi
callq 0x2090
movq %rax, %rbx
leaq 0x3561(%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 0x3776(%rip), %rdi      # 0x683f
leaq 0x3777(%rip), %rsi      # 0x6847
leaq 0x3820(%rip), %rcx      # 0x68f7
jmp 0x30ee
leaq 0x375f(%rip), %rdi      # 0x683f
leaq 0x3760(%rip), %rsi      # 0x6847
leaq 0x4479(%rip), %rcx      # 0x7567
movl $0xc7, %edx
callq 0x2080
leaq 0x3553(%rip), %rdi      # 0x6652
leaq 0x359d(%rip), %rsi      # 0x66a3
leaq 0x35b7(%rip), %rcx      # 0x66c4
movl $0xdc, %edx
callq 0x2080
jmp 0x317d
jmp 0x317d
jmp 0x317d
movq %rax, %rbx
movq -0x90(%rbp), %rax
testq %rax, %rax
je 0x3196
leaq -0xa0(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3196
jmp 0x317d
movq %rax, %rbx
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x31c4
leaq -0x60(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x31c4
jmp 0x317d
jmp 0x31b8
movq %rax, %rbx
movq -0x70(%rbp), %rax
testq %rax, %rax
je 0x31c4
leaq -0x80(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x31c4
movq %rax, %rdi
callq 0x39cc
movq %rax, %rbx
leaq -0x20(%rbp), %rdi
callq 0x38c6
jmp 0x3196
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x3912
jmp 0x31c4
movq %rax, %rbx
leaq -0x20(%rbp), %rdi
callq 0x3344
leaq -0x38(%rbp), %rdi
callq 0x3344
jmp 0x31bb
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x35c2
movq %rbx, %rdi
callq 0x21a0