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

    static struct option long_options[] = {
        {"name", no_argument, NULL, 'n'},
        {"operation", required_argument, NULL, 'o'},
        {"help", no_argument, NULL, 'h'},
        {0, 0, 0, 0}
    };

    //Variables for options
    bool name = false;
    int max_number = -1;
    string operation = "";
    bool help = false;

    while (true) {
        int option_index = 0;
        int flag_char = getopt_long(argc, argv, "i:t:", long_options, &option_index);
        if (flag_char == -1) {
          break;
        }

        switch (flag_char) {
            case 'n':
                name = true;
                break;
            case 'o':
                operation = std::string(optarg);
                break;
            case 'h':
                help = true;
                break;
            case 't':
                num_threads = stoi(optarg);
                break;
            case 'i':
                max_number = stoi(optarg);
                break;
            case '?':
                break;
            default:
                exit(EXIT_FAILURE);
        }
    }

    if(name){
        cout << "\nShreyas Gopalakrishna\n";
    }

    if(help){
        show_usage();
    }

	if(argc > 2){
	    if(operation == "" || max_number <= 0 || num_threads < 1 ){
	        show_usage();
	    }else{

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

	        if(operation == "separate"){
                concurrent_skiplist_seperate();
	        }
	        else if (operation == "combined"){
                concurrent_skiplist_combined();
	        }else{
	            cout << "Invalid operation type \n";
	            show_usage();
	        }
	    }
    }else{
        show_usage();
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r15
movl %edi, 0x14(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x3578(%rip), %rdx      # 0x7049
leaq 0x48(%rsp), %rdi
movq %rdx, %rsi
callq 0x4558
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x40(%rsp)
movl $0x0, 0x10(%rsp)
leaq 0x3ae6(%rip), %r12      # 0x75dd
leaq 0x76f2(%rip), %r13      # 0xb1f0
leaq 0x8(%rsp), %rbp
leaq 0x18(%rsp), %r14
movl $0x0, 0xc(%rsp)
movq %r14, %rbx
movl $0x0, 0x8(%rsp)
movl 0x14(%rsp), %edi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %rbp, %r8
callq 0x2320
cmpl $0x67, %eax
jle 0x3b5b
leal -0x68(%rax), %ecx
cmpl $0x7, %ecx
ja 0x3b75
leaq 0x34c4(%rip), %rdx      # 0x7008
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
movq %rbx, %r14
jmpq *%rax
movb $0x1, %al
movl %eax, 0xc(%rsp)
jmp 0x3d08
cmpl $-0x1, %eax
je 0x3d0c
cmpl $0x3f, %eax
jne 0x3e24
movq %rbx, %r14
jmp 0x3d08
cmpl $0x74, %eax
jne 0x3e24
movq %rbx, %rdi
movq 0x7438(%rip), %rax      # 0xafc0
movq (%rax), %rsi
leaq 0x7(%rsp), %rdx
callq 0x3f08
movq 0x18(%rsp), %rbp
callq 0x2040
movq %rax, %r13
movl (%rax), %r12d
movl $0x0, (%rax)
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
cmpq %rbp, 0x38(%rsp)
je 0x3e52
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
jb 0x3e46
movl (%r13), %ecx
cmpl $0x22, %ecx
je 0x3e46
testl %ecx, %ecx
leaq 0x8(%rsp), %rbp
jne 0x3bfc
movl %r12d, (%r13)
cltq
movq %rax, 0x75db(%rip)      # 0xb1e0
jmp 0x3cd4
movq 0x73af(%rip), %rax      # 0xafc0
movq (%rax), %rsi
movq %r14, %rdi
leaq 0x38(%rsp), %rdx
callq 0x3f08
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x2280
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x3c4a
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
movb $0x1, %al
jmp 0x3d0e
movq 0x7368(%rip), %rax      # 0xafc0
movq (%rax), %rsi
movq %r14, %rdi
leaq 0x7(%rsp), %rdx
callq 0x3f08
movq 0x18(%rsp), %rbp
callq 0x2040
movq %rax, %r13
movl (%rax), %r12d
movl $0x0, (%rax)
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
cmpq %rbp, 0x38(%rsp)
je 0x3e3a
leaq -0x80000000(%rax), %rdx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmpq %rcx, %rdx
jb 0x3e2e
movl (%r13), %ecx
cmpl $0x22, %ecx
je 0x3e2e
testl %ecx, %ecx
leaq 0x8(%rsp), %rbp
jne 0x3ccf
movl %r12d, (%r13)
movq %rax, 0x40(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x3cf0
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
movb $0x1, %al
leaq 0x38e4(%rip), %r12      # 0x75dd
leaq 0x74f0(%rip), %r13      # 0xb1f0
jmp 0x3d0e
movb $0x1, %al
movl %eax, 0x10(%rsp)
movb $0x1, %al
jmp 0x3d11
xorl %eax, %eax
movq %rbx, %r14
testb %al, %al
jne 0x3b10
testb $0x1, 0x10(%rsp)
movq 0x40(%rsp), %rbx
je 0x3d3d
movq 0x72a4(%rip), %rdi      # 0xafd0
leaq 0x38af(%rip), %rsi      # 0x75e2
movl $0x17, %edx
callq 0x2250
cmpl $0x3, 0x14(%rsp)
jl 0x3e76
testb $0x1, 0xc(%rsp)
jne 0x3e76
leaq 0x32ef(%rip), %rsi      # 0x7049
leaq 0x48(%rsp), %rdi
callq 0x2090
testl %eax, %eax
je 0x3e76
testl %ebx, %ebx
jle 0x3e76
cmpq $0x0, 0x7464(%rip)      # 0xb1e0
je 0x3e76
movl %ebx, %edi
callq 0x26c3
movq 0x7518(%rip), %rsi      # 0xb2a8
subq 0x7509(%rip), %rsi      # 0xb2a0
shrq $0x2, %rsi
leaq 0x18(%rsp), %rdi
movss 0x325c(%rip), %xmm0     # 0x7004
callq 0x4d1c
leaq 0x18(%rsp), %rdi
movups (%rdi), %xmm0
movups %xmm0, 0x74d4(%rip)     # 0xb290
callq 0x5d0a
leaq 0x3832(%rip), %rsi      # 0x75fa
leaq 0x48(%rsp), %rdi
callq 0x2090
testl %eax, %eax
je 0x3df2
leaq 0x3826(%rip), %rsi      # 0x7603
leaq 0x48(%rsp), %rdi
callq 0x2090
testl %eax, %eax
jne 0x3e5e
callq 0x37e9
jmp 0x3df7
callq 0x2e77
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x3e13
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2230
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x2270
leaq 0x37f0(%rip), %rdi      # 0x7625
callq 0x22a0
leaq 0x37e4(%rip), %rdi      # 0x7625
callq 0x2150
leaq 0x37d8(%rip), %rdi      # 0x7625
callq 0x22a0
leaq 0x37cc(%rip), %rdi      # 0x7625
callq 0x2150
movq 0x716b(%rip), %rdi      # 0xafd0
leaq 0x37a0(%rip), %rsi      # 0x760c
movl $0x18, %edx
callq 0x2250
callq 0x25fc
jmp 0x3e83
jmp 0x3e83
jmp 0x3e83
jmp 0x3e83
movq %rax, %rbx
jmp 0x3eb4
jmp 0x3e8a
movq %rax, %rbx
cmpl $0x0, (%r13)
jne 0x3e98
movl %r12d, (%r13)
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x3eb4
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x3ed0
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x2350