// File: /workspace/github_cpp_makefile_star2_O3/cpottamus[P]btree_lab/btree_display.cc
// Function: main
int main(int argc, char **argv)
{
  char *filestem;
  bool dot;
  SIZE_T cachesize;
  SIZE_T superblocknum;

  if (argc!=4) { 
    usage();
    return -1;
  }

  filestem=argv[1];
  cachesize=atoi(argv[2]);
  dot=argv[3][0]=='d' || argv[3][0]=='D';

  DiskSystem disk(filestem);
  BufferCache cache(&disk,cachesize);
  BTreeIndex btree(0,0,&cache);
  
  ERROR_T rc;


  if ((rc=cache.Attach())!=ERROR_NOERROR) { 
    cerr << "Can't attach buffer cache due to error"<<rc<<endl;
    return -1;
  }

  if ((rc=btree.Attach(0))!=ERROR_NOERROR) { 
    cerr << "Can't attach to index  due to error "<<rc<<endl;
    return -1;
  } else {
    cerr << "Index attached!"<<endl;
    VALUE_T val;
    if ((rc=btree.Display(cout, dot ? BTREE_DEPTH_DOT : BTREE_DEPTH))!=ERROR_NOERROR) { 
      cerr <<"Display failed: error "<<rc<<endl;
    } else {
      cerr <<"Display succeeded\n";
    }
    if ((rc=btree.Detach(superblocknum))!=ERROR_NOERROR) { 
      cerr <<"Can't detach from index due to error "<<rc<<endl;
      return -1;
    }
    if ((rc=cache.Detach())!=ERROR_NOERROR) { 
      cerr <<"Can't detach from cache due to error "<<rc<<endl;
      return -1;
    }
    cerr << "Performance statistics:\n";
    
    cerr << "numallocs       = "<<cache.GetNumAllocs()<<endl;
    cerr << "numdeallocs     = "<<cache.GetNumDeallocs()<<endl;
    cerr << "numreads        = "<<cache.GetNumReads()<<endl;
    cerr << "numdiskreads    = "<<cache.GetNumDiskReads()<<endl;
    cerr << "numwrites       = "<<cache.GetNumWrites()<<endl;
    cerr << "numdiskwrites   = "<<cache.GetNumDiskWrites()<<endl;
    cerr << endl;
    
    cerr << "total time      = "<<cache.GetCurrentTime()<<endl;

    return 0;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
cmpl $0x4, %edi
jne 0x26f7
movq %rsi, %rbx
movq 0x8(%rsi), %r14
movq 0x10(%rsi), %rdi
callq 0x22f0
movl %eax, %ebp
movq 0x18(%rbx), %rax
movb (%rax), %al
andb $-0x21, %al
xorl %ebx, %ebx
cmpb $0x44, %al
sete %r15b
leaq 0x8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %r14, %rsi
callq 0x2b44
subq $0x8, %rsp
xorl %eax, %eax
leaq 0xe0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rax
pushq %rax
pushq %rax
callq 0x2fe0
addq $0x20, %rsp
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x267b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
leaq 0x8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
movl %ebp, %edx
callq 0x4a0c
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rcx
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %r8d
callq 0x54a8
leaq 0x8(%rsp), %rdi
callq 0x4aea
movl %eax, %ebp
testl %eax, %eax
je 0x2719
movq 0xb931(%rip), %rdi      # 0xdff0
leaq 0x6972(%rip), %rsi      # 0x9038
movl $0x26, %edx
callq 0x2230
movq 0xb919(%rip), %rdi      # 0xdff0
movl %ebp, %esi
callq 0x2360
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
jmp 0x276e
movq 0xb8f2(%rip), %rdi      # 0xdff0
leaq 0x68ff(%rip), %rsi      # 0x9004
movl $0x33, %edx
callq 0x2230
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x27a7
leaq 0x68(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5736
movl %eax, %ebp
testl %eax, %eax
je 0x27b7
movq 0xb8b8(%rip), %rdi      # 0xdff0
leaq 0x6920(%rip), %rsi      # 0x905f
movl $0x24, %edx
callq 0x2230
movq 0xb8a0(%rip), %rdi      # 0xdff0
movl %ebp, %esi
callq 0x2360
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2130
leaq 0x68(%rsp), %rdi
callq 0x5584
leaq 0x8(%rsp), %rdi
callq 0x4a3c
leaq 0xd8(%rsp), %rdi
callq 0x3580
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xb832(%rip), %r14      # 0xdff0
leaq 0x68bf(%rip), %rsi      # 0x9084
movl $0xf, %edx
movq %r14, %rdi
callq 0x2230
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq 0xb800(%rip), %rdi      # 0xdff0
callq 0x2040
movq %rax, %rdi
callq 0x2130
leaq 0xb0(%rsp), %rdi
callq 0x2c18
movb %r15b, %bl
movq 0xb7bc(%rip), %rsi      # 0xdfd0
leaq 0x68(%rsp), %rdi
movl %ebx, %edx
callq 0x741a
movl %eax, %ebx
testl %eax, %eax
je 0x2878
movq 0xb7c3(%rip), %rdi      # 0xdff0
leaq 0x6860(%rip), %rsi      # 0x9094
movl $0x16, %edx
callq 0x2230
movq 0xb7ab(%rip), %rdi      # 0xdff0
movl %ebx, %esi
callq 0x2360
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
jmp 0x2890
movq 0xb771(%rip), %rdi      # 0xdff0
leaq 0x6825(%rip), %rsi      # 0x90ab
movl $0x12, %edx
callq 0x2230
leaq 0x68(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x5958
movl %eax, %ebx
testl %eax, %eax
je 0x28ff
movq 0xb744(%rip), %rdi      # 0xdff0
leaq 0x680b(%rip), %rsi      # 0x90be
movl $0x25, %edx
callq 0x2230
movq 0xb72c(%rip), %rdi      # 0xdff0
movl %ebx, %esi
callq 0x2360
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2130
jmp 0x2ac3
leaq 0x8(%rsp), %rdi
callq 0x4a74
movl %eax, %ebx
testl %eax, %eax
je 0x2947
movq 0xb6da(%rip), %rdi      # 0xdff0
leaq 0x67c7(%rip), %rsi      # 0x90e4
movl $0x25, %edx
callq 0x2230
movq 0xb6c2(%rip), %rdi      # 0xdff0
movl %ebx, %esi
callq 0x2360
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x20c0
jmp 0x2ac3
movq 0xb6a2(%rip), %rdi      # 0xdff0
leaq 0x67b5(%rip), %rsi      # 0x910a
movl $0x18, %edx
callq 0x2230
movq 0xb68a(%rip), %rdi      # 0xdff0
leaq 0x67b6(%rip), %rsi      # 0x9123
movl $0x12, %edx
callq 0x2230
movl 0x50(%rsp), %esi
movq 0xb66e(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb65a(%rip), %rdi      # 0xdff0
leaq 0x6799(%rip), %rsi      # 0x9136
movl $0x12, %edx
callq 0x2230
movl 0x54(%rsp), %esi
movq 0xb63e(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb62a(%rip), %rdi      # 0xdff0
leaq 0x677c(%rip), %rsi      # 0x9149
movl $0x12, %edx
callq 0x2230
movl 0x58(%rsp), %esi
movq 0xb60e(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb5fa(%rip), %rdi      # 0xdff0
leaq 0x675f(%rip), %rsi      # 0x915c
movl $0x12, %edx
callq 0x2230
movl 0x60(%rsp), %esi
movq 0xb5de(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb5ca(%rip), %rdi      # 0xdff0
leaq 0x6742(%rip), %rsi      # 0x916f
movl $0x12, %edx
callq 0x2230
movl 0x5c(%rsp), %esi
movq 0xb5ae(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb59a(%rip), %rdi      # 0xdff0
leaq 0x6725(%rip), %rsi      # 0x9182
movl $0x12, %edx
callq 0x2230
movl 0x64(%rsp), %esi
movq 0xb57e(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb56a(%rip), %rdi      # 0xdff0
callq 0x20c0
movq 0xb55e(%rip), %rdi      # 0xdff0
leaq 0x66fc(%rip), %rsi      # 0x9195
movl $0x12, %edx
callq 0x2230
leaq 0x8(%rsp), %rdi
callq 0x4b0c
movq 0xb53c(%rip), %rdi      # 0xdff0
callq 0x2310
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x20c0
leaq 0xb0(%rsp), %rdi
callq 0x2de6
jmp 0x2786
jmp 0x2b18
movq %rax, %rbx
jmp 0x2b25
movq %rax, %rbx
jmp 0x2b2f
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b3c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2b3c
movq %rax, %rbx
jmp 0x2b3c
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x2de6
jmp 0x2b1b
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x5584
leaq 0x8(%rsp), %rdi
callq 0x4a3c
leaq 0xd8(%rsp), %rdi
callq 0x3580
movq %rbx, %rdi
callq 0x2370