// File: kkloberdanz[P]Sort/main.cpp
// Function: timeAnalysis()
void timeAnalysis() {

    srand(time(0));
    std::vector<int> V;
    std::vector<int> Vcopy;
    std::vector<int> sortedVector;

    const uint64_t MAX_LOOPS = 400000000;

    std::cout << "Size, ";
    //std::cout << "Insertion, ";
    std::cout << "Quick, ";
    std::cout << "std::sort\n";

    for (uint64_t j = 2; j < MAX_LOOPS; j = j * 2) {
        for (uint64_t i = 0; i < j; i++) {
            V.push_back(rand() % 100);
        }

        clock_t startTime = clock();
        std::cout << V.size() << ", ";
        /*
        sortedVector = kgk::sort(V, "insertion");
        std::cout << 
            1000*(double)(clock() - startTime)/CLOCKS_PER_SEC 
            << "ms, ";
        sortedVector.clear();
        //V.clear();
        */

        startTime = clock();
        std::cout << "Unsorted: ";
        printVector(V);
        std::cout << std::endl;
        sortedVector = kgk::sort(V, "quick");
        std::cout << 
            1000*(double)(clock() - startTime)/CLOCKS_PER_SEC
            << "ms, ";
        std::cout << "kgk::sort Sorted vector: ";
        printVector(sortedVector);
        sortedVector.clear();
        //V.clear();

        Vcopy = V;
        startTime = clock();
        std::sort(Vcopy.begin(), Vcopy.end());
        std::cout << 
            1000*(double)(clock() - startTime)/CLOCKS_PER_SEC
            << "ms " << std::endl;
        Vcopy.clear();
        V.clear();
    }
}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
xorl %eax, %eax
movl %eax, %edi
callq 0x20f0
movl %eax, %edi
callq 0x2110
leaq 0x140(%rsp), %rdi
callq 0x2e20
leaq 0x128(%rsp), %rdi
callq 0x2e20
leaq 0x110(%rsp), %rdi
callq 0x2e20
movq $0x17d78400, 0x108(%rsp) # imm = 0x17D78400
movq 0xac37(%rip), %rdi      # 0xcfd8
leaq 0x6c70(%rip), %rsi      # 0x9018
callq 0x2120
jmp 0x23af
movq 0xac22(%rip), %rdi      # 0xcfd8
leaq 0x6c62(%rip), %rsi      # 0x901f
callq 0x2120
jmp 0x23c4
movq 0xac0d(%rip), %rdi      # 0xcfd8
leaq 0x6c55(%rip), %rsi      # 0x9027
callq 0x2120
jmp 0x23d9
movq $0x2, 0xf0(%rsp)
cmpq $0x17d78400, 0xf0(%rsp) # imm = 0x17D78400
jae 0x27fb
movq $0x0, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
cmpq 0xf0(%rsp), %rax
jae 0x2485
callq 0x2040
movslq %eax, %rcx
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rcx
addl %edx, %ecx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
movl %eax, 0xe4(%rsp)
leaq 0x140(%rsp), %rdi
leaq 0xe4(%rsp), %rsi
callq 0x2e30
jmp 0x2454
jmp 0x2456
movq 0xe8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe8(%rsp)
jmp 0x2403
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0x282a
callq 0x20b0
movq %rax, 0xd8(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x2e60
movq %rax, %rsi
movq 0xab2f(%rip), %rdi      # 0xcfd8
callq 0x2030
movq %rax, 0x38(%rsp)
jmp 0x24b5
movq 0x38(%rsp), %rdi
leaq 0x6b5b(%rip), %rsi      # 0x901c
callq 0x2120
jmp 0x24c8
callq 0x20b0
movq %rax, 0xd8(%rsp)
movq 0xaafc(%rip), %rdi      # 0xcfd8
leaq 0x6b4f(%rip), %rsi      # 0x9032
callq 0x2120
jmp 0x24ea
leaq 0xc0(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x2f50
jmp 0x2501
leaq 0xc0(%rsp), %rdi
callq 0x2e80
jmp 0x2510
leaq 0xc0(%rsp), %rdi
callq 0x3050
movq 0xaab4(%rip), %rdi      # 0xcfd8
movq 0xaa9d(%rip), %rsi      # 0xcfc8
callq 0x2140
jmp 0x2532
leaq 0x90(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x2f50
jmp 0x2549
leaq 0x6f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x21f0
movq 0x30(%rsp), %rdx
leaq 0x6ad9(%rip), %rsi      # 0x903d
leaq 0x70(%rsp), %rdi
callq 0x2180
jmp 0x2570
leaq 0xa8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x30b0
jmp 0x258c
leaq 0x110(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movq %rsi, 0x20(%rsp)
callq 0x3160
movq 0x20(%rsp), %rdi
callq 0x3050
leaq 0x70(%rsp), %rdi
callq 0x20a0
leaq 0x6f(%rsp), %rdi
callq 0x2150
leaq 0x90(%rsp), %rdi
callq 0x3050
callq 0x20b0
movq 0xd8(%rsp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0x6a1a(%rip), %xmm1     # 0x9008
mulsd %xmm1, %xmm0
movsd 0x6a16(%rip), %xmm1     # 0x9010
divsd %xmm1, %xmm0
movq 0xa9d3(%rip), %rdi      # 0xcfd8
callq 0x2200
movq %rax, 0x28(%rsp)
jmp 0x2611
movq 0x28(%rsp), %rdi
leaq 0x6a26(%rip), %rsi      # 0x9043
callq 0x2120
jmp 0x2624
movq 0xa9ad(%rip), %rdi      # 0xcfd8
leaq 0x6a16(%rip), %rsi      # 0x9048
callq 0x2120
jmp 0x2639
leaq 0x50(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x2f50
jmp 0x264d
leaq 0x50(%rsp), %rdi
callq 0x2e80
jmp 0x2659
leaq 0x50(%rsp), %rdi
callq 0x3050
leaq 0x110(%rsp), %rdi
callq 0x31a0
leaq 0x128(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x31c0
jmp 0x2687
callq 0x20b0
movq %rax, 0xd8(%rsp)
leaq 0x128(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x34c0
movq 0x18(%rsp), %rdi
movq %rax, 0x48(%rsp)
callq 0x34f0
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x3480
jmp 0x26cb
callq 0x20b0
movq 0xd8(%rsp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0x6920(%rip), %xmm1     # 0x9008
mulsd %xmm1, %xmm0
movsd 0x691c(%rip), %xmm1     # 0x9010
divsd %xmm1, %xmm0
movq 0xa8d9(%rip), %rdi      # 0xcfd8
callq 0x2200
movq %rax, 0x10(%rsp)
jmp 0x270b
movq 0x10(%rsp), %rdi
leaq 0x694b(%rip), %rsi      # 0x9062
callq 0x2120
movq %rax, 0x8(%rsp)
jmp 0x2723
movq 0x8(%rsp), %rdi
movq 0xa899(%rip), %rsi      # 0xcfc8
callq 0x2140
jmp 0x2736
leaq 0x128(%rsp), %rdi
callq 0x31a0
leaq 0x140(%rsp), %rdi
callq 0x31a0
movq 0xf0(%rsp), %rax
shlq %rax
movq %rax, 0xf0(%rsp)
jmp 0x23e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x3050
jmp 0x282a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0x27c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x20a0
leaq 0x6f(%rsp), %rdi
callq 0x2150
leaq 0x90(%rsp), %rdi
callq 0x3050
jmp 0x282a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x3050
jmp 0x282a
leaq 0x110(%rsp), %rdi
callq 0x3050
leaq 0x128(%rsp), %rdi
callq 0x3050
leaq 0x140(%rsp), %rdi
callq 0x3050
addq $0x158, %rsp            # imm = 0x158
retq
leaq 0x110(%rsp), %rdi
callq 0x3050
leaq 0x128(%rsp), %rdi
callq 0x3050
leaq 0x140(%rsp), %rdi
callq 0x3050
movq 0x100(%rsp), %rdi
callq 0x21e0
nop