// File: /workspace/github_cpp_makefile_star2_O3/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 0x1a9d
callq 0x1833
jmp 0x1c52
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 0x1788
movq %rax, %r15
cmpl $0x63, %r14d
jg 0x1ae9
movq %r15, %rdi
callq 0x15de
movl $0x1, 0x1c(%r15)
leaq 0x28(%rsp), %r12
movl $0x1, %edi
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
callq 0x1040
cltd
idivl %ebp
movq %r15, %rdi
movl %edx, %esi
callq 0x12f2
decl %ebx
jne 0x1b1b
leaq 0x28(%rsp), %r12
movl $0x1, %edi
movq %r12, %rsi
callq 0x1070
movq (%r12), %r13
movq 0x8(%r12), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0x1c(%r15)
leal 0x270f(%r14), %ebx
leal -0x1(%r14), %r12d
callq 0x1040
cltd
idivl %ebp
movq %r15, %rdi
movl %edx, %esi
callq 0x14ce
incl %r12d
cmpl %ebx, %r12d
jl 0x1b64
imulq $0x3b9aca00, %r13, %rbx # imm = 0x3B9ACA00
addq 0x10(%rsp), %rbx
leaq 0x28(%rsp), %r12
movl $0x1, %edi
movq %r12, %rsi
callq 0x1070
imulq $0x3b9aca00, (%r12), %rcx # imm = 0x3B9ACA00
movq 0x8(%r12), %rax
subq %rbx, %rax
addq %rcx, %rax
movabsq $0x346dc5d63886594b, %rsi # imm = 0x346DC5D63886594B
imulq %rsi
movq %rdx, %rcx
movq %rdx, %r12
shrq $0x3f, %r12
sarq $0xb, %rcx
imulq $-0x3b9aca00, 0x18(%rsp), %rax # imm = 0xC4653600
subq 0x8(%rsp), %rax
addq %rbx, %rax
imulq %rsi
movq %rdx, %r13
addq %rcx, %r12
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xb, %r13
addq %rax, %r13
cvtsi2sd %r14d, %xmm0
callq 0x1060
movsd %xmm0, 0x8(%rsp)
movq 0x20(%rsp), %rbx
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
callq 0x1060
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x10f0
cvttsd2si %xmm0, %r9d
movl 0x18(%r15), %r10d
leaq 0x4c5(%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
addq $0x10, %rsp
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq