// File: iZhangHui[P]CppPrimer/CH15_ObjectOrientedProgramming/examples/Basket.cc
// Function: Basket::display(std::ostream&) const
void Basket::display(ostream &os) const
{
    os << "Basket size: " << items.size() << endl;

    // print each distinct ISBN in the Basket along with
    // count of how many copies are ordered and what their price will be
    // upper_bound returns an iterator to the next item in the set
    for (auto next_item = items.cbegin();
              next_item != items.cend();
              next_item = items.upper_bound(*next_item))
    {
        // we know there's at least one element with this key in the Basket
        os << (*next_item)->isbn() << " occurs " 
           << items.count(*next_item) << " times" 
           << " for a price of " 
           << (*next_item)->net_price(items.count(*next_item)) 
           << endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x1278(%rip), %rsi      # 0x71ae
callq 0x20d0
movq -0x60(%rbp), %rdi
movq %rax, -0x68(%rbp)
callq 0x6250
movq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x2030
movq %rax, %rdi
movq 0x6062(%rip), %rsi      # 0xbfc0
callq 0x2100
movq -0x60(%rbp), %rdi
callq 0x6270
movq %rax, -0x18(%rbp)
movq -0x60(%rbp), %rdi
callq 0x62d0
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x62a0
testb $0x1, %al
jne 0x5f93
jmp 0x6133
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x6300
movq %rax, %rdi
callq 0x2c90
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0x6330
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x20c0
movq %rax, -0x70(%rbp)
jmp 0x5fcf
movq -0x70(%rbp), %rdi
leaq 0x11e2(%rip), %rsi      # 0x71bc
callq 0x20d0
movq %rax, -0x88(%rbp)
jmp 0x5fe8
leaq -0x18(%rbp), %rdi
callq 0x6300
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x6360
movq %rax, -0x90(%rbp)
jmp 0x6006
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdi
callq 0x2030
movq %rax, -0x98(%rbp)
jmp 0x6022
movq -0x98(%rbp), %rdi
leaq 0x1195(%rip), %rsi      # 0x71c5
callq 0x20d0
movq %rax, -0xa0(%rbp)
jmp 0x603e
movq -0xa0(%rbp), %rdi
leaq 0x1180(%rip), %rsi      # 0x71cc
callq 0x20d0
movq %rax, -0xa8(%rbp)
jmp 0x605a
leaq -0x18(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x6300
movq %rax, %rdi
callq 0x2c90
movq -0xc0(%rbp), %rdi
movq %rax, -0xb8(%rbp)
callq 0x6300
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x6360
movq %rax, -0xb0(%rbp)
jmp 0x609a
movq -0xb0(%rbp), %rsi
movq -0xb8(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movsd %xmm0, -0xc8(%rbp)
jmp 0x60bb
movsd -0xc8(%rbp), %xmm0
movq -0xa8(%rbp), %rdi
callq 0x21a0
movq %rax, -0xd0(%rbp)
jmp 0x60d8
movq -0xd0(%rbp), %rdi
movq 0x5eda(%rip), %rsi      # 0xbfc0
callq 0x2100
jmp 0x60ed
leaq -0x40(%rbp), %rdi
callq 0x2090
leaq -0x18(%rbp), %rdi
callq 0x6300
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x6390
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x5f70
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2090
jmp 0x613c
addq $0xd0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2180
nopw %cs:(%rax,%rax)