// File: /workspace/github_cpp_makefile_star2_O3/shreyas-gopalakrishna[P]Concurrent-Skip-list/unit_test_1.cpp
// Function: main
int main(int argc, char *argv[]){

    cout << "\n---------- Unit Test - 1 ----------" << endl;

    cout << "\nThis Unit test uses 4 Threads. Numbers (1-30) are inserted into the skip list parallelly." << endl;
    cout << "Then a few numbers at random are removed from the skip list parallelly. And next a few numbers are searched in the skip list." << endl;
    cout << "Finally, few Range operations are done in the skip list parallelly. The output is dislayed after each step for verification." << endl;
    cout << "This Unit test displays the output. Output may be interleaved since multiple threads tend to print together." << endl;
    

	generate_input(30);

    skiplist = SkipList(numbers_insert.size(), 0.5);

    vector<thread> threads;

    cout << "\n---------- Numbers inserted parallelly ----------" << endl;

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

    // 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();
    }
    threads.clear();

    cout << "\n---------- Skip list after insert ----------" << endl;
    skiplist.display();


    cout << "\n---------- Numbers deleted parallelly ----------" << endl;

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

    // 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();
    }
    threads.clear();

    cout << "\n---------- Skip list after delete ----------" << endl;
    skiplist.display();

    cout << "\n---------- Numbers searched parallelly ----------" << endl;

    for (auto i = numbers_get.begin(); i != numbers_get.end(); ++i)
    std::cout << *i << ' ';
    cout << 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 parallely ---------- " << 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();
    }
	
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq 0x627d(%rip), %rbx      # 0x8fd0
leaq 0x32ff(%rip), %rsi      # 0x6059
movl $0x24, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x32e9(%rip), %rsi      # 0x607e
movl $0x5a, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x3309(%rip), %rsi      # 0x60d9
movl $0x7d, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x334c(%rip), %rsi      # 0x6157
movl $0x7c, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x338e(%rip), %rsi      # 0x61d4
movl $0x6c, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movl $0x1e, %edi
callq 0x255c
movq 0x633d(%rip), %rsi      # 0x91c8
subq 0x632e(%rip), %rsi      # 0x91c0
shrq $0x2, %rsi
leaq 0x10(%rsp), %r14
movss 0x3161(%rip), %xmm0     # 0x6004
movq %r14, %rdi
callq 0x43c0
movups (%r14), %xmm0
movups %xmm0, 0x62fa(%rip)     # 0x91b0
movq %r14, %rdi
callq 0x537a
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
leaq 0x336d(%rip), %rsi      # 0x6241
movl $0x32, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x60d1(%rip), %rbx      # 0x8fd0
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x62aa(%rip), %r12      # 0x91c0
cmpq 0x62ab(%rip), %r12      # 0x91c8
je 0x2f56
movq 0x60aa(%rip), %r14      # 0x8fd0
movq %rsp, %r15
movl (%r12), %esi
movq %r14, %rdi
callq 0x22a0
movb $0x20, (%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2200
addq $0x4, %r12
cmpq 0x6274(%rip), %r12      # 0x91c8
jne 0x2f29
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x605c(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x6240(%rip), %rcx      # 0x91c8
movq 0x6231(%rip), %rdx      # 0x91c0
movq 0x61f2(%rip), %rax      # 0x9188
movq $0x0, (%rsp)
subq %rdx, %rcx
je 0x306d
sarq $0x2, %rcx
js 0x2fb7
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
jmp 0x2fcf
movq %rcx, %rdx
shrq %rdx
andl $0x1, %ecx
orq %rdx, %rcx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
testq %rax, %rax
js 0x2fdb
cvtsi2ss %rax, %xmm1
jmp 0x2ff0
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
callq 0x2100
cvttss2si %xmm0, %eax
movslq %eax, %rbp
xorl %eax, %eax
leaq -0x8c5(%rip), %rbx      # 0x2744
leaq 0x8(%rsp), %r14
movq %rsp, %r15
leaq 0x30(%rsp), %r12
leaq 0x10(%rsp), %r13
addq %rbp, %rax
movq %rax, 0x30(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x3688
movq %r13, %rdi
movq %r14, %rsi
callq 0x3cc8
cmpq $0x0, 0x8(%rsp)
jne 0x3635
movq (%rsp), %rax
addq %rbp, %rax
movq %rax, (%rsp)
movq 0x616b(%rip), %rcx      # 0x91c8
subq 0x615c(%rip), %rcx      # 0x91c0
sarq $0x2, %rcx
cmpq %rcx, %rax
jb 0x301b
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x30b7
movq %rbx, %rdi
callq 0x2290
addq $0x8, %rbx
cmpq %r14, %rbx
jne 0x307c
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpq %rax, %rcx
je 0x30b7
movq %rax, %rdx
cmpq $0x0, (%rdx)
jne 0x3635
addq $0x8, %rdx
cmpq %rcx, %rdx
jne 0x309f
movq %rax, 0x18(%rsp)
movq 0x5f12(%rip), %rbx      # 0x8fd0
leaq 0x31af(%rip), %rsi      # 0x6274
movl $0x2d, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5ee0(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x60ac(%rip), %rdi      # 0x91b0
callq 0x5290
movq 0x5ec0(%rip), %rbx      # 0x8fd0
leaq 0x318b(%rip), %rsi      # 0x62a2
movl $0x31, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5e8e(%rip), %rbx      # 0x8fd0
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x607f(%rip), %r12      # 0x91d8
cmpq 0x6080(%rip), %r12      # 0x91e0
je 0x3199
movq 0x5e67(%rip), %r14      # 0x8fd0
movq %rsp, %r15
movl (%r12), %esi
movq %r14, %rdi
callq 0x22a0
movb $0x20, (%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2200
addq $0x4, %r12
cmpq 0x6049(%rip), %r12      # 0x91e0
jne 0x316c
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5e19(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x6015(%rip), %rcx      # 0x91e0
movq 0x6006(%rip), %rdx      # 0x91d8
movq 0x5faf(%rip), %rax      # 0x9188
movq $0x0, (%rsp)
subq %rdx, %rcx
je 0x32aa
sarq $0x2, %rcx
js 0x31f7
cvtsi2ss %rcx, %xmm0
jmp 0x320c
movq %rcx, %rdx
shrq %rdx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
testq %rax, %rax
js 0x3218
cvtsi2ss %rax, %xmm1
jmp 0x322d
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
callq 0x2100
cvttss2si %xmm0, %eax
movslq %eax, %rbp
xorl %eax, %eax
leaq -0x8ba(%rip), %rbx      # 0x298c
leaq 0x8(%rsp), %r14
movq %rsp, %r15
leaq 0x30(%rsp), %r12
leaq 0x10(%rsp), %r13
addq %rbp, %rax
movq %rax, 0x30(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x3688
movq %r13, %rdi
movq %r14, %rsi
callq 0x3cc8
cmpq $0x0, 0x8(%rsp)
jne 0x3635
movq (%rsp), %rax
addq %rbp, %rax
movq %rax, (%rsp)
movq 0x5f46(%rip), %rcx      # 0x91e0
subq 0x5f37(%rip), %rcx      # 0x91d8
sarq $0x2, %rcx
cmpq %rcx, %rax
jb 0x3258
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x32f4
movq %rbx, %rdi
callq 0x2290
addq $0x8, %rbx
cmpq %r14, %rbx
jne 0x32b9
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpq %rax, %rcx
je 0x32f4
movq %rax, %rdx
cmpq $0x0, (%rdx)
jne 0x3635
addq $0x8, %rdx
cmpq %rcx, %rdx
jne 0x32dc
movq %rax, 0x18(%rsp)
movq 0x5cd5(%rip), %rbx      # 0x8fd0
leaq 0x2fd2(%rip), %rsi      # 0x62d4
movl $0x2d, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5ca3(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x5e6f(%rip), %rdi      # 0x91b0
callq 0x5290
movq 0x5c83(%rip), %rbx      # 0x8fd0
leaq 0x2fae(%rip), %rsi      # 0x6302
movl $0x32, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5c51(%rip), %rbx      # 0x8fd0
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x5e5a(%rip), %r12      # 0x91f0
cmpq 0x5e5b(%rip), %r12      # 0x91f8
je 0x33d6
movq 0x5c2a(%rip), %r14      # 0x8fd0
movq %rsp, %r15
movl (%r12), %esi
movq %r14, %rdi
callq 0x22a0
movb $0x20, (%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2200
addq $0x4, %r12
cmpq 0x5e24(%rip), %r12      # 0x91f8
jne 0x33a9
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5bdc(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x5df0(%rip), %rcx      # 0x91f8
movq 0x5de1(%rip), %rdx      # 0x91f0
movq 0x5d72(%rip), %rax      # 0x9188
movq $0x0, (%rsp)
subq %rdx, %rcx
je 0x34e7
sarq $0x2, %rcx
js 0x3434
cvtsi2ss %rcx, %xmm0
jmp 0x3449
movq %rcx, %rdx
shrq %rdx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
testq %rax, %rax
js 0x3455
cvtsi2ss %rax, %xmm1
jmp 0x346a
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
callq 0x2100
cvttss2si %xmm0, %eax
movslq %eax, %rbp
xorl %eax, %eax
leaq -0xa93(%rip), %rbx      # 0x29f0
leaq 0x8(%rsp), %r14
movq %rsp, %r15
leaq 0x30(%rsp), %r12
leaq 0x10(%rsp), %r13
addq %rbp, %rax
movq %rax, 0x30(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x3688
movq %r13, %rdi
movq %r14, %rsi
callq 0x3cc8
cmpq $0x0, 0x8(%rsp)
jne 0x3635
movq (%rsp), %rax
addq %rbp, %rax
movq %rax, (%rsp)
movq 0x5d21(%rip), %rcx      # 0x91f8
subq 0x5d12(%rip), %rcx      # 0x91f0
sarq $0x2, %rcx
cmpq %rcx, %rax
jb 0x3495
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x3531
movq %rbx, %rdi
callq 0x2290
addq $0x8, %rbx
cmpq %r14, %rbx
jne 0x34f6
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpq %rax, %rcx
je 0x3531
movq %rax, %rdx
cmpq $0x0, (%rdx)
jne 0x3635
addq $0x8, %rdx
cmpq %rcx, %rdx
jne 0x3519
movq %rax, 0x18(%rsp)
movq 0x5a98(%rip), %rbx      # 0x8fd0
leaq 0x2df6(%rip), %rsi      # 0x6335
movl $0x4b, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5a66(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2120
cmpq $0x0, 0x5c09(%rip)      # 0x9188
je 0x35d8
movl $0x4, %r12d
xorl %r13d, %r13d
leaq -0xa42(%rip), %rbx      # 0x2b4f
movq %rsp, %r14
leaq 0x10(%rsp), %r15
movq 0x5c68(%rip), %rcx      # 0x9208
leaq (%rcx,%r12), %rdx
addq $-0x4, %rdx
addq %r12, %rcx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x370e
movq %r15, %rdi
movq %r14, %rsi
callq 0x3cc8
cmpq $0x0, (%rsp)
jne 0x3635
incq %r13
addq $0x8, %r12
cmpq 0x5bb2(%rip), %r13      # 0x9188
jb 0x3599
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x35f5
movq %rbx, %rdi
callq 0x2290
addq $0x8, %rbx
jmp 0x35e2
leaq 0x10(%rsp), %rdi
callq 0x3792
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3642
jmp 0x3642
cmpq $0x0, (%rsp)
jne 0x3635
jmp 0x3642
jmp 0x3642
jmp 0x3642
jmp 0x362d
jmp 0x3642
jmp 0x3642
jmp 0x362d
jmp 0x3642
jmp 0x3642
cmpq $0x0, 0x8(%rsp)
je 0x3642
callq 0x2070
jmp 0x3642
jmp 0x3642
jmp 0x3642
jmp 0x3642
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3792
movq %rbx, %rdi
callq 0x22b0
nop