// File: /workspace/github_cpp_makefile_star2_O2/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)
andq $0x0, -0x20(%rbp)
movq 0x2d5c(%rip), %rdi      # 0x3fd8
leaq 0xd81(%rip), %rsi       # 0x2004
callq 0x10b0
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
leaq 0xd6e(%rip), %rsi       # 0x2011
movq %rax, %rdi
callq 0x10b0
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
movq %rax, %rdi
callq 0x1060
xorl %r15d, %r15d
leaq -0x30(%rbp), %rbx
leaq -0x34(%rbp), %r14
cmpq $0x18, %r15
je 0x12ec
movl %r15d, -0x34(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x15e4
incq %r15
jmp 0x12d2
movq 0x2ce5(%rip), %rdi      # 0x3fd8
leaq 0xd0a(%rip), %rsi       # 0x2004
callq 0x10b0
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
leaq 0xcf7(%rip), %rsi       # 0x2011
movq %rax, %rdi
callq 0x10b0
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
movq %rax, %rdi
callq 0x1060
leaq -0x30(%rbp), %rdi
pushq $0x32
popq %rsi
callq 0x1502
movq 0x2c87(%rip), %rdi      # 0x3fd8
leaq 0xcac(%rip), %rsi       # 0x2004
callq 0x10b0
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
leaq 0xc99(%rip), %rsi       # 0x2011
movq %rax, %rdi
callq 0x10b0
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
movq %rax, %rdi
callq 0x1060
leaq -0x30(%rbp), %rbx
leaq -0x34(%rbp), %r14
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x13bf
andl $0x0, -0x34(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x15e4
jmp 0x13a4
movq 0x2c12(%rip), %rdi      # 0x3fd8
leaq 0xc37(%rip), %rsi       # 0x2004
callq 0x10b0
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
leaq 0xc24(%rip), %rsi       # 0x2011
movq %rax, %rdi
callq 0x10b0
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
movq %rax, %rdi
callq 0x1060
leaq -0x34(%rbp), %rsi
movl $0x2a, (%rsi)
leaq -0x30(%rbp), %rdi
callq 0x15e4
movq 0x2bad(%rip), %rdi      # 0x3fd8
leaq 0xbd2(%rip), %rsi       # 0x2004
callq 0x10b0
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
leaq 0xbbf(%rip), %rsi       # 0x2011
movq %rax, %rdi
callq 0x10b0
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
movq %rax, %rdi
callq 0x1060
leaq -0x30(%rbp), %rdi
callq 0x1764
movq 0x2b52(%rip), %rdi      # 0x3fd8
leaq 0xb77(%rip), %rsi       # 0x2004
callq 0x10b0
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
leaq 0xb64(%rip), %rsi       # 0x2011
movq %rax, %rdi
callq 0x10b0
movq -0x20(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x1080
movq %rax, %rdi
callq 0x1060
leaq -0x30(%rbp), %rdi
callq 0x15a6
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14ed
jmp 0x14ed
jmp 0x14ed
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x15a6
movq %rbx, %rdi
callq 0x1110
nop