// File: narula[P]skiplists/skiplist-extra.cc
// Function: SkipList::pretty_print()
void SkipList::pretty_print() {
  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:");
	  for (int k = 0; k < FANOUT; k++) {
		if (ptr->nexts[i][k].prefix == INT_MAX) {
		  printf("ND");
		} else {		
		  printf("%02d", ptr->nexts[i][k].prefix);
		}
		if (k != FANOUT-1) {
		  printf("|");
		}
	  }
	  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][0].nxt;
  }
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x8(%rsp)
movq (%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x315a
movq 0x8(%rsp), %rcx
movq 0x38(%rsp), %rax
cmpq (%rcx), %rax
je 0x2efe
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x2ec7
leaq 0x2171(%rip), %rdi      # 0x5024
movb $0x0, %al
callq 0x1040
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x2e9e
movq 0x38(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x30(%rsp)
movq 0x8(%rsp), %rcx
movl 0x30(%rsp), %eax
cmpl 0x10(%rcx), %eax
jge 0x2efc
leaq 0x214f(%rip), %rdi      # 0x5037
movb $0x0, %al
callq 0x1040
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x2ed3
jmp 0x2efe
leaq 0x2445(%rip), %rdi      # 0x534a
movb $0x0, %al
callq 0x1040
movq 0x8(%rsp), %rcx
movq 0x38(%rsp), %rax
cmpq 0x8(%rcx), %rax
jne 0x2f60
movl $0x0, 0x2c(%rsp)
movq 0x8(%rsp), %rcx
movl 0x2c(%rsp), %eax
cmpl 0x10(%rcx), %eax
jge 0x2f4d
leaq 0x2111(%rip), %rdi      # 0x504a
movb $0x0, %al
callq 0x1040
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x2f24
leaq 0x23f6(%rip), %rdi      # 0x534a
movb $0x0, %al
callq 0x1040
jmp 0x315a
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x2f98
movq 0x38(%rsp), %rax
movl (%rax), %esi
leaq 0x20d9(%rip), %rdi      # 0x505d
movb $0x0, %al
callq 0x1040
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x2f68
movq 0x38(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x24(%rsp)
movq 0x8(%rsp), %rcx
movl 0x24(%rsp), %eax
cmpl 0x10(%rcx), %eax
jge 0x2fcd
leaq 0x207e(%rip), %rdi      # 0x5037
movb $0x0, %al
callq 0x1040
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x2fa4
leaq 0x2376(%rip), %rdi      # 0x534a
movb $0x0, %al
callq 0x1040
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x30c5
leaq 0x2076(%rip), %rdi      # 0x5072
movb $0x0, %al
callq 0x1040
movl $0x0, 0x1c(%rsp)
cmpl $0x4, 0x1c(%rsp)
jge 0x30a7
movq 0x38(%rsp), %rax
addq $0x8, %rax
movslq 0x20(%rsp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x1c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x7fffffff, (%rax)     # imm = 0x7FFFFFFF
jne 0x304f
leaq 0x2030(%rip), %rdi      # 0x5076
movb $0x0, %al
callq 0x1040
jmp 0x3080
movq 0x38(%rsp), %rax
addq $0x8, %rax
movslq 0x20(%rsp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x1c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %esi
leaq 0x2000(%rip), %rdi      # 0x5079
movb $0x0, %al
callq 0x1040
cmpl $0x3, 0x1c(%rsp)
je 0x3095
leaq 0x1ff0(%rip), %rdi      # 0x507e
movb $0x0, %al
callq 0x1040
jmp 0x3097
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x300b
leaq 0x1fd2(%rip), %rdi      # 0x5080
movb $0x0, %al
callq 0x1040
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x2fe3
movq 0x38(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x8(%rsp), %rcx
movl 0x18(%rsp), %eax
cmpl 0x10(%rcx), %eax
jge 0x30fa
leaq 0x1f51(%rip), %rdi      # 0x5037
movb $0x0, %al
callq 0x1040
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x30d1
leaq 0x2249(%rip), %rdi      # 0x534a
movb $0x0, %al
callq 0x1040
movl $0x0, 0x14(%rsp)
movq 0x8(%rsp), %rcx
movl 0x14(%rsp), %eax
cmpl 0x10(%rcx), %eax
jge 0x3139
leaq 0x1f12(%rip), %rdi      # 0x5037
movb $0x0, %al
callq 0x1040
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x3110
leaq 0x220a(%rip), %rdi      # 0x534a
movb $0x0, %al
callq 0x1040
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x2e7b
addq $0x48, %rsp
retq
nop