// File: /workspace/github_cpp_makefile_star2_O3/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, %ebx
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x355d(%rip), %rdx      # 0x7049
leaq 0x40(%rsp), %rdi
movq %rdx, %rsi
callq 0x4536
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x60(%rsp)
movl $0x0, 0x10(%rsp)
leaq 0x3acb(%rip), %r14      # 0x75dd
leaq 0x76d7(%rip), %r13      # 0xb1f0
leaq 0xc(%rsp), %rbp
movl $0x0, 0x14(%rsp)
movl $0x0, 0xc(%rsp)
movl %ebx, %edi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %rbp, %r8
callq 0x2320
cmpl $0x67, %eax
jle 0x3b6b
leal -0x68(%rax), %ecx
cmpl $0x7, %ecx
ja 0x3b75
leaq 0x34b3(%rip), %rdx      # 0x7008
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
leaq 0x18(%rsp), %r12
jmpq *%rax
movb $0x1, %al
movl %eax, 0x14(%rsp)
jmp 0x3b26
cmpl $0x3f, %eax
je 0x3b26
jmp 0x3d0f
cmpl $0x74, %eax
leaq 0x18(%rsp), %rdi
jne 0x3e21
movq 0x7436(%rip), %rax      # 0xafc0
movq (%rax), %rsi
leaq 0xb(%rsp), %rdx
callq 0x3f08
movq 0x18(%rsp), %rbp
callq 0x2040
movq %rax, %r13
movl (%rax), %r14d
movl $0x0, (%rax)
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
cmpq %rbp, 0x38(%rsp)
je 0x3e2b
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
jb 0x3e37
movl (%r13), %ecx
cmpl $0x22, %ecx
je 0x3e37
testl %ecx, %ecx
leaq 0xc(%rsp), %rbp
jne 0x3bfe
movl %r14d, (%r13)
movq %rax, 0x75db(%rip)      # 0xb1e0
jmp 0x3ce0
movq 0x73af(%rip), %rax      # 0xafc0
movq (%rax), %rsi
movq %r12, %rdi
leaq 0x38(%rsp), %rdx
callq 0x3f08
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x2280
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x3b26
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
jmp 0x3b26
movb $0x1, %al
movl %eax, 0x10(%rsp)
jmp 0x3b26
movq 0x735b(%rip), %rax      # 0xafc0
movq (%rax), %rsi
movq %r12, %rdi
leaq 0xb(%rsp), %rdx
callq 0x3f08
movq 0x18(%rsp), %rbp
callq 0x2040
movq %rax, %r13
movl (%rax), %r14d
movl $0x0, (%rax)
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
cmpq %rbp, 0x38(%rsp)
je 0x3e43
movq %rax, 0x60(%rsp)
addq $-0x80000000, %rax      # imm = 0x80000000
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmpq %rcx, %rax
jb 0x3e4f
movl (%r13), %eax
cmpl $0x22, %eax
je 0x3e4f
testl %eax, %eax
leaq 0xc(%rsp), %rbp
jne 0x3ce0
movl %r14d, (%r13)
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x3cfc
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
leaq 0x38da(%rip), %r14      # 0x75dd
leaq 0x74e6(%rip), %r13      # 0xb1f0
jmp 0x3b26
cmpl $-0x1, %eax
jne 0x3e21
testb $0x1, 0x10(%rsp)
leaq 0x50(%rsp), %r14
movq 0x60(%rsp), %r15
je 0x3d41
movq 0x72a0(%rip), %rdi      # 0xafd0
leaq 0x38ab(%rip), %rsi      # 0x75e2
movl $0x17, %edx
callq 0x2250
cmpl $0x3, %ebx
setl %al
orb 0x14(%rsp), %al
testb $0x1, %al
jne 0x3e73
leaq 0x32ef(%rip), %rsi      # 0x7049
leaq 0x40(%rsp), %rdi
callq 0x2090
testl %eax, %eax
je 0x3e73
testl %r15d, %r15d
jle 0x3e73
cmpq $0x0, 0x7463(%rip)      # 0xb1e0
je 0x3e73
movl %r15d, %edi
callq 0x26c3
movq 0x7516(%rip), %rsi      # 0xb2a8
subq 0x7507(%rip), %rsi      # 0xb2a0
shrq $0x2, %rsi
leaq 0x18(%rsp), %rdi
movss 0x325a(%rip), %xmm0     # 0x7004
callq 0x4d08
leaq 0x18(%rsp), %rdi
movups (%rdi), %xmm0
movups %xmm0, 0x74d2(%rip)     # 0xb290
callq 0x5cc2
leaq 0x3830(%rip), %rsi      # 0x75fa
leaq 0x40(%rsp), %rdi
callq 0x2090
testl %eax, %eax
je 0x3df4
leaq 0x3824(%rip), %rsi      # 0x7603
leaq 0x40(%rsp), %rdi
callq 0x2090
testl %eax, %eax
jne 0x3e5b
callq 0x3804
jmp 0x3df9
callq 0x2e85
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x3e10
movq 0x50(%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 0x37f3(%rip), %rdi      # 0x7625
callq 0x2150
leaq 0x37e7(%rip), %rdi      # 0x7625
callq 0x22a0
leaq 0x37db(%rip), %rdi      # 0x7625
callq 0x2150
leaq 0x37cf(%rip), %rdi      # 0x7625
callq 0x22a0
movq 0x716e(%rip), %rdi      # 0xafd0
leaq 0x37a3(%rip), %rsi      # 0x760c
movl $0x18, %edx
callq 0x2250
callq 0x25fc
jmp 0x3e7a
movq %rax, %rbx
jmp 0x3eb9
jmp 0x3e83
jmp 0x3e83
movq %rax, %rbx
jmp 0x3eb4
jmp 0x3e8a
movq %rax, %rbx
cmpl $0x0, (%r13)
jne 0x3e98
movl %r14d, (%r13)
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x3eb4
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
leaq 0x50(%rsp), %r14
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x3ed0
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x2350