// File: narula[P]skiplists/skiplist-fanout.cc
// Function: SkipList::pretty_print_skiplist()
void SkipList::pretty_print_skiplist() {
  node* ptr = head;
  while (ptr != 0) {
	if (ptr != head) {
	  for (int i = 0; i < ptr->topLevel; i++) {
		printf("   V   ");
	  }
	  for (int i = ptr->topLevel; i < max_level; i++) {
		printf("   |   ");
	  }
	}
	printf("\n");
	if (ptr == tail) {
	  for (int i = 0; i < max_level; i++) {
		printf("[K:ND] ");
	  }
	  printf("\n");
	  return;
	}
	for (int i = 0; i < ptr->topLevel; i++) {
	  printf("[K:%02d] ", ptr->key);
	}
	for (int i = ptr->topLevel; i < max_level; i++) {
	  printf("   |   ");
	}
	printf("\n");
	
	for (int i = 0; i < ptr->topLevel; i++) {
	  printf("[P:");
	  if (ptr->nexts[i][FANOUT-1].prefix == INT_MAX) {
		printf("ND");
	  } else {		
		printf("%02d", ptr->nexts[i][FANOUT-1].prefix);
	  }
	  printf("] ");
	}
	for (int i = ptr->topLevel; i < max_level; i++) {
	  printf("   |   ");
	}
	printf("\n");
	for (int i = 0; i < max_level; i++) {
	  printf("   |   ");
	}
	printf ("\n");
	ptr = ptr->nexts[0][FANOUT-1].nxt;
  }
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
movq (%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0x2912
movq (%rsp), %rcx
movq 0x28(%rsp), %rax
cmpq (%rcx), %rax
je 0x270b
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
movq 0x28(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x26d5
leaq 0xa1a(%rip), %rdi       # 0x30db
movb $0x0, %al
callq 0x1040
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x26ac
movq 0x28(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x20(%rsp)
movq (%rsp), %rcx
movl 0x20(%rsp), %eax
cmpl 0x14(%rcx), %eax
jge 0x2709
leaq 0x9ee(%rip), %rdi       # 0x30e3
movb $0x0, %al
callq 0x1040
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x26e1
jmp 0x270b
leaq 0x9ae(%rip), %rdi       # 0x30c0
movb $0x0, %al
callq 0x1040
movq (%rsp), %rcx
movq 0x28(%rsp), %rax
cmpq 0x8(%rcx), %rax
jne 0x276b
movl $0x0, 0x1c(%rsp)
movq (%rsp), %rcx
movl 0x1c(%rsp), %eax
cmpl 0x14(%rcx), %eax
jge 0x2758
leaq 0x9a7(%rip), %rdi       # 0x30eb
movb $0x0, %al
callq 0x1040
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x2730
leaq 0x961(%rip), %rdi       # 0x30c0
movb $0x0, %al
callq 0x1040
jmp 0x2912
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
movq 0x28(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x27a3
movq 0x28(%rsp), %rax
movl (%rax), %esi
leaq 0x964(%rip), %rdi       # 0x30f3
movb $0x0, %al
callq 0x1040
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x2773
movq 0x28(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x14(%rsp)
movq (%rsp), %rcx
movl 0x14(%rsp), %eax
cmpl 0x14(%rcx), %eax
jge 0x27d7
leaq 0x920(%rip), %rdi       # 0x30e3
movb $0x0, %al
callq 0x1040
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x27af
leaq 0x8e2(%rip), %rdi       # 0x30c0
movb $0x0, %al
callq 0x1040
movl $0x0, 0x10(%rsp)
movl 0x10(%rsp), %eax
movq 0x28(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x287f
leaq 0x8f7(%rip), %rdi       # 0x30fd
movb $0x0, %al
callq 0x1040
movq 0x28(%rsp), %rax
addq $0x8, %rax
movslq 0x10(%rsp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
cmpl $0x7fffffff, 0x30(%rax) # imm = 0x7FFFFFFF
jne 0x283b
leaq 0x8cf(%rip), %rdi       # 0x3101
movb $0x0, %al
callq 0x1040
jmp 0x2861
movq 0x28(%rsp), %rax
addq $0x8, %rax
movslq 0x10(%rsp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x30(%rax), %esi
leaq 0x8aa(%rip), %rdi       # 0x3104
movb $0x0, %al
callq 0x1040
leaq 0x888(%rip), %rdi       # 0x30f0
movb $0x0, %al
callq 0x1040
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x27ed
movq 0x28(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0xc(%rsp)
movq (%rsp), %rcx
movl 0xc(%rsp), %eax
cmpl 0x14(%rcx), %eax
jge 0x28b3
leaq 0x844(%rip), %rdi       # 0x30e3
movb $0x0, %al
callq 0x1040
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x288b
leaq 0x806(%rip), %rdi       # 0x30c0
movb $0x0, %al
callq 0x1040
movl $0x0, 0x8(%rsp)
movq (%rsp), %rcx
movl 0x8(%rsp), %eax
cmpl 0x14(%rcx), %eax
jge 0x28f1
leaq 0x806(%rip), %rdi       # 0x30e3
movb $0x0, %al
callq 0x1040
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x28c9
leaq 0x7c8(%rip), %rdi       # 0x30c0
movb $0x0, %al
callq 0x1040
movq 0x28(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0x28(%rsp)
jmp 0x268a
addq $0x38, %rsp
retq
nopw (%rax,%rax)