// File: /workspace/github_cpp_makefile_star2_O2/narula[P]skiplists/skiplist.cc
// Function: main
int main(int argc, char** argv) {
  if (argc < 2) {
	basic_test();
	return 0;
  }
  srand(time(NULL));
  int LIST_SIZE = atoi(argv[1]);
  int PROBABILITY = atoi(argv[2]);
  int POOL = 3*LIST_SIZE;
  int ITERATIONS = 10000;
  int seconds = 10;
  SkipList* stest2 = SkipList::init_list(LIST_SIZE, POOL, PROBABILITY);
  assert(stest2);
  timespec ts;
  if (LIST_SIZE < 100) {
	stest2->pretty_print_skiplist();
  }
  stest2->enable_counts();
  clock_gettime(CLOCK_MONOTONIC, &ts);
  time_t start = ts.tv_sec*1000000000 + ts.tv_nsec;
  for (int i = 0; i < ITERATIONS; i++) {
	int key = (rand() % POOL);
	if (ITERATIONS < 50) printf("key: %d\n", key);
	stest2->lookup(key);
  }
  clock_gettime(CLOCK_MONOTONIC, &ts);
  time_t lookup_time = ts.tv_sec*1000000000 + ts.tv_nsec;
  stest2->disable_counts();
  for (int i = LIST_SIZE; i < LIST_SIZE+ITERATIONS; i++) {
	stest2->insert(rand() % POOL);
  }
  clock_gettime(CLOCK_MONOTONIC, &ts);
  time_t insert_time = ts.tv_sec*1000000000 + ts.tv_nsec;

  printf("insert: %ld; lookup: %ld; itr: %d; size: %d; levels: %d; probability: %d; ptr: %d\n", 
		 (insert_time-lookup_time)/(ITERATIONS), (lookup_time-start)/(ITERATIONS), ITERATIONS, LIST_SIZE, int(floor(log(LIST_SIZE)/log(PROBABILITY))), PROBABILITY, stest2->get_ptr_count());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpl $0x1, %edi
jg 0x19da
callq 0x179c
jmp 0x1b66
movq %rsi, %rbx
xorl %edi, %edi
callq 0x1080
movl %eax, %edi
callq 0x1090
movq 0x8(%rbx), %rdi
callq 0x10e0
movl %eax, %r14d
movq 0x10(%rbx), %rdi
callq 0x10e0
leal (%r14,%r14,2), %ebp
movl %r14d, %edi
movl %ebp, %esi
movq %rax, 0x20(%rsp)
movl %eax, %edx
callq 0x1700
movq %rax, %r15
cmpl $0x63, %r14d
jg 0x1a26
movq %r15, %rdi
callq 0x1584
movl $0x1, 0x1c(%r15)
pushq $0x1
popq %rdi
leaq 0x28(%rsp), %r12
movq %r12, %rsi
callq 0x1070
movq (%r12), %rax
movq %rax, 0x18(%rsp)
movq 0x8(%r12), %rax
movq %rax, 0x8(%rsp)
movl $0x2710, %ebx           # imm = 0x2710
subl $0x1, %ebx
jb 0x1a6f
callq 0x1040
cltd
idivl %ebp
movq %r15, %rdi
movl %edx, %esi
callq 0x12dc
jmp 0x1a56
pushq $0x1
popq %rdi
leaq 0x28(%rsp), %r12
movq %r12, %rsi
callq 0x1070
movq (%r12), %r13
movq 0x8(%r12), %rax
movq %rax, 0x10(%rsp)
andl $0x0, 0x1c(%r15)
movl %r14d, %ebx
addl $0x2710, %ebx           # imm = 0x2710
movl %r14d, %r12d
cmpl %ebx, %r12d
jge 0x1aba
callq 0x1040
cltd
idivl %ebp
movq %r15, %rdi
movl %edx, %esi
callq 0x1474
incl %r12d
jmp 0x1a9e
imulq $0x3b9aca00, %r13, %rbx # imm = 0x3B9ACA00
addq 0x10(%rsp), %rbx
pushq $0x1
popq %rdi
leaq 0x28(%rsp), %r12
movq %r12, %rsi
callq 0x1070
imulq $0x3b9aca00, (%r12), %rcx # imm = 0x3B9ACA00
movq 0x8(%r12), %rax
subq %rbx, %rax
addq %rcx, %rax
movl $0x2710, %ecx           # imm = 0x2710
cqto
idivq %rcx
movq %rax, %r12
imulq $-0x3b9aca00, 0x18(%rsp), %rax # imm = 0xC4653600
subq 0x8(%rsp), %rax
addq %rbx, %rax
cqto
idivq %rcx
movq %rax, %r13
movl %r14d, %edi
callq 0x1b77
movsd %xmm0, 0x8(%rsp)
movq 0x20(%rsp), %rbx
movl %ebx, %edi
callq 0x1b77
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x10f0
cvttsd2si %xmm0, %r9d
movl 0x18(%r15), %r10d
leaq 0x5af(%rip), %rdi       # 0x20fb
movq %r12, %rsi
movq %r13, %rdx
movl $0x2710, %ecx           # imm = 0x2710
movl %r14d, %r8d
xorl %eax, %eax
pushq %r10
pushq %rbx
callq 0x1030
popq %rcx
popq %rdx
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq