// File: /workspace/github_cpp_makefile_star2_O1/ostafen[P]Fast-Insertion-Sort/src/test.cpp
// Function: main
int main()
{
    IntArrayGenerator gen;

    SortAlgorithm<int> *algo[] = {
        new BlockInsertionSort<int>,
        new FastInsertionSort<int>,
        new MergeSort<int>,
        new QuickSort<int>,
        new QuickInsertionSort<int>,
        new ChainedBlockInsertionSort<int>(0.666, new ChainedBlockInsertionSort<int>),
        new ChainedBlockInsertionSort<int>(0.8,
            new ChainedBlockInsertionSort<int>(0.666, new ChainedBlockInsertionSort<int>))
        };

    QuickSort<int> qs;
    MergeSort<int> ms;

    int num_algos = sizeof(algo) / sizeof(SortAlgorithm<int> *);
    for (int i = 0; i < num_algos; i++)
    {
        bool passed = true;
        int size = 512;
        for (int n = 0; n < TEST_NUM; n++)
        {
            SortAlgorithm<int> *oracle = typeid(algo[i]) != typeid(QuickSort<int>) ? (SortAlgorithm<int> *)&qs : (SortAlgorithm<int> *)&ms;

            int *A = gen.random(size);
            int *B = arrayCopy(A, size);
            cout << "e[A\r\e[0K" << algo[i]->name() << ": test "
                 << "[" << n + 1 << "/" << TEST_NUM << "]." << flush;

            oracle->sort(B, size);

            algo[i]->sort(A, size);

            if (!compare(A, B, size))
            {
                passed = false;
                break;
            }
            delete[] A;
            delete[] B;
            size = size * 2;
        }
        cout << "e[A\r\e[0K" << algo[i]->name() << ": " << (passed ? "[OK]." : "[FAILED].") << flush << endl;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
leaq 0x38cb(%rip), %rax      # 0x5c40
movq %rax, 0x40(%rsp)
xorl %edi, %edi
callq 0x20b0
movl %eax, %edi
callq 0x20c0
leaq 0x3871(%rip), %rax      # 0x5c00
movq %rax, 0x40(%rsp)
movabsq $0x7fffffff00000000, %rax # imm = 0x7FFFFFFF00000000
movq %rax, 0x48(%rsp)
movl $0x18, %edi
callq 0x20e0
leaq 0x38a4(%rip), %rcx      # 0x5c58
movq %rcx, (%rax)
leaq 0x38d2(%rip), %rbx      # 0x5c90
movq %rbx, 0x10(%rax)
movq %rax, 0x60(%rsp)
movl $0x20, %edi
callq 0x20e0
leaq 0x3980(%rip), %rcx      # 0x5d58
movq %rcx, (%rax)
movq %rbx, 0x10(%rax)
movl $0x40a00000, 0x18(%rax) # imm = 0x40A00000
movq %rax, 0x68(%rsp)
movl $0x8, %edi
callq 0x20e0
leaq 0x38cc(%rip), %rcx      # 0x5cc8
movq %rcx, (%rax)
movq %rax, 0x70(%rsp)
movl $0x10, %edi
callq 0x20e0
leaq 0x38eb(%rip), %r13      # 0x5d00
movq %r13, (%rax)
movq %rbx, 0x8(%rax)
movq %rax, 0x78(%rsp)
movl $0x10, %edi
callq 0x20e0
leaq 0x38ee(%rip), %rcx      # 0x5d20
movq %rcx, (%rax)
movq %rbx, 0x8(%rax)
movq %rax, 0x80(%rsp)
movl $0x20, %edi
callq 0x20e0
movq %rax, %r14
movl $0x20, %edi
callq 0x20e0
movq %rax, %r15
leaq 0x392e(%rip), %rbp      # 0x5d90
movq %rbp, (%rax)
movl $0x8, %edi
callq 0x20e0
movq %rbx, (%rax)
movq %rax, 0x10(%r15)
movl $0x3f000000, 0x8(%r15)  # imm = 0x3F000000
movl $0x1, 0x18(%r15)
movq %rbp, (%r14)
movl $0x3f2a7efa, 0x8(%r14)  # imm = 0x3F2A7EFA
movq %r15, 0x10(%r14)
movq %r14, 0x88(%rsp)
movl $0x20, %edi
callq 0x20e0
movq %rax, %r14
movl $0x20, %edi
callq 0x20e0
movq %rax, %r15
movl $0x20, %edi
callq 0x20e0
movq %rax, %r12
movq %rbp, (%rax)
movl $0x8, %edi
callq 0x20e0
movq %rbx, (%rax)
movq %rax, 0x10(%r12)
movl $0x3f000000, 0x8(%r12)  # imm = 0x3F000000
movl $0x1, 0x18(%r12)
movq %rbp, (%r15)
movl $0x3f2a7efa, 0x8(%r15)  # imm = 0x3F2A7EFA
movq %r12, 0x10(%r15)
movq %rbp, (%r14)
movl $0x3f4ccccd, 0x8(%r14)  # imm = 0x3F4CCCCD
movq %r15, 0x10(%r14)
movq %r14, 0x90(%rsp)
leaq 0x50(%rsp), %rax
movq %r13, (%rax)
movq %rbx, 0x8(%rax)
movq $0x0, 0x10(%rsp)
movl $0x200, %r12d           # imm = 0x200
movb $0x1, %al
movl %eax, 0xc(%rsp)
xorl %ebp, %ebp
cmpl $0xa, %ebp
je 0x26fd
leaq 0x40(%rsp), %rdi
movl %r12d, %esi
callq 0x285e
movq %rax, %r13
movslq %r12d, %r14
leaq (,%r14,4), %rdi
testl %r14d, %r14d
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x2030
movq %rax, %r15
movl %r12d, 0x3c(%rsp)
movl %r12d, %ebx
testl %r14d, %r14d
jle 0x258e
leaq (,%rbx,4), %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x2090
movl $0x8, %edx
movq 0x3a3e(%rip), %r14      # 0x5fd8
movq %r14, %rdi
leaq 0x1a81(%rip), %rsi      # 0x4025
callq 0x2110
movq 0x10(%rsp), %rax
movq 0x60(%rsp,%rax,8), %r12
movq (%r12), %rax
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
callq *0x8(%rax)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r14, %rdi
callq 0x2110
movq %rax, %r14
movl $0x7, %edx
movq %rax, %rdi
leaq 0x1a48(%rip), %rsi      # 0x402e
callq 0x2110
movl $0x1, %edx
movq %r14, %rdi
leaq 0x1a3c(%rip), %rsi      # 0x4036
callq 0x2110
incl %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x2160
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1a1b(%rip), %rsi      # 0x4038
callq 0x2110
movq %r14, %rdi
movl $0xa, %esi
callq 0x2160
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
leaq 0x1a09(%rip), %rsi      # 0x404a
callq 0x2110
movq %r14, %rdi
callq 0x2060
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x266a
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x20f0
movq 0x50(%rsp), %rax
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
movl 0x3c(%rsp), %r14d
movl %r14d, %edx
callq *(%rax)
movq (%r12), %rax
movq %r12, %rdi
movl %r14d, %r12d
movq %r13, %rsi
movl %r14d, %edx
callq *(%rax)
testl %r14d, %r14d
setle %r14b
jle 0x26cd
movl (%r13), %eax
cmpl (%r15), %eax
jne 0x26ca
movl $0x1, %ecx
movq %rcx, %rax
cmpq %rcx, %rbx
je 0x26c1
movl (%r13,%rax,4), %edx
leaq 0x1(%rax), %rcx
cmpl (%r15,%rax,4), %edx
je 0x26aa
cmpq %rbx, %rax
setae %r14b
jmp 0x26cd
xorl %r14d, %r14d
testb %r14b, %r14b
je 0x26ec
testq %r13, %r13
je 0x26df
movq %r13, %rdi
callq 0x2130
movq %r15, %rdi
callq 0x2130
addl %r12d, %r12d
jmp 0x26f4
movl $0x0, 0xc(%rsp)
testb %r14b, %r14b
jne 0x2534
movl $0x8, %edx
movq 0x38cf(%rip), %rbx      # 0x5fd8
movq %rbx, %rdi
leaq 0x1912(%rip), %rsi      # 0x4025
callq 0x2110
movq 0x10(%rsp), %rax
movq 0x60(%rsp,%rax,8), %rsi
movq (%rsi), %rax
leaq 0x18(%rsp), %rdi
callq *0x8(%rax)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x2110
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
leaq 0x18e9(%rip), %rsi      # 0x403a
callq 0x2110
movl 0xc(%rsp), %ecx
testb $0x1, %cl
leaq 0x18df(%rip), %rsi      # 0x4043
leaq 0x18d2(%rip), %rax      # 0x403d
cmovneq %rax, %rsi
notb %cl
movzbl %cl, %eax
andl $0x1, %eax
leaq 0x5(,%rax,4), %rdx
movq %rbx, %rdi
callq 0x2110
movq %rbx, %rdi
callq 0x2060
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2060
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x27d5
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x20f0
movq 0x10(%rsp), %rcx
incq %rcx
movq %rcx, 0x10(%rsp)
cmpq $0x7, %rcx
jne 0x2526
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x20, %esi
movq %r12, %rdi
callq 0x20f0
jmp 0x2819
jmp 0x2816
jmp 0x2828
movq %rax, %rbx
movl $0x20, %esi
movq %r15, %rdi
callq 0x20f0
jmp 0x282b
movq %rax, %rbx
movl $0x20, %esi
movq %r14, %rdi
jmp 0x2851
jmp 0x2837
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x2856
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x20f0
movq %rbx, %rdi
callq 0x2180