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

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

  filestem=argv[1];
  cachesize=atoi(argv[2]);

  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;
    // Your Implementation should do the right thing here
    cout << btree;
    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 %r14
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
cmpl $0x3, %edi
jne 0x26e4
movq 0x8(%rsi), %r14
movq 0x10(%rsi), %rdi
callq 0x22f0
movl %eax, %ebx
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rdx
movq %r14, %rsi
callq 0x2a70
subq $0x8, %rsp
xorl %eax, %eax
leaq 0xc0(%rsp), %rdi
leaq 0x18(%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 0x2b40
addq $0x20, %rsp
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2665
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21e0
leaq 0x10(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
movl %ebx, %edx
callq 0x4534
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rcx
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %r8d
callq 0x5010
leaq 0x10(%rsp), %rdi
callq 0x462c
movl %eax, %ebx
testl %eax, %eax
je 0x2706
movq 0xb947(%rip), %rdi      # 0xdff0
leaq 0x697a(%rip), %rsi      # 0x902a
movl $0x26, %edx
callq 0x2230
movq 0xb92f(%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
jmp 0x2809
movq 0xb905(%rip), %rdi      # 0xdff0
leaq 0x6912(%rip), %rsi      # 0x9004
movl $0x25, %edx
callq 0x2230
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x2842
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x529e
movl %eax, %ebx
testl %eax, %eax
je 0x275c
movq 0xb8cf(%rip), %rdi      # 0xdff0
leaq 0x6929(%rip), %rsi      # 0x9051
movl $0x24, %edx
callq 0x2230
movq 0xb8b7(%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
jmp 0x2809
movq 0xb88d(%rip), %rbx      # 0xdff0
leaq 0x690c(%rip), %rsi      # 0x9076
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2230
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq 0xb85b(%rip), %rdi      # 0xdff0
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xb827(%rip), %rsi      # 0xdfd0
leaq 0x70(%rsp), %rdi
callq 0x74d6
leaq 0x70(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x54ba
movl %eax, %ebx
testl %eax, %eax
je 0x284f
movq 0xb81d(%rip), %rdi      # 0xdff0
leaq 0x68ac(%rip), %rsi      # 0x9086
movl $0x25, %edx
callq 0x2230
movq 0xb805(%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
leaq 0x70(%rsp), %rdi
callq 0x50ec
leaq 0x10(%rsp), %rdi
callq 0x4564
leaq 0xb8(%rsp), %rdi
callq 0x30e0
movl %ebx, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r14
retq
leaq 0x10(%rsp), %rdi
callq 0x459c
movl %eax, %ebx
testl %eax, %eax
je 0x2894
movq 0xb78a(%rip), %rdi      # 0xdff0
leaq 0x683f(%rip), %rsi      # 0x90ac
movl $0x25, %edx
callq 0x2230
movq 0xb772(%rip), %rdi      # 0xdff0
movl %ebx, %esi
callq 0x2360
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x20c0
jmp 0x2821
movq 0xb755(%rip), %rdi      # 0xdff0
leaq 0x6830(%rip), %rsi      # 0x90d2
movl $0x18, %edx
callq 0x2230
movq 0xb73d(%rip), %rdi      # 0xdff0
leaq 0x6831(%rip), %rsi      # 0x90eb
movl $0x12, %edx
callq 0x2230
movl 0x58(%rsp), %esi
movq 0xb721(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb70d(%rip), %rdi      # 0xdff0
leaq 0x6814(%rip), %rsi      # 0x90fe
movl $0x12, %edx
callq 0x2230
movl 0x5c(%rsp), %esi
movq 0xb6f1(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb6dd(%rip), %rdi      # 0xdff0
leaq 0x67f7(%rip), %rsi      # 0x9111
movl $0x12, %edx
callq 0x2230
movl 0x60(%rsp), %esi
movq 0xb6c1(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb6ad(%rip), %rdi      # 0xdff0
leaq 0x67da(%rip), %rsi      # 0x9124
movl $0x12, %edx
callq 0x2230
movl 0x68(%rsp), %esi
movq 0xb691(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb67d(%rip), %rdi      # 0xdff0
leaq 0x67bd(%rip), %rsi      # 0x9137
movl $0x12, %edx
callq 0x2230
movl 0x64(%rsp), %esi
movq 0xb661(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb64d(%rip), %rdi      # 0xdff0
leaq 0x67a0(%rip), %rsi      # 0x914a
movl $0x12, %edx
callq 0x2230
movl 0x6c(%rsp), %esi
movq 0xb631(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb61d(%rip), %rdi      # 0xdff0
callq 0x20c0
movq 0xb611(%rip), %rdi      # 0xdff0
leaq 0x6777(%rip), %rsi      # 0x915d
movl $0x12, %edx
callq 0x2230
leaq 0x10(%rsp), %rdi
callq 0x464e
movq 0xb5ef(%rip), %rdi      # 0xdff0
callq 0x2310
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x20c0
jmp 0x2821
movq %rax, %rbx
jmp 0x2a51
movq %rax, %rbx
jmp 0x2a5b
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a68
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2a68
movq %rax, %rbx
jmp 0x2a68
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x50ec
leaq 0x10(%rsp), %rdi
callq 0x4564
leaq 0xb8(%rsp), %rdi
callq 0x30e0
movq %rbx, %rdi
callq 0x2370