// File: /workspace/github_cpp_makefile_star2_O3/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 0x2d01(%rip), %rdi      # 0x3fd8
xorl %esi, %esi
callq 0x1090
movq %rax, %rbx
leaq 0xd29(%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 0x1359
movl %r15d, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x28(%rbp)
jmp 0x1364
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1786
incq %r15
cmpq $0x18, %r15
jne 0x133e
movq 0x2c64(%rip), %rdi      # 0x3fd8
leaq 0xc89(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2c40(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0xc6a(%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 0x16ce
movq 0x2bd1(%rip), %rdi      # 0x3fd8
leaq 0xbf6(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2bad(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0xbd7(%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 0x14b7
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 0x2b1a(%rip), %rdi      # 0x3fd8
leaq 0xb3f(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2af6(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0xb20(%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 0x155d
movl $0x2a, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x28(%rbp)
jmp 0x156a
leaq -0x30(%rbp), %rdi
leaq -0x34(%rbp), %rdx
callq 0x1786
movq 0x2a67(%rip), %rdi      # 0x3fd8
leaq 0xa8c(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2a43(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0xa6d(%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 0x1602
leaq -0x30(%rbp), %rdi
callq 0x18c6
movq 0x29cf(%rip), %rdi      # 0x3fd8
leaq 0x9f4(%rip), %rsi       # 0x2004
movl $0xc, %edx
callq 0x1100
movq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
sarq $0x2, %rsi
movq 0x29ab(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, %rbx
leaq 0x9d5(%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 0x169c
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 0x16ad
jmp 0x16ad
movq %rax, %rbx
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x16c5
movq -0x20(%rbp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq %rbx, %rdi
callq 0x1140
nop