// File: vividvilla[P]hackerrank/src/quicksort2.cpp
// Function: quickSortAux(std::vector<int, std::allocator<int>>&, int, int)
void quickSortAux(vector<int> & v, int l, int r) {
    if (l >= r)
        return;

    int p = v[l];
    vector<int> p1;
    vector<int> p2;
    for (int i = l + 1; i <= r; i++) {
        if (v[i] < p)
            p1.push_back(v[i]);
        else if (v[i] > p)
            p2.push_back(v[i]);
    }
    int m = l + p1.size();
    p1.push_back(p);
    p1.insert(p1.end(), p2.begin(), p2.end());

    for (int i = l; i <= r; i++)
        v[i] = p1[i - l];

    quickSortAux(v, l, m - 1);
    quickSortAux(v, m + 1, r);

    for (int i = l; i <= r; i++) {
        cout << v[i];
        if (i + 1 <= r)
            cout << " ";
        else
            cout << endl;
    }
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movl %esi, 0xbc(%rsp)
movl %edx, 0xb8(%rsp)
movl 0xbc(%rsp), %eax
cmpl 0xb8(%rsp), %eax
jl 0x12b2
jmp 0x15bb
movq 0xc0(%rsp), %rdi
movslq 0xbc(%rsp), %rsi
callq 0x16d0
movl (%rax), %eax
movl %eax, 0xb4(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x16f0
leaq 0x80(%rsp), %rdi
callq 0x16f0
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
movl 0x7c(%rsp), %eax
cmpl 0xb8(%rsp), %eax
jg 0x13d0
movq 0xc0(%rsp), %rdi
movslq 0x7c(%rsp), %rsi
callq 0x16d0
movl (%rax), %eax
cmpl 0xb4(%rsp), %eax
jge 0x1379
movq 0xc0(%rsp), %rdi
movslq 0x7c(%rsp), %rsi
callq 0x16d0
movq %rax, %rsi
leaq 0x98(%rsp), %rdi
callq 0x1700
jmp 0x134a
jmp 0x13be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x18f0
leaq 0x98(%rsp), %rdi
callq 0x18f0
jmp 0x15c3
movq 0xc0(%rsp), %rdi
movslq 0x7c(%rsp), %rsi
callq 0x16d0
movl (%rax), %eax
cmpl 0xb4(%rsp), %eax
jle 0x13bc
movq 0xc0(%rsp), %rdi
movslq 0x7c(%rsp), %rsi
callq 0x16d0
movq %rax, %rsi
leaq 0x80(%rsp), %rdi
callq 0x1700
jmp 0x13ba
jmp 0x13bc
jmp 0x13be
jmp 0x13c0
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x12f8
movl 0xbc(%rsp), %eax
movl %eax, 0x34(%rsp)
leaq 0x98(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x1770
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl 0x34(%rsp), %eax
addl %ecx, %eax
movl %eax, 0x68(%rsp)
leaq 0xb4(%rsp), %rsi
callq 0x1700
jmp 0x140e
leaq 0x98(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x1850
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x1880
leaq 0x80(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x18c0
movq 0x10(%rsp), %rdi
movq %rax, 0x50(%rsp)
callq 0x1850
movq 0x18(%rsp), %rdi
movq %rax, 0x48(%rsp)
movq 0x60(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x48(%rsp), %rcx
callq 0x1790
movq %rax, 0x20(%rsp)
jmp 0x147a
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0xbc(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0xb8(%rsp), %eax
jg 0x14e2
movl 0x3c(%rsp), %eax
subl 0xbc(%rsp), %eax
movslq %eax, %rsi
leaq 0x98(%rsp), %rdi
callq 0x16d0
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movq 0xc0(%rsp), %rdi
movslq 0x3c(%rsp), %rsi
callq 0x16d0
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x148f
movq 0xc0(%rsp), %rdi
movl 0xbc(%rsp), %esi
movl 0x68(%rsp), %edx
decl %edx
callq 0x1280
jmp 0x14fe
movq 0xc0(%rsp), %rdi
movl 0x68(%rsp), %esi
incl %esi
movl 0xb8(%rsp), %edx
callq 0x1280
jmp 0x151a
movl 0xbc(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x38(%rsp), %eax
cmpl 0xb8(%rsp), %eax
jg 0x15a1
movq 0xc0(%rsp), %rdi
movslq 0x38(%rsp), %rsi
callq 0x16d0
movl (%rax), %esi
movq 0x5a83(%rip), %rdi      # 0x6fd0
callq 0x1120
jmp 0x1554
movl 0x38(%rsp), %eax
addl $0x1, %eax
cmpl 0xb8(%rsp), %eax
jg 0x157b
movq 0x5a65(%rip), %rdi      # 0x6fd0
leaq 0x2a92(%rip), %rsi      # 0x4004
callq 0x10a0
jmp 0x1579
jmp 0x1592
movq 0x5a4e(%rip), %rdi      # 0x6fd0
movq 0x5a37(%rip), %rsi      # 0x6fc0
callq 0x10d0
jmp 0x1590
jmp 0x1592
jmp 0x1594
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x1525
leaq 0x80(%rsp), %rdi
callq 0x18f0
leaq 0x98(%rsp), %rdi
callq 0x18f0
addq $0xc8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0x1130
nopl (%rax)