// File: /workspace/github_cpp_makefile_star2_O1/f18m[P]boost-intrusive-pool/tests/tutorial.cpp
// Function: showcase_std_shared_pointers()
void showcase_std_shared_pointers()
{
    print_header();
    std::cout << "Running some examples for std::shared_ptr<>:" << std::endl;

    // the test below shows that the overhead of a std::shared_ptr is about 8B/pointer
    // (tested with GCC 7.3.0) and the control block adds an overhead of about 16B

    {
        std::shared_ptr<DummyClass> hdummy;
        std::cout << "  Size of a simple std::shared_ptr<>: " << sizeof(hdummy) << std::endl;

        {
            // now allocate an instance of the class:
            std::cout << "  Now allocating dummy class of size: " << sizeof(DummyClass) << std::endl;
            hdummy = std::make_shared<DummyClass>(); // you will see a memory malloc traced when running this line

            // of course copying pointers around does not trigger any memory allocation:
            std::shared_ptr<DummyClass> hdummy2 = hdummy;

        } // the DummyClass instance survives this block since its reference is stored in hdummy

        std::cout << "  Going to release all references to the std::shared_ptr<> created so far" << std::endl;
    } // you will see a memory free traced when running this line
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
callq 0x25a5
movq 0x89c6(%rip), %r14      # 0xafd0
leaq 0x3a69(%rip), %rsi      # 0x607a
movl $0x2c, %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
xorl %ebx, %ebx
leaq 0x3a59(%rip), %rsi      # 0x60a7
movl $0x26, %edx
movq %r14, %rdi
callq 0x2100
xorl %ebx, %ebx
movq 0x896c(%rip), %rdi      # 0xafd0
movl $0x10, %esi
callq 0x2090
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %ebx, %ebx
movl $0xa, %esi
callq 0x20e0
xorl %ebx, %ebx
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x20a0
xorl %ebx, %ebx
movq 0x8929(%rip), %rdi      # 0xafd0
leaq 0x3a20(%rip), %rsi      # 0x60ce
movl $0x26, %edx
callq 0x2100
xorl %ebx, %ebx
movq 0x890f(%rip), %rdi      # 0xafd0
movl $0x420, %esi            # imm = 0x420
callq 0x2090
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %ebx, %ebx
movl $0xa, %esi
callq 0x20e0
xorl %ebx, %ebx
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x20a0
leaq -0x28(%rbp), %rdi
movq $0x0, -0x8(%rdi)
leaq -0x30(%rbp), %rsi
leaq -0x11(%rbp), %rdx
callq 0x3b74
movq -0x28(%rbp), %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movq -0x28(%rbp), %rdi
testq %rdi, %rdi
je 0x272d
callq 0x39b0
testq %rbx, %rbx
je 0x2754
movq 0x888f(%rip), %rax      # 0xafc8
cmpb $0x0, (%rax)
je 0x2743
incl 0x8(%rbx)
jmp 0x2747
lock
incl 0x8(%rbx)
testq %rbx, %rbx
je 0x2754
movq %rbx, %rdi
callq 0x39b0
movq 0x8875(%rip), %r14      # 0xafd0
leaq 0x3993(%rip), %rsi      # 0x60f5
movl $0x49, %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 0x8843(%rip), %rdi      # 0xafd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
testq %rbx, %rbx
je 0x27a7
movq %rbx, %rdi
callq 0x39b0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %r14
xorl %ebx, %ebx
jmp 0x27ba
movq %rax, %r14
testq %rbx, %rbx
je 0x27c7
movq %rbx, %rdi
callq 0x39b0
movq %r14, %rdi
callq 0x21a0