// File: Baobaobear[P]sort/demo.cpp
// Function: main
int main(void)
{
    typedef int sort_t;
    const size_t count = 1000;
    std::vector<sort_t> arr;

    for (size_t i = 0; i < count; i++)
    {
        arr.push_back(i);
    }

    baobao::random_shuffle(arr.begin(), arr.end());
    baobao::sort::insert_sort(arr.begin(), arr.end());
    print_check_sorted(arr.begin(), arr.end());

    baobao::random_shuffle(arr.begin(), arr.end());
    baobao::sort::heap_sort(arr.begin(), arr.end());
    print_check_sorted(arr.begin(), arr.end());

    baobao::random_shuffle(arr.begin(), arr.end());
    baobao::sort::shell_sort(arr.begin(), arr.end());
    print_check_sorted(arr.begin(), arr.end());

    baobao::random_shuffle(arr.begin(), arr.end());
    baobao::sort::quick_sort(arr.begin(), arr.end());
    print_check_sorted(arr.begin(), arr.end());

    baobao::random_shuffle(arr.begin(), arr.end());
    baobao::sort::merge_sort(arr.begin(), arr.end());
    print_check_sorted(arr.begin(), arr.end());

    baobao::random_shuffle(arr.begin(), arr.end());
    baobao::sort::tim_sort(arr.begin(), arr.end());
    print_check_sorted(arr.begin(), arr.end());

    return 0;
}

