// File: /workspace/github_cpp_makefile_star2_O2/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 0x88(%rsp), %rdi
callq 0x2754
pushq $0x18
popq %rdi
callq 0x2120
leaq 0x4892(%rip), %rcx      # 0x6c58
movq %rcx, (%rax)
leaq 0x48c0(%rip), %r13      # 0x6c90
movq %r13, 0x10(%rax)
movq %rax, 0x40(%rsp)
pushq $0x20
popq %rbx
movq %rbx, %rdi
callq 0x2120
leaq 0x496d(%rip), %rcx      # 0x6d58
movq %rcx, (%rax)
movq %r13, 0x10(%rax)
movl $0x40a00000, 0x18(%rax) # imm = 0x40A00000
movq %rax, 0x48(%rsp)
pushq $0x8
popq %rdi
callq 0x2120
leaq 0x48bb(%rip), %rcx      # 0x6cc8
movq %rcx, (%rax)
movq %rax, 0x50(%rsp)
pushq $0x10
popq %r14
movq %r14, %rdi
callq 0x2120
leaq 0x48d8(%rip), %rcx      # 0x6d00
movq %rcx, (%rax)
movq %r13, 0x8(%rax)
movq %rax, 0x58(%rsp)
movq %r14, %rdi
callq 0x2120
leaq 0x48dd(%rip), %rcx      # 0x6d20
movq %rcx, (%rax)
movq %r13, 0x8(%rax)
movq %rax, 0x60(%rsp)
movq %rbx, %rdi
callq 0x2120
movq %rax, %r14
movq %rbx, %rdi
callq 0x2120
movq %rax, %r15
movq %rax, %rdi
callq 0x2778
leaq 0x491c(%rip), %rbp      # 0x6d90
movq %rbp, (%r14)
movl $0x3f2a7efa, 0x8(%r14)  # imm = 0x3F2A7EFA
movq %r15, 0x10(%r14)
movq %r14, 0x68(%rsp)
pushq $0x20
popq %rbx
movq %rbx, %rdi
callq 0x2120
movq %rax, %r14
movq %rbx, %rdi
callq 0x2120
movq %rax, %r15
pushq $0x20
popq %rdi
callq 0x2120
movq %rax, %r12
movq %rax, %rdi
callq 0x2778
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, 0x70(%rsp)
leaq 0x78(%rsp), %rax
leaq 0x481d(%rip), %rcx      # 0x6d00
movq %rcx, (%rax)
movq %r13, 0x8(%rax)
leaq 0x18(%rsp), %rax
leaq 0x47d2(%rip), %rcx      # 0x6cc8
movq %rcx, (%rax)
xorl %r14d, %r14d
cmpq $0x7, %r14
je 0x26f4
xorl %r12d, %r12d
movl $0x200, %r13d           # imm = 0x200
movq %r14, 0x8(%rsp)
cmpl $0xa, %r12d
je 0x2671
leaq 0x4693(%rip), %rdi      # 0x6bb8
leaq 0x46ac(%rip), %rsi      # 0x6bd8
callq 0x27ac
testb %al, %al
leaq 0x18(%rsp), %rbx
leaq 0x78(%rsp), %rax
cmovneq %rax, %rbx
leaq 0x88(%rsp), %rdi
movl %r13d, %esi
callq 0x27b6
movq %rax, %rbp
movq %rax, %rdi
movl %r13d, 0x4(%rsp)
movl %r13d, %esi
callq 0x2806
movq %rax, 0x10(%rsp)
movq 0x4a68(%rip), %rdi      # 0x6fd8
leaq 0x1ac2(%rip), %rsi      # 0x4039
callq 0x2110
movq %rax, %r15
movq 0x40(%rsp,%r14,8), %r14
movq (%r14), %rax
movq %r12, %r13
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq *0x8(%rax)
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %r12
callq 0x20e0
movq %rax, %rdi
leaq 0x1a92(%rip), %rsi      # 0x4042
callq 0x2110
movq %rax, %rdi
leaq 0x1a8b(%rip), %rsi      # 0x404a
callq 0x2110
leal 0x1(%r12), %r15d
movq %rax, %rdi
movl %r15d, %esi
callq 0x21a0
movq %rax, %rdi
leaq 0x1a6e(%rip), %rsi      # 0x404c
callq 0x2110
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x21a0
movq %rax, %rdi
leaq 0x1a66(%rip), %rsi      # 0x405e
callq 0x2110
movq %rax, %rdi
callq 0x2090
leaq 0x20(%rsp), %rdi
callq 0x2070
movq (%rbx), %rax
movq %rbx, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
movl 0x4(%rsp), %r13d
movl %r13d, %edx
callq *(%rax)
movq (%r14), %rax
movq %r14, %rdi
movq %rbp, %rsi
movl %r13d, %edx
callq *(%rax)
movq %rbp, %rdi
movq %rbx, %rsi
movl %r13d, %edx
callq 0x236c
testb %al, %al
movq 0x8(%rsp), %r14
je 0x2671
testq %rbp, %rbp
je 0x2659
movq %rbp, %rdi
callq 0x2150
testq %rbx, %rbx
je 0x2666
movq %rbx, %rdi
callq 0x2150
addl %r13d, %r13d
movl %r15d, %r12d
jmp 0x2514
movq 0x4960(%rip), %rdi      # 0x6fd8
leaq 0x19ba(%rip), %rsi      # 0x4039
callq 0x2110
movq %rax, %rbx
movq 0x40(%rsp,%r14,8), %rsi
movq (%rsi), %rax
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq *0x8(%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x20e0
movq %rax, %rdi
leaq 0x199f(%rip), %rsi      # 0x404e
callq 0x2110
cmpl $0xa, %r12d
leaq 0x1998(%rip), %rsi      # 0x4057
leaq 0x198b(%rip), %rcx      # 0x4051
cmovaeq %rcx, %rsi
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2090
movq %rax, %rdi
callq 0x2080
leaq 0x20(%rsp), %rdi
callq 0x2070
incq %r14
jmp 0x24fc
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r12, %rdi
callq 0x2130
jmp 0x271f
jmp 0x271c
jmp 0x272c
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0x2130
jmp 0x272f
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x2130
jmp 0x274b
jmp 0x273e
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x21c0
nop