// File: ostafen[P]Fast-Insertion-Sort/src/bench.cpp
// Function: BenchmarkExecutor<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>::run(std::vector<SortAlgorithm<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>*, std::allocator<SortAlgorithm<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>*>>*, int)
void run(std::vector<SortAlgorithm<T> *> *algos, int n)
    {
        int maxNameLength = -1;
        for (SortAlgorithm<T> *algo : *algos)
        {
            int length = algo->name().length();
            if (length > maxNameLength)
                maxNameLength = length;
        }

        for (int size = minSize; size <= maxSize; size *= 2)
        {
            double time[30];
            for (int i = 0; i < 30; i++)
                time[i] = 0;

            cout << "Size: " << size << endl
                 << endl;

            for (int z = 0; z < n; z++)
            {
                T *A = gen->random(size);
                T *B = arrayCopy<T>(A, size);

                int c = 0;
                for (SortAlgorithm<T> *algo : *algos)
                {
                    int start = clock();
                    algo->sort(B, size);
                    int elapsedTime = clock() - start;
                    time[c++] += (((double)elapsedTime / (double)n) / CLOCKS_PER_SEC) * 1000;

                    for (int i = 0; i < size; i++)
                    {
                        B[i] = A[i];
                    }
                }

                delete[] A;
                delete[] B;
            }

            int c = 0;
            for (SortAlgorithm<T> *algo : *algos)
            {
                cout << setw(maxNameLength) << left
                     << algo->name() << ": " << setw(10) << right << time[c++] << endl;
            }

            cout << endl;
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x210(%rbp)
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0xa490
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0xa2e0
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa880
testb $0x1, %al
jne 0x462d
jmp 0x4687
leaq -0x28(%rbp), %rdi
callq 0xa860
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rsi
movq (%rsi), %rax
leaq -0x60(%rbp), %rdi
callq *0x8(%rax)
leaq -0x60(%rbp), %rdi
callq 0x3320
movl %eax, -0x214(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3120
movl -0x214(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jle 0x467a
movl -0x3c(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x467c
leaq -0x28(%rbp), %rdi
callq 0xa8c0
jmp 0x461a
movq -0x210(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x210(%rbp), %rcx
movl -0x64(%rbp), %eax
cmpl 0xc(%rcx), %eax
jg 0x4bea
movl $0x0, -0x164(%rbp)
cmpl $0x1e, -0x164(%rbp)
jge 0x46de
movslq -0x164(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x160(%rbp,%rax,8)
movl -0x164(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x164(%rbp)
jmp 0x46b1
movq 0xd8f3(%rip), %rdi      # 0x11fd8
leaq 0x7aaa(%rip), %rsi      # 0xc196
callq 0x3210
movq %rax, %rdi
movl -0x64(%rbp), %esi
callq 0x3370
movq %rax, %rdi
movq 0xd8c2(%rip), %rsi      # 0x11fc8
callq 0x3240
movq %rax, %rdi
movq 0xd8b3(%rip), %rsi      # 0x11fc8
callq 0x3240
movl $0x0, -0x168(%rbp)
movl -0x168(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4a09
movq -0x210(%rbp), %rax
movq (%rax), %rdi
movl -0x64(%rbp), %esi
movq (%rdi), %rax
callq *(%rax)
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0xa8e0
movq %rax, -0x178(%rbp)
movl $0x0, -0x17c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rdi
callq 0xa490
movq %rax, -0x190(%rbp)
movq -0x188(%rbp), %rdi
callq 0xa2e0
movq %rax, -0x198(%rbp)
leaq -0x190(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0xa880
testb $0x1, %al
jne 0x47b9
jmp 0x48bf
leaq -0x190(%rbp), %rdi
callq 0xa860
movq (%rax), %rax
movq %rax, -0x1a0(%rbp)
callq 0x3140
movl %eax, -0x1a4(%rbp)
movq -0x1a0(%rbp), %rdi
movq -0x178(%rbp), %rsi
movl -0x64(%rbp), %edx
movq (%rdi), %rax
callq *(%rax)
callq 0x3140
movslq -0x1a4(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x1a8(%rbp)
cvtsi2sdl -0x1a8(%rbp), %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x77f2(%rip), %xmm1     # 0xc010
divsd %xmm1, %xmm0
movl -0x17c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x17c(%rbp)
cltq
movsd -0x160(%rbp,%rax,8), %xmm1
movsd 0x77c2(%rip), %xmm2     # 0xc008
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x160(%rbp,%rax,8)
movl $0x0, -0x1ac(%rbp)
movl -0x1ac(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x48ac
movq -0x170(%rbp), %rsi
movslq -0x1ac(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
movq -0x178(%rbp), %rdi
movslq -0x1ac(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x3050
movl -0x1ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ac(%rbp)
jmp 0x4861
jmp 0x48ae
leaq -0x190(%rbp), %rdi
callq 0xa8c0
jmp 0x479d
movq -0x170(%rbp), %rax
movq %rax, -0x220(%rbp)
cmpq $0x0, %rax
je 0x4959
movq -0x220(%rbp), %rcx
movq %rcx, %rax
addq $-0x8, %rax
movq %rax, -0x238(%rbp)
movq -0x8(%rcx), %rdx
movq %rdx, -0x230(%rbp)
shlq $0x5, %rdx
movq %rcx, %rax
addq %rdx, %rax
cmpq %rax, %rcx
movq %rax, -0x228(%rbp)
je 0x493e
movq -0x228(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x240(%rbp)
callq 0x3120
movq -0x220(%rbp), %rcx
movq -0x240(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x228(%rbp)
jne 0x490d
movq -0x238(%rbp), %rdi
movq -0x230(%rbp), %rsi
shlq $0x5, %rsi
addq $0x8, %rsi
callq 0x33e0
movq -0x178(%rbp), %rax
movq %rax, -0x248(%rbp)
cmpq $0x0, %rax
je 0x49f3
movq -0x248(%rbp), %rcx
movq %rcx, %rax
addq $-0x8, %rax
movq %rax, -0x260(%rbp)
movq -0x8(%rcx), %rdx
movq %rdx, -0x258(%rbp)
shlq $0x5, %rdx
movq %rcx, %rax
addq %rdx, %rax
cmpq %rax, %rcx
movq %rax, -0x250(%rbp)
je 0x49d8
movq -0x250(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x268(%rbp)
callq 0x3120
movq -0x248(%rbp), %rcx
movq -0x268(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x250(%rbp)
jne 0x49a7
movq -0x260(%rbp), %rdi
movq -0x258(%rbp), %rsi
shlq $0x5, %rsi
addq $0x8, %rsi
callq 0x33e0
jmp 0x49f5
movl -0x168(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x168(%rbp)
jmp 0x4724
movl $0x0, -0x1b0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rdi
callq 0xa490
movq %rax, -0x1c0(%rbp)
movq -0x1b8(%rbp), %rdi
callq 0xa2e0
movq %rax, -0x1c8(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0xa880
testb $0x1, %al
jne 0x4a60
jmp 0x4bca
leaq -0x1c0(%rbp), %rdi
callq 0xa860
movq (%rax), %rax
movq %rax, -0x1d0(%rbp)
movl -0x18(%rbp), %edi
callq 0x9d70
movl %eax, -0x1d4(%rbp)
movl -0x1d4(%rbp), %esi
movq 0xd547(%rip), %rdi      # 0x11fd8
callq 0x3290
movq %rax, %rdi
leaq 0x52f0(%rip), %rsi      # 0x9d90
callq 0x30a0
movq %rax, -0x280(%rbp)
movq -0x1d0(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x1f8(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq *%rax
movq -0x280(%rbp), %rdi
movq -0x278(%rbp), %rsi
callq 0x31d0
movq %rax, -0x270(%rbp)
jmp 0x4ae6
movq -0x270(%rbp), %rdi
leaq 0x76a6(%rip), %rsi      # 0xc19a
callq 0x3210
movq %rax, -0x288(%rbp)
jmp 0x4b02
movl $0xa, %edi
callq 0x9d70
movq -0x288(%rbp), %rdi
movl %eax, -0x208(%rbp)
movl -0x208(%rbp), %esi
callq 0x3290
movq %rax, -0x290(%rbp)
jmp 0x4b2d
movq -0x290(%rbp), %rdi
leaq 0x5285(%rip), %rsi      # 0x9dc0
callq 0x30a0
movq %rax, -0x298(%rbp)
jmp 0x4b49
movq -0x298(%rbp), %rdi
movslq -0x1b0(%rbp), %rax
movl %eax, %ecx
incl %ecx
movl %ecx, -0x1b0(%rbp)
movsd -0x160(%rbp,%rax,8), %xmm0
callq 0x33c0
movq %rax, -0x2a0(%rbp)
jmp 0x4b78
movq -0x2a0(%rbp), %rdi
movq 0xd442(%rip), %rsi      # 0x11fc8
callq 0x3240
jmp 0x4b8d
leaq -0x1f8(%rbp), %rdi
callq 0x3120
leaq -0x1c0(%rbp), %rdi
callq 0xa8c0
jmp 0x4a44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x3120
jmp 0x4bf3
movq 0xd407(%rip), %rdi      # 0x11fd8
movq 0xd3f0(%rip), %rsi      # 0x11fc8
callq 0x3240
movl -0x64(%rbp), %eax
shll %eax
movl %eax, -0x64(%rbp)
jmp 0x4694
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0x200(%rbp), %rdi
callq 0x3390
nop