// Assembly:
subq $0x288, %rsp            # imm = 0x288
movl $0x0, 0x284(%rsp)
movq $0x3e8, 0x278(%rsp) # imm = 0x3E8
leaq 0x260(%rsp), %rdi
callq 0x2770
movq $0x0, 0x258(%rsp)
cmpq $0x3e8, 0x258(%rsp) # imm = 0x3E8
jae 0x1948
movl 0x258(%rsp), %eax
movl %eax, 0x254(%rsp)
leaq 0x260(%rsp), %rdi
leaq 0x254(%rsp), %rsi
callq 0x2780
jmp 0x190a
jmp 0x190c
movq 0x258(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x258(%rsp)
jmp 0x18d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x248(%rsp)
movl %eax, 0x244(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x2ad0
jmp 0x2027
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x118(%rsp)
jmp 0x195f
movq 0x118(%rsp), %rax
movq %rax, 0x238(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x110(%rsp)
jmp 0x1986
movq 0x110(%rsp), %rax
movq %rax, 0x230(%rsp)
movq 0x238(%rsp), %rdi
movq 0x230(%rsp), %rsi
callq 0x27f0
jmp 0x19ad
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x108(%rsp)
jmp 0x19c4
movq 0x108(%rsp), %rax
movq %rax, 0x228(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x100(%rsp)
jmp 0x19eb
movq 0x100(%rsp), %rax
movq %rax, 0x220(%rsp)
movq 0x228(%rsp), %rdi
movq 0x220(%rsp), %rsi
callq 0x28f0
jmp 0x1a12
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0xf8(%rsp)
jmp 0x1a29
movq 0xf8(%rsp), %rax
movq %rax, 0x218(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0xf0(%rsp)
jmp 0x1a50
movq 0xf0(%rsp), %rax
movq %rax, 0x210(%rsp)
movq 0x218(%rsp), %rdi
movq 0x210(%rsp), %rsi
callq 0x2930
jmp 0x1a77
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0xe8(%rsp)
jmp 0x1a8e
movq 0xe8(%rsp), %rax
movq %rax, 0x208(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0xe0(%rsp)
jmp 0x1ab5
movq 0xe0(%rsp), %rax
movq %rax, 0x200(%rsp)
movq 0x208(%rsp), %rdi
movq 0x200(%rsp), %rsi
callq 0x27f0
jmp 0x1adc
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0xd8(%rsp)
jmp 0x1af3
movq 0xd8(%rsp), %rax
movq %rax, 0x1f8(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0xd0(%rsp)
jmp 0x1b1a
movq 0xd0(%rsp), %rax
movq %rax, 0x1f0(%rsp)
movq 0x1f8(%rsp), %rdi
movq 0x1f0(%rsp), %rsi
callq 0x2990
jmp 0x1b41
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0xc8(%rsp)
jmp 0x1b58
movq 0xc8(%rsp), %rax
movq %rax, 0x1e8(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0xc0(%rsp)
jmp 0x1b7f
movq 0xc0(%rsp), %rax
movq %rax, 0x1e0(%rsp)
movq 0x1e8(%rsp), %rdi
movq 0x1e0(%rsp), %rsi
callq 0x2930
jmp 0x1ba6
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0xb8(%rsp)
jmp 0x1bbd
movq 0xb8(%rsp), %rax
movq %rax, 0x1d8(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0xb0(%rsp)
jmp 0x1be4
movq 0xb0(%rsp), %rax
movq %rax, 0x1d0(%rsp)
movq 0x1d8(%rsp), %rdi
movq 0x1d0(%rsp), %rsi
callq 0x27f0
jmp 0x1c0b
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0xa8(%rsp)
jmp 0x1c22
movq 0xa8(%rsp), %rax
movq %rax, 0x1c8(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0xa0(%rsp)
jmp 0x1c49
movq 0xa0(%rsp), %rax
movq %rax, 0x1c0(%rsp)
movq 0x1c8(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
callq 0x29d0
jmp 0x1c70
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x98(%rsp)
jmp 0x1c87
movq 0x98(%rsp), %rax
movq %rax, 0x1b8(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x90(%rsp)
jmp 0x1cae
movq 0x90(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x1b8(%rsp), %rdi
movq 0x1b0(%rsp), %rsi
callq 0x2930
jmp 0x1cd5
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x88(%rsp)
jmp 0x1cec
movq 0x88(%rsp), %rax
movq %rax, 0x1a8(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x80(%rsp)
jmp 0x1d13
movq 0x80(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x1a8(%rsp), %rdi
movq 0x1a0(%rsp), %rsi
callq 0x27f0
jmp 0x1d3a
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x78(%rsp)
jmp 0x1d4e
movq 0x78(%rsp), %rax
movq %rax, 0x198(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x70(%rsp)
jmp 0x1d6f
movq 0x70(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x198(%rsp), %rdi
movq 0x190(%rsp), %rsi
callq 0x2a10
jmp 0x1d93
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x68(%rsp)
jmp 0x1da7
movq 0x68(%rsp), %rax
movq %rax, 0x188(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x60(%rsp)
jmp 0x1dc8
movq 0x60(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x188(%rsp), %rdi
movq 0x180(%rsp), %rsi
callq 0x2930
jmp 0x1dec
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x58(%rsp)
jmp 0x1e00
movq 0x58(%rsp), %rax
movq %rax, 0x178(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x50(%rsp)
jmp 0x1e21
movq 0x50(%rsp), %rax
movq %rax, 0x170(%rsp)
movq 0x178(%rsp), %rdi
movq 0x170(%rsp), %rsi
callq 0x27f0
jmp 0x1e45
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x48(%rsp)
jmp 0x1e59
movq 0x48(%rsp), %rax
movq %rax, 0x168(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x40(%rsp)
jmp 0x1e7a
movq 0x40(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x168(%rsp), %rdi
movq 0x160(%rsp), %rsi
callq 0x2a50
jmp 0x1e9e
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x38(%rsp)
jmp 0x1eb2
movq 0x38(%rsp), %rax
movq %rax, 0x158(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x30(%rsp)
jmp 0x1ed3
movq 0x30(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x158(%rsp), %rdi
movq 0x150(%rsp), %rsi
callq 0x2930
jmp 0x1ef7
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x28(%rsp)
jmp 0x1f0b
movq 0x28(%rsp), %rax
movq %rax, 0x148(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x20(%rsp)
jmp 0x1f2c
movq 0x20(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rsi
callq 0x27f0
jmp 0x1f50
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x18(%rsp)
jmp 0x1f64
movq 0x18(%rsp), %rax
movq %rax, 0x138(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, 0x10(%rsp)
jmp 0x1f85
movq 0x10(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x138(%rsp), %rdi
movq 0x130(%rsp), %rsi
callq 0x2a90
jmp 0x1fa9
leaq 0x260(%rsp), %rdi
callq 0x2890
movq %rax, 0x8(%rsp)
jmp 0x1fbd
movq 0x8(%rsp), %rax
movq %rax, 0x128(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x28c0
movq %rax, (%rsp)
jmp 0x1fdd
movq (%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x128(%rsp), %rdi
movq 0x120(%rsp), %rsi
callq 0x2930
jmp 0x2000
movl $0x0, 0x284(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x2ad0
movl 0x284(%rsp), %eax
addq $0x288, %rsp            # imm = 0x288
retq
jmp 0x2029
movq 0x248(%rsp), %rdi
callq 0x11a0
movq %rax, %rdi
callq 0x2b50
nop