// File: iZhangHui[P]CppPrimer/CH09_SequentialContainers/examples/capacity.cc
// Function: main
int main()
{
    vector<int> ivec;

    // size should be zero; capacity is implementation defined
    cout << "ivec: size: " << ivec.size()
         << " capacity: "  << ivec.capacity() << endl;

    // give ivec 24 elements
    for (vector<int>::size_type ix = 0; ix != 24; ++ix)
         ivec.push_back(ix);

    // size should be 24; capacity will be >= 24 and is implementation defined
    cout << "ivec: size: " << ivec.size()
         << " capacity: "  << ivec.capacity() << endl;
    ivec.reserve(50); // sets capacity to at least 50; might be more
    // size should be 24; capacity will be >= 50 and is implementation defined
    cout << "ivec: size: " << ivec.size()
         << " capacity: "  << ivec.capacity() << endl;

    // add elements to use up the excess capacity
    while (ivec.size() != ivec.capacity())
         ivec.push_back(0);

    // capacity should be unchanged and size and capacity are now equal
    cout << "ivec: size: " << ivec.size()
         << " capacity: "  << ivec.capacity() << endl;
    ivec.push_back(42); // add one more element

    // size should be 51; capacity will be >= 51 and is implementation defined
    cout << "ivec: size: " << ivec.size()
         << " capacity: "  << ivec.capacity() << endl;

    ivec.shrink_to_fit();  // ask for the memory to be returned

    // size should be unchanged; capacity is implementation defined
    cout << "ivec: size: " << ivec.size()
         << " capacity: "  << ivec.capacity() << endl;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movl $0x0, -0x4(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x16a0
movq 0x4d56(%rip), %rdi      # 0x5fd8
leaq 0x1d7b(%rip), %rsi      # 0x3004
callq 0x10a0
movq %rax, -0x50(%rbp)
jmp 0x1294
leaq -0x20(%rbp), %rdi
callq 0x16c0
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0x58(%rbp)
jmp 0x12af
movq -0x58(%rbp), %rdi
leaq 0x1d57(%rip), %rsi      # 0x3011
callq 0x10a0
movq %rax, -0x60(%rbp)
jmp 0x12c5
leaq -0x20(%rbp), %rdi
callq 0x16e0
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0x68(%rbp)
jmp 0x12e0
movq -0x68(%rbp), %rdi
movq 0x4cdd(%rip), %rsi      # 0x5fc8
callq 0x10d0
jmp 0x12f2
movq $0x0, -0x38(%rbp)
cmpq $0x18, -0x38(%rbp)
je 0x1340
movl -0x38(%rbp), %eax
movl %eax, -0x3c(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x1700
jmp 0x1316
jmp 0x1318
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x12fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1850
jmp 0x1688
movq 0x4c91(%rip), %rdi      # 0x5fd8
leaq 0x1cb6(%rip), %rsi      # 0x3004
callq 0x10a0
movq %rax, -0x70(%rbp)
jmp 0x1359
leaq -0x20(%rbp), %rdi
callq 0x16c0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0x78(%rbp)
jmp 0x1374
movq -0x78(%rbp), %rdi
leaq 0x1c92(%rip), %rsi      # 0x3011
callq 0x10a0
movq %rax, -0x80(%rbp)
jmp 0x138a
leaq -0x20(%rbp), %rdi
callq 0x16e0
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0x88(%rbp)
jmp 0x13a8
movq -0x88(%rbp), %rdi
movq 0x4c12(%rip), %rsi      # 0x5fc8
callq 0x10d0
jmp 0x13bd
leaq -0x20(%rbp), %rdi
movl $0x32, %esi
callq 0x1730
jmp 0x13cd
movq 0x4c04(%rip), %rdi      # 0x5fd8
leaq 0x1c29(%rip), %rsi      # 0x3004
callq 0x10a0
movq %rax, -0x90(%rbp)
jmp 0x13e9
leaq -0x20(%rbp), %rdi
callq 0x16c0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0x98(%rbp)
jmp 0x140a
movq -0x98(%rbp), %rdi
leaq 0x1bf9(%rip), %rsi      # 0x3011
callq 0x10a0
movq %rax, -0xa0(%rbp)
jmp 0x1426
leaq -0x20(%rbp), %rdi
callq 0x16e0
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0xa8(%rbp)
jmp 0x1447
movq -0xa8(%rbp), %rdi
movq 0x4b73(%rip), %rsi      # 0x5fc8
callq 0x10d0
jmp 0x145c
jmp 0x145e
leaq -0x20(%rbp), %rdi
callq 0x16c0
movq %rax, -0xb0(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x16e0
movq %rax, %rcx
movq -0xb0(%rbp), %rax
cmpq %rcx, %rax
je 0x149e
movl $0x0, -0x40(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1700
jmp 0x149c
jmp 0x145e
movq 0x4b33(%rip), %rdi      # 0x5fd8
leaq 0x1b58(%rip), %rsi      # 0x3004
callq 0x10a0
movq %rax, -0xb8(%rbp)
jmp 0x14ba
leaq -0x20(%rbp), %rdi
callq 0x16c0
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0xc0(%rbp)
jmp 0x14db
movq -0xc0(%rbp), %rdi
leaq 0x1b28(%rip), %rsi      # 0x3011
callq 0x10a0
movq %rax, -0xc8(%rbp)
jmp 0x14f7
leaq -0x20(%rbp), %rdi
callq 0x16e0
movq -0xc8(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0xd0(%rbp)
jmp 0x1518
movq -0xd0(%rbp), %rdi
movq 0x4aa2(%rip), %rsi      # 0x5fc8
callq 0x10d0
jmp 0x152d
movl $0x2a, -0x44(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x1700
jmp 0x1543
movq 0x4a8e(%rip), %rdi      # 0x5fd8
leaq 0x1ab3(%rip), %rsi      # 0x3004
callq 0x10a0
movq %rax, -0xd8(%rbp)
jmp 0x155f
leaq -0x20(%rbp), %rdi
callq 0x16c0
movq -0xd8(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0xe0(%rbp)
jmp 0x1580
movq -0xe0(%rbp), %rdi
leaq 0x1a83(%rip), %rsi      # 0x3011
callq 0x10a0
movq %rax, -0xe8(%rbp)
jmp 0x159c
leaq -0x20(%rbp), %rdi
callq 0x16e0
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0xf0(%rbp)
jmp 0x15bd
movq -0xf0(%rbp), %rdi
movq 0x49fd(%rip), %rsi      # 0x5fc8
callq 0x10d0
jmp 0x15d2
leaq -0x20(%rbp), %rdi
callq 0x1830
jmp 0x15dd
movq 0x49f4(%rip), %rdi      # 0x5fd8
leaq 0x1a19(%rip), %rsi      # 0x3004
callq 0x10a0
movq %rax, -0xf8(%rbp)
jmp 0x15f9
leaq -0x20(%rbp), %rdi
callq 0x16c0
movq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0x100(%rbp)
jmp 0x161a
movq -0x100(%rbp), %rdi
leaq 0x19e9(%rip), %rsi      # 0x3011
callq 0x10a0
movq %rax, -0x108(%rbp)
jmp 0x1636
leaq -0x20(%rbp), %rdi
callq 0x16e0
movq -0x108(%rbp), %rdi
movq %rax, %rsi
callq 0x1030
movq %rax, -0x110(%rbp)
jmp 0x1657
movq -0x110(%rbp), %rdi
movq 0x4963(%rip), %rsi      # 0x5fc8
callq 0x10d0
jmp 0x166c
movl $0x0, -0x4(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1850
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x1110
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)