// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
movq 0x2d19(%rip), %rdi      # 0x3fd8
leaq 0xd3e(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2cf5(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0xd1f(%rip), %rsi       # 0x2011
movl $0xb, %edx
movq %rax, %rdi
callq 0x1100
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rbx, %rdi
callq 0x1090
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
xorl %r15d, %r15d
leaq -0x30(%rbp), %rbx
leaq -0x34(%rbp), %r14
movl %r15d, -0x34(%rbp)
movq -0x28(%rbp), %rsi
cmpq -0x20(%rbp), %rsi
je 0x1363
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x28(%rbp)
jmp 0x136e
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1786
incq %r15
cmpq $0x18, %r15
jne 0x1348
movq 0x2c5a(%rip), %rdi      # 0x3fd8
leaq 0xc7f(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2c36(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0xc60(%rip), %rsi       # 0x2011
movl $0xb, %edx
movq %rax, %rdi
callq 0x1100
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rbx, %rdi
callq 0x1090
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
leaq -0x30(%rbp), %rdi
movl $0x32, %esi
callq 0x16d8
movq 0x2bc7(%rip), %rdi      # 0x3fd8
leaq 0xbec(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2ba3(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0xbcd(%rip), %rsi       # 0x2011
movl $0xb, %edx
movq %rax, %rdi
callq 0x1100
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rbx, %rdi
callq 0x1090
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq -0x28(%rbp), %rbx
movq -0x20(%rbp), %r14
cmpq %r14, %rbx
je 0x14c1
subq %rbx, %r14
addq $-0x4, %r14
andq $-0x4, %r14
leaq 0x4(%r14), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1080
leaq (%rbx,%r14), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq 0x2b10(%rip), %rdi      # 0x3fd8
leaq 0xb35(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2aec(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0xb16(%rip), %rsi       # 0x2011
movl $0xb, %edx
movq %rax, %rdi
callq 0x1100
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rbx, %rdi
callq 0x1090
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movl $0x2a, -0x34(%rbp)
movq -0x28(%rbp), %rsi
cmpq -0x20(%rbp), %rsi
je 0x1567
movl $0x2a, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x28(%rbp)
jmp 0x1574
leaq -0x30(%rbp), %rdi
leaq -0x34(%rbp), %rdx
callq 0x1786
movq 0x2a5d(%rip), %rdi      # 0x3fd8
leaq 0xa82(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2a39(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0xa63(%rip), %rsi       # 0x2011
movl $0xb, %edx
movq %rax, %rdi
callq 0x1100
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rbx, %rdi
callq 0x1090
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x160c
leaq -0x30(%rbp), %rdi
callq 0x18c6
movq 0x29c5(%rip), %rdi      # 0x3fd8
leaq 0x9ea(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x29a1(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0x9cb(%rip), %rsi       # 0x2011
movl $0xb, %edx
movq %rax, %rdi
callq 0x1100
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rbx, %rdi
callq 0x1090
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x16a6
movq -0x20(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16b7
jmp 0x16b7
movq %rax, %rbx
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x16cf
movq -0x20(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq %rbx, %rdi
callq 0x1140
nop