// File: emilisb[P]OOP-4/src/main.cpp
// Function: benchmarkResize(unsigned long)
void benchmarkResize(size_t size) {
    vector<int> vec;
    std::vector<int> stdvec;
    int totalRealloc = 0;
    Timer t;

    std::cout << "Benchmark: reallocations inserting " << size << " elements" << std::endl;

    t.start();

    for (int i = 0; i < size; i++) {
        vec.push_back(i);
        if (vec.size() == vec.capacity()) {
            totalRealloc++;
        }
    }

    std::cout << "My vector: << " << totalRealloc << std::endl;

    totalRealloc = 0;
    t.start();

    for (int i = 0; i < size; i++) {
        stdvec.push_back(i);
        if (stdvec.size() == stdvec.capacity()) {
            totalRealloc++;
        }
    }

    std::cout << "STD vector: << " << totalRealloc << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2b00
leaq -0x40(%rbp), %rdi
callq 0x2b80
movl $0x0, -0x44(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2ba0
jmp 0x2643
movq 0x597e(%rip), %rdi      # 0x7fc8
leaq 0x2a32(%rip), %rsi      # 0x5083
callq 0x2170
movq %rax, -0x70(%rbp)
jmp 0x265c
movq -0x70(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x2060
movq %rax, -0x78(%rbp)
jmp 0x266f
movq -0x78(%rbp), %rdi
leaq 0x29dc(%rip), %rsi      # 0x5056
callq 0x2170
movq %rax, -0x80(%rbp)
jmp 0x2685
movq -0x80(%rbp), %rdi
movq 0x5928(%rip), %rsi      # 0x7fb8
callq 0x21a0
jmp 0x2697
leaq -0x50(%rbp), %rdi
callq 0x47a0
jmp 0x26a2
movl $0x0, -0x60(%rbp)
movslq -0x60(%rbp), %rax
cmpq -0x8(%rbp), %rax
jae 0x273b
leaq -0x28(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2bc0
jmp 0x26c6
leaq -0x28(%rbp), %rdi
callq 0x2e00
movq %rax, -0x88(%rbp)
jmp 0x26d8
leaq -0x28(%rbp), %rdi
callq 0x2e20
movq %rax, -0x90(%rbp)
jmp 0x26ea
movq -0x88(%rbp), %rax
movq -0x90(%rbp), %rcx
cmpq %rcx, %rax
jne 0x272b
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x272b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2cc0
leaq -0x28(%rbp), %rdi
callq 0x2d20
jmp 0x2858
jmp 0x272d
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x26a9
movq 0x5886(%rip), %rdi      # 0x7fc8
leaq 0x2917(%rip), %rsi      # 0x5060
callq 0x2170
movq %rax, -0x98(%rbp)
jmp 0x2757
movq -0x98(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x2250
movq %rax, -0xa0(%rbp)
jmp 0x276f
movq -0xa0(%rbp), %rdi
movq 0x583b(%rip), %rsi      # 0x7fb8
callq 0x21a0
jmp 0x2784
movl $0x0, -0x44(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x47a0
jmp 0x2796
movl $0x0, -0x64(%rbp)
movslq -0x64(%rbp), %rax
cmpq -0x8(%rbp), %rax
jae 0x27f4
leaq -0x40(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0x2c50
jmp 0x27b6
leaq -0x40(%rbp), %rdi
callq 0x2e40
movq %rax, -0xa8(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2e60
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jne 0x27e7
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x27e9
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x279d
movq 0x57cd(%rip), %rdi      # 0x7fc8
leaq 0x2871(%rip), %rsi      # 0x5073
callq 0x2170
movq %rax, -0xb0(%rbp)
jmp 0x2810
movq -0xb0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x2250
movq %rax, -0xb8(%rbp)
jmp 0x2828
movq -0xb8(%rbp), %rdi
movq 0x5782(%rip), %rsi      # 0x7fb8
callq 0x21a0
jmp 0x283d
leaq -0x40(%rbp), %rdi
callq 0x2cc0
leaq -0x28(%rbp), %rdi
callq 0x2d20
addq $0xc0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x2260
nopw %cs:(%rax,%rax)