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

    {
        std::cout << "  Now allocating dummy class of size: " << sizeof(DummyClass) << std::endl;

        boost::intrusive_ptr<DummyClass> hdummy(new DummyClass(3));
        // you will see a memory malloc traced when running this line

        std::cout << "  Size of a simple boost::intrusive_ptr<>: " << sizeof(hdummy) << std::endl;

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

            // of course you can move Boost intrusive pointers as well:
            std::cout << "  Before std::move hdummy2 is valid: " << (bool)hdummy2 << std::endl;
            boost::intrusive_ptr<DummyClass> hdummy3(std::move(hdummy2));
            std::cout << "  Value from allocated dummy class: " << hdummy3->dummy() << std::endl;
            std::cout << "  After std::move hdummy2 is valid: " << (bool)hdummy2 << std::endl;

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
callq 0x2490
movq 0xc9a1(%rip), %rdi      # 0xefd8
movq %rdi, -0x48(%rbp)
leaq 0x6b34(%rip), %rsi      # 0x9176
callq 0x20f0
movq %rax, %rdi
movq 0xc96f(%rip), %rsi      # 0xefc0
movq %rsi, -0x40(%rbp)
callq 0x2100
movq -0x48(%rbp), %rdi
leaq 0x6aa0(%rip), %rsi      # 0x9105
callq 0x20f0
movq %rax, %rdi
movl $0x420, %esi            # imm = 0x420
movq %rsi, -0x38(%rbp)
callq 0x2040
movq -0x40(%rbp), %rsi
movq %rax, %rdi
callq 0x2100
movq -0x38(%rbp), %rdi
callq 0x22f0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x30(%rbp)
movl $0x3, %esi
callq 0x3420
jmp 0x26a6
movq -0x30(%rbp), %rsi
leaq -0x8(%rbp), %rdi
movl $0x1, %edx
callq 0x3500
movq 0xc919(%rip), %rdi      # 0xefd8
leaq 0x6ae2(%rip), %rsi      # 0x91a8
callq 0x20f0
movq %rax, -0x50(%rbp)
jmp 0x26d1
movq -0x50(%rbp), %rdi
movl $0x8, %esi
callq 0x2040
movq %rax, -0x58(%rbp)
jmp 0x26e5
movq -0x58(%rbp), %rdi
movq 0xc8d0(%rip), %rsi      # 0xefc0
callq 0x2100
jmp 0x26f7
leaq -0x20(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0x3550
jmp 0x2706
movq 0xc8cb(%rip), %rdi      # 0xefd8
leaq 0x6ac0(%rip), %rsi      # 0x91d4
callq 0x20f0
movq %rax, -0x60(%rbp)
jmp 0x271f
leaq -0x20(%rbp), %rdi
callq 0x3590
movq %rax, %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movb %al, -0x61(%rbp)
jmp 0x2739
movq -0x60(%rbp), %rdi
movb -0x61(%rbp), %al
movsbl %al, %esi
callq 0x2120
movq %rax, -0x70(%rbp)
jmp 0x274e
movq -0x70(%rbp), %rdi
movq 0xc867(%rip), %rsi      # 0xefc0
callq 0x2100
jmp 0x2760
movq 0xc871(%rip), %rdi      # 0xefd8
leaq 0x6a8b(%rip), %rsi      # 0x91f9
callq 0x20f0
movq %rax, -0x78(%rbp)
jmp 0x2779
leaq -0x20(%rbp), %rdi
callq 0x35e0
movq -0x78(%rbp), %rdi
movzbl %al, %esi
callq 0x21a0
movq %rax, -0x80(%rbp)
jmp 0x2794
movq -0x80(%rbp), %rdi
movq 0xc821(%rip), %rsi      # 0xefc0
callq 0x2100
jmp 0x27a6
leaq -0x28(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3600
movq 0xc81e(%rip), %rdi      # 0xefd8
leaq 0x6a13(%rip), %rsi      # 0x91d4
callq 0x20f0
movq %rax, -0x88(%rbp)
jmp 0x27cf
leaq -0x28(%rbp), %rdi
callq 0x3590
movq %rax, %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movb %al, -0x89(%rbp)
jmp 0x27ec
movq -0x88(%rbp), %rdi
movb -0x89(%rbp), %al
movsbl %al, %esi
callq 0x2120
movq %rax, -0x98(%rbp)
jmp 0x280a
movq -0x98(%rbp), %rdi
movq 0xc7a8(%rip), %rsi      # 0xefc0
callq 0x2100
jmp 0x281f
movq 0xc7b2(%rip), %rdi      # 0xefd8
leaq 0x69f2(%rip), %rsi      # 0x921f
callq 0x20f0
movq %rax, -0xa0(%rbp)
jmp 0x283b
leaq -0x20(%rbp), %rdi
callq 0x35e0
movq -0xa0(%rbp), %rdi
movzbl %al, %esi
callq 0x21a0
movq %rax, -0xa8(%rbp)
jmp 0x285c
movq -0xa8(%rbp), %rdi
movq 0xc756(%rip), %rsi      # 0xefc0
callq 0x2100
jmp 0x2871
leaq -0x28(%rbp), %rdi
callq 0x3630
leaq -0x20(%rbp), %rdi
callq 0x3630
movq 0xc74e(%rip), %rdi      # 0xefd8
leaq 0x69b3(%rip), %rsi      # 0x9244
callq 0x20f0
movq %rax, -0xb0(%rbp)
jmp 0x289f
movq -0xb0(%rbp), %rdi
movq 0xc713(%rip), %rsi      # 0xefc0
callq 0x2100
jmp 0x28b4
leaq -0x8(%rbp), %rdi
callq 0x3630
addq $0xb0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
callq 0x2370
jmp 0x2920
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0x2917
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0x290e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3630
leaq -0x20(%rbp), %rdi
callq 0x3630
leaq -0x8(%rbp), %rdi
callq 0x3630
movq -0x10(%rbp), %rdi
callq 0x2190
nopl (%rax)