// File: cpottamus[P]btree_lab/btree.cc
// Function: BTreeIndex::DisplayInternal(unsigned int const&, std::ostream&, BTreeDisplayType) const
ERROR_T BTreeIndex::DisplayInternal(const SIZE_T &node,
  ostream &o,
  BTreeDisplayType display_type) const
{
  KEY_T testkey;
  SIZE_T ptr;
  BTreeNode b;
  ERROR_T rc;
  SIZE_T offset;

  rc= b.Unserialize(buffercache,node);

  if (rc!=ERROR_NOERROR) { 
    return rc;
  }

  rc = PrintNode(o,node,b,display_type);
  
  if (rc) { return rc; }

  if (display_type==BTREE_DEPTH_DOT) { 
    o << ";";
  }

  if (display_type!=BTREE_SORTED_KEYVAL) {
    o << endl;
  }

  switch (b.info.nodetype) { 
    case BTREE_ROOT_NODE:
    case BTREE_INTERIOR_NODE:
    if (b.info.numkeys>0) { 
      for (offset=0;offset<=b.info.numkeys;offset++) { 
       rc=b.GetPtr(offset,ptr);
       if (rc) { return rc; }
       if (display_type==BTREE_DEPTH_DOT) { 
         o << node << " -> "<<ptr<<";\n";
       }
       rc=DisplayInternal(ptr,o,display_type);
       if (rc) { return rc; }
     }
   }
   return ERROR_NOERROR;
   break;
   case BTREE_LEAF_NODE:
   return ERROR_NOERROR;
   break;
   default:
   if (display_type==BTREE_DEPTH_DOT) { 
   } else {
    o << "Unsupported Node Type " << b.info.nodetype ;
  }
  return ERROR_INSANE;
}

return ERROR_NOERROR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x43e0
leaq -0x80(%rbp), %rdi
callq 0xee80
jmp 0xcb19
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
leaq -0x80(%rbp), %rdi
callq 0xf1a0
movl %eax, -0xa4(%rbp)
jmp 0xcb3b
movl -0xa4(%rbp), %eax
movl %eax, -0x90(%rbp)
cmpl $0x0, -0x90(%rbp)
je 0xcb9f
movl -0x90(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0xcde8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xce06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xeea0
jmp 0xce06
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
movl -0x24(%rbp), %ecx
leaq -0x80(%rbp), %rdx
callq 0xce20
movl %eax, -0xa8(%rbp)
jmp 0xcbbd
movl -0xa8(%rbp), %eax
movl %eax, -0x90(%rbp)
cmpl $0x0, -0x90(%rbp)
je 0xcbea
movl -0x90(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0xcde8
cmpl $0x1, -0x24(%rbp)
jne 0xcc04
movq -0x20(%rbp), %rdi
leaq 0x3bad(%rip), %rsi      # 0x107a8
callq 0x31f0
jmp 0xcc02
jmp 0xcc04
cmpl $0x2, -0x24(%rbp)
je 0xcc1e
movq -0x20(%rbp), %rdi
movq 0xa3ab(%rip), %rsi      # 0x16fc0
callq 0x3240
jmp 0xcc1c
jmp 0xcc1e
movl -0x80(%rbp), %eax
movl %eax, -0xac(%rbp)
addl $-0x2, %eax
subl $0x2, %eax
jb 0xcc45
jmp 0xcc31
movl -0xac(%rbp), %eax
subl $0x4, %eax
je 0xcd90
jmp 0xcda3
cmpl $0x0, -0x68(%rbp)
jbe 0xcd7d
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x68(%rbp), %eax
ja 0xcd7b
movl -0x94(%rbp), %esi
leaq -0x80(%rbp), %rdi
leaq -0x54(%rbp), %rdx
callq 0xf650
movl %eax, -0xb0(%rbp)
jmp 0xcc83
movl -0xb0(%rbp), %eax
movl %eax, -0x90(%rbp)
cmpl $0x0, -0x90(%rbp)
je 0xccb0
movl -0x90(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0xcde8
cmpl $0x1, -0x24(%rbp)
jne 0xcd19
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x3320
movq %rax, -0xb8(%rbp)
jmp 0xccce
movq -0xb8(%rbp), %rdi
leaq 0x3ace(%rip), %rsi      # 0x107aa
callq 0x31f0
movq %rax, -0xc0(%rbp)
jmp 0xccea
movq -0xc0(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x3320
movq %rax, -0xc8(%rbp)
jmp 0xcd02
movq -0xc8(%rbp), %rdi
leaq 0x3a9f(%rip), %rsi      # 0x107af
callq 0x31f0
jmp 0xcd17
jmp 0xcd19
movq -0xa0(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
leaq -0x54(%rbp), %rsi
callq 0xcae0
movl %eax, -0xcc(%rbp)
jmp 0xcd38
movl -0xcc(%rbp), %eax
movl %eax, -0x90(%rbp)
cmpl $0x0, -0x90(%rbp)
je 0xcd65
movl -0x90(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0xcde8
jmp 0xcd67
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0xcc59
jmp 0xcd7d
movl $0x0, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0xcde8
movl $0x0, -0x4(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0xcde8
cmpl $0x1, -0x24(%rbp)
jne 0xcdab
jmp 0xcdd7
movq -0x20(%rbp), %rdi
leaq 0x39fc(%rip), %rsi      # 0x107b2
callq 0x31f0
movq %rax, -0xd8(%rbp)
jmp 0xcdc4
movq -0xd8(%rbp), %rdi
movl -0x80(%rbp), %esi
callq 0x33f0
jmp 0xcdd5
jmp 0xcdd7
movl $0xfffffff1, -0x4(%rbp) # imm = 0xFFFFFFF1
movl $0x1, -0x98(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xeea0
leaq -0x50(%rbp), %rdi
callq 0x46e0
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x46e0
movq -0x88(%rbp), %rdi
callq 0x3400
nopl (%rax,%rax)