// File: shreyas-gopalakrishna[P]Concurrent-Skip-list/main.cpp
// Function: concurrent_skiplist_seperate()
void concurrent_skiplist_seperate(){
    vector<thread> threads;

    // insert
    int chunk_size = ceil(float(numbers_insert.size()) / num_threads);
    for(size_t i = 0; i < numbers_insert.size(); i = i + chunk_size){
        threads.push_back(thread(skiplist_add, i, i+chunk_size));
    }
    for (auto &th : threads) {
        th.join();
    }

    cout << "\n---------- Skip list after insert ----------" << endl;

    skiplist.display();

    threads.clear();

    cout << "\n---------- Deleting the following elements from the Skip list ----------" << endl;

    for (auto i = numbers_delete.begin(); i != numbers_delete.end(); ++i)
    std::cout << *i << ' ';

    // delete
    chunk_size = ceil(float(numbers_delete.size()) / num_threads);
    for(size_t i = 0; i < numbers_delete.size(); i = i + chunk_size){
        threads.push_back(thread(skiplist_remove, i, i+chunk_size));
    }
    for (auto &th : threads) {
        th.join();
    }

    cout << "\n\n---------- Skip list after delete ---------- " << endl;

    skiplist.display();

    threads.clear();

    cout << "\n---------- Searching random numbers in Skip list ---------- " << endl;
    // search
    chunk_size = ceil(float(numbers_get.size()) / num_threads);
    for(size_t i = 0; i < numbers_get.size(); i = i + chunk_size){
        threads.push_back(thread(skiplist_search, i, i+chunk_size));
    }
    for (auto &th : threads) {
        th.join();
    }

    threads.clear();

    cout << "\n---------- Range between random numbers in Skip list ---------- " << endl;
    // range
    for(size_t i = 0; i < num_threads; i++){
        threads.push_back(thread(skiplist_range, numbers_range[i].first, numbers_range[i].second));
    }
    for (auto &th : threads) {
        th.join();
    }

    threads.clear();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
leaq -0x18(%rbp), %rdi
callq 0x57f0
leaq 0x133a5(%rip), %rdi     # 0x17300
callq 0x5400
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x120(%rbp)
testq %rax, %rax
movss %xmm0, -0x11c(%rbp)
js 0x3fa1
movss -0x120(%rbp), %xmm0
movss %xmm0, -0x11c(%rbp)
movss -0x11c(%rbp), %xmm0
movss %xmm0, -0x12c(%rbp)
movq 0x13288(%rip), %rax     # 0x17240
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x128(%rbp)
testq %rax, %rax
movss %xmm0, -0x124(%rbp)
js 0x3ff9
movss -0x128(%rbp), %xmm0
movss %xmm0, -0x124(%rbp)
movss -0x12c(%rbp), %xmm0
movss -0x124(%rbp), %xmm1
divss %xmm1, %xmm0
callq 0x5810
movss %xmm0, -0x130(%rbp)
jmp 0x401c
movss -0x130(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x1c(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq 0x132bb(%rip), %rdi     # 0x17300
callq 0x5400
movq %rax, %rcx
movq -0x138(%rbp), %rax
cmpq %rcx, %rax
jae 0x40d6
movq -0x38(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
leaq -0x6ef(%rip), %rsi      # 0x3980
leaq -0x40(%rbp), %rdi
leaq -0x38(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x5860
jmp 0x4082
leaq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5830
jmp 0x4091
leaq -0x40(%rbp), %rdi
callq 0x5930
movq -0x38(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x4033
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x4849
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5930
jmp 0x4849
leaq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x5960
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0x5990
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x59c0
testb $0x1, %al
jne 0x410b
jmp 0x4130
leaq -0x58(%rbp), %rdi
callq 0x5a00
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x33d0
jmp 0x4123
jmp 0x4125
leaq -0x58(%rbp), %rdi
callq 0x5a20
jmp 0x40f8
movq 0x12e91(%rip), %rdi     # 0x16fc8
leaq 0xb357(%rip), %rsi      # 0xf495
callq 0x3240
movq %rax, -0x140(%rbp)
jmp 0x414c
movq -0x140(%rbp), %rdi
movq 0x12e4e(%rip), %rsi     # 0x16fa8
callq 0x3280
jmp 0x4161
leaq 0x13188(%rip), %rdi     # 0x172f0
callq 0xc660
jmp 0x416f
leaq -0x18(%rbp), %rdi
callq 0x5a40
movq 0x12e49(%rip), %rdi     # 0x16fc8
leaq 0xb33d(%rip), %rsi      # 0xf4c3
callq 0x3240
movq %rax, -0x148(%rbp)
jmp 0x4194
movq -0x148(%rbp), %rdi
movq 0x12e06(%rip), %rsi     # 0x16fa8
callq 0x3280
jmp 0x41a9
leaq 0x13168(%rip), %rdi     # 0x17318
callq 0x5a60
movq %rax, -0x70(%rbp)
leaq 0x13158(%rip), %rdi     # 0x17318
callq 0x5ad0
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x5a90
testb $0x1, %al
jne 0x41dc
jmp 0x421c
leaq -0x70(%rbp), %rdi
callq 0x5b00
movl (%rax), %esi
movq 0x12dda(%rip), %rdi     # 0x16fc8
callq 0x33e0
movq %rax, -0x150(%rbp)
jmp 0x41fc
movq -0x150(%rbp), %rdi
movl $0x20, %esi
callq 0x32e0
jmp 0x420f
jmp 0x4211
leaq -0x70(%rbp), %rdi
callq 0x5b20
jmp 0x41b9
leaq 0x130f5(%rip), %rdi     # 0x17318
callq 0x5400
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x158(%rbp)
testq %rax, %rax
movss %xmm0, -0x154(%rbp)
js 0x4269
movss -0x158(%rbp), %xmm0
movss %xmm0, -0x154(%rbp)
movss -0x154(%rbp), %xmm0
movss %xmm0, -0x164(%rbp)
movq 0x12fc0(%rip), %rax     # 0x17240
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x160(%rbp)
testq %rax, %rax
movss %xmm0, -0x15c(%rbp)
js 0x42c1
movss -0x160(%rbp), %xmm0
movss %xmm0, -0x15c(%rbp)
movss -0x164(%rbp), %xmm0
movss -0x15c(%rbp), %xmm1
divss %xmm1, %xmm0
callq 0x5810
movss %xmm0, -0x168(%rbp)
jmp 0x42e4
movss -0x168(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x1c(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq 0x1300b(%rip), %rdi     # 0x17318
callq 0x5400
movq %rax, %rcx
movq -0x170(%rbp), %rax
cmpq %rcx, %rax
jae 0x43a6
movq -0x80(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
leaq -0x83e(%rip), %rsi      # 0x3b00
leaq -0x88(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq -0x90(%rbp), %rcx
callq 0x5860
jmp 0x4357
leaq -0x18(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x5830
jmp 0x4369
leaq -0x88(%rbp), %rdi
callq 0x5930
movq -0x80(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
jmp 0x42fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x5930
jmp 0x4849
leaq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x5960
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rdi
callq 0x5990
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x59c0
testb $0x1, %al
jne 0x43f0
jmp 0x4421
leaq -0xa0(%rbp), %rdi
callq 0x5a00
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x33d0
jmp 0x4411
jmp 0x4413
leaq -0xa0(%rbp), %rdi
callq 0x5a20
jmp 0x43d7
movq 0x12ba0(%rip), %rdi     # 0x16fc8
leaq 0xb0de(%rip), %rsi      # 0xf50d
callq 0x3240
movq %rax, -0x178(%rbp)
jmp 0x443d
movq -0x178(%rbp), %rdi
movq 0x12b5d(%rip), %rsi     # 0x16fa8
callq 0x3280
jmp 0x4452
leaq 0x12e97(%rip), %rdi     # 0x172f0
callq 0xc660
jmp 0x4460
leaq -0x18(%rbp), %rdi
callq 0x5a40
movq 0x12b58(%rip), %rdi     # 0x16fc8
leaq 0xb0c6(%rip), %rsi      # 0xf53d
callq 0x3240
movq %rax, -0x180(%rbp)
jmp 0x4485
movq -0x180(%rbp), %rdi
movq 0x12b15(%rip), %rsi     # 0x16fa8
callq 0x3280
jmp 0x449a
leaq 0x12e8f(%rip), %rdi     # 0x17330
callq 0x5400
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x188(%rbp)
testq %rax, %rax
movss %xmm0, -0x184(%rbp)
js 0x44e7
movss -0x188(%rbp), %xmm0
movss %xmm0, -0x184(%rbp)
movss -0x184(%rbp), %xmm0
movss %xmm0, -0x194(%rbp)
movq 0x12d42(%rip), %rax     # 0x17240
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x190(%rbp)
testq %rax, %rax
movss %xmm0, -0x18c(%rbp)
js 0x453f
movss -0x190(%rbp), %xmm0
movss %xmm0, -0x18c(%rbp)
movss -0x194(%rbp), %xmm0
movss -0x18c(%rbp), %xmm1
divss %xmm1, %xmm0
callq 0x5810
movss %xmm0, -0x198(%rbp)
jmp 0x4562
movss -0x198(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x1c(%rbp)
movq $0x0, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq 0x12d9f(%rip), %rdi     # 0x17330
callq 0x5400
movq %rax, %rcx
movq -0x1a0(%rbp), %rax
cmpq %rcx, %rax
jae 0x4636
movq -0xb8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
leaq -0xa15(%rip), %rsi      # 0x3bb0
leaq -0xc0(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
callq 0x5860
jmp 0x45e1
leaq -0x18(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x5830
jmp 0x45f3
leaq -0xc0(%rbp), %rdi
callq 0x5930
movq -0xb8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
jmp 0x457c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x5930
jmp 0x4849
leaq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x5960
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x5990
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x59c0
testb $0x1, %al
jne 0x4680
jmp 0x46b1
leaq -0xd8(%rbp), %rdi
callq 0x5a00
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x33d0
jmp 0x46a1
jmp 0x46a3
leaq -0xd8(%rbp), %rdi
callq 0x5a20
jmp 0x4667
leaq -0x18(%rbp), %rdi
callq 0x5a40
movq 0x12907(%rip), %rdi     # 0x16fc8
leaq 0xaeb3(%rip), %rsi      # 0xf57b
callq 0x3240
movq %rax, -0x1a8(%rbp)
jmp 0x46d6
movq -0x1a8(%rbp), %rdi
movq 0x128c4(%rip), %rsi     # 0x16fa8
callq 0x3280
jmp 0x46eb
movq $0x0, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
cmpq 0x12b3c(%rip), %rax     # 0x17240
jae 0x47b3
movq -0xf0(%rbp), %rsi
leaq 0x12c30(%rip), %rdi     # 0x17348
movq %rdi, -0x1b8(%rbp)
callq 0x5b40
movq -0x1b8(%rbp), %rdi
movq %rax, -0x1b0(%rbp)
movq -0xf0(%rbp), %rsi
callq 0x5b40
movq -0x1b0(%rbp), %rdx
movq %rax, %rcx
addq $0x4, %rcx
leaq -0xa33(%rip), %rsi      # 0x3d20
leaq -0xf8(%rbp), %rdi
callq 0x5b60
jmp 0x4761
leaq -0x18(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x5830
jmp 0x4773
leaq -0xf8(%rbp), %rdi
callq 0x5930
movq -0xf0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf0(%rbp)
jmp 0x46f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x5930
jmp 0x4849
leaq -0x18(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rdi
callq 0x5960
movq %rax, -0x108(%rbp)
movq -0x100(%rbp), %rdi
callq 0x5990
movq %rax, -0x110(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x59c0
testb $0x1, %al
jne 0x47fd
jmp 0x482e
leaq -0x108(%rbp), %rdi
callq 0x5a00
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rdi
callq 0x33d0
jmp 0x481e
jmp 0x4820
leaq -0x108(%rbp), %rdi
callq 0x5a20
jmp 0x47e4
leaq -0x18(%rbp), %rdi
callq 0x5a40
leaq -0x18(%rbp), %rdi
callq 0x5c30
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x18(%rbp), %rdi
callq 0x5c30
movq -0x28(%rbp), %rdi
callq 0x33f0
nopl (%rax,%rax)