// File: iZhangHui[P]CppPrimer/CH04_Expressions/examples/vec_init.cc
// Function: main
int main()
{
    
    vector<int> ivec;                // empty vector
    int cnt = 10;
    // add elements 10 . . . 1 to ivec
    while (cnt > 0)
        ivec.push_back(cnt--);       // int postfix decrement

    auto iter = ivec.begin();
    // prints 10 9 8 . . . 1 
    while (iter != ivec.end())
        cout << *iter++ << endl; // iterator postfix increment

	vector<int> vec2(10, 0);  // ten elements initially all 0
    cnt = vec2.size();
    // assign values from size . . . 1 to the elements in vec2
    for(vector<int>::size_type ix = 0; 
                    ix != vec2.size(); ++ix, --cnt)   
        vec2[ix] = cnt;

    iter = vec2.begin();
    // prints 10 9 8 . . . 1 
    while (iter != vec2.end())
        cout << *iter++ << endl; // iterator postfix increment

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl $0x0, -0x4(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x14a0
movl $0xa, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x1297
movl -0x24(%rbp), %eax
movl %eax, %ecx
decl %ecx
movl %ecx, -0x24(%rbp)
movl %eax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x14c0
jmp 0x1284
jmp 0x1262
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x148e
leaq -0x20(%rbp), %rdi
callq 0x14f0
movq %rax, -0x40(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1560
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1520
testb $0x1, %al
jne 0x12c4
jmp 0x130a
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x1590
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x15d0
movl (%rax), %esi
movq 0x3cf3(%rip), %rdi      # 0x4fd8
callq 0x10e0
movq %rax, -0x98(%rbp)
jmp 0x12f3
movq -0x98(%rbp), %rdi
movq 0x3cc7(%rip), %rsi      # 0x4fc8
callq 0x10b0
jmp 0x1308
jmp 0x12a4
movl $0x0, -0x6c(%rbp)
leaq -0x6d(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x15f0
movq -0xa0(%rbp), %rcx
leaq -0x68(%rbp), %rdi
movl $0xa, %esi
leaq -0x6c(%rbp), %rdx
callq 0x1610
jmp 0x133c
leaq -0x6d(%rbp), %rdi
callq 0x1690
leaq -0x68(%rbp), %rdi
callq 0x16b0
movl %eax, -0x24(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x16b0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
je 0x13cb
movl -0x24(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x78(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x16d0
movl -0xac(%rbp), %ecx
movl %ecx, (%rax)
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1359
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x6d(%rbp), %rdi
callq 0x1690
jmp 0x148e
leaq -0x68(%rbp), %rdi
callq 0x14f0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x1560
movq %rax, -0x88(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1520
testb $0x1, %al
jne 0x1406
jmp 0x1469
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x1590
movq %rax, -0x90(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x15d0
movl (%rax), %esi
movq 0x3bab(%rip), %rdi      # 0x4fd8
callq 0x10e0
movq %rax, -0xb8(%rbp)
jmp 0x143b
movq -0xb8(%rbp), %rdi
movq 0x3b7f(%rip), %rsi      # 0x4fc8
callq 0x10b0
jmp 0x1450
jmp 0x13e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x16f0
jmp 0x148e
movl $0x0, -0x4(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x16f0
leaq -0x20(%rbp), %rdi
callq 0x16f0
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
leaq -0x20(%rbp), %rdi
callq 0x16f0
movq -0x30(%rbp), %rdi
callq 0x10f0