// File: /workspace/github_cpp_makefile_star2_O2/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 $0x148, %rsp            # imm = 0x148
cmpl $0x3, %edi
jne 0x2689
movq 0x8(%rsi), %r14
movq 0x10(%rsi), %rdi
callq 0x2300
movl %eax, %ebx
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rdx
movq %r14, %rsi
callq 0x2914
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x29e8
leaq 0x20(%rsp), %rdi
callq 0x20b0
leaq 0x20(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
movl %ebx, %edx
callq 0x3fac
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rcx
pushq $0x1
popq %r8
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a58
leaq 0x20(%rsp), %rdi
callq 0x408e
movl %eax, %ebx
testl %eax, %eax
je 0x2696
movq 0xa978(%rip), %rdi      # 0xcff0
leaq 0x59ab(%rip), %rsi      # 0x802a
callq 0x21b0
jmp 0x2741
callq 0x25ac
pushq $-0x1
popq %rbx
jmp 0x277a
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4cce
movl %eax, %ebx
testl %eax, %eax
je 0x26c2
movq 0xa93c(%rip), %rdi      # 0xcff0
leaq 0x5996(%rip), %rsi      # 0x8051
callq 0x21b0
jmp 0x2741
movq 0xa927(%rip), %rdi      # 0xcff0
leaq 0x59a6(%rip), %rsi      # 0x8076
callq 0x21b0
movq %rax, %rdi
callq 0x20c0
movq 0xa8ec(%rip), %rsi      # 0xcfd0
leaq 0x80(%rsp), %rdi
callq 0x6ad8
leaq 0x80(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0x4ede
movl %eax, %ebx
testl %eax, %eax
je 0x271e
movq 0xa8e0(%rip), %rdi      # 0xcff0
leaq 0x596f(%rip), %rsi      # 0x8086
callq 0x21b0
jmp 0x2741
leaq 0x20(%rsp), %rdi
callq 0x400c
movl %eax, %ebx
testl %eax, %eax
je 0x2787
movq 0xa8bb(%rip), %rdi      # 0xcff0
leaq 0x5970(%rip), %rsi      # 0x80ac
callq 0x21b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x2370
movq %rax, %rdi
callq 0x20c0
pushq $-0x1
popq %rbx
leaq 0x80(%rsp), %rdi
callq 0x4b34
leaq 0x20(%rsp), %rdi
callq 0x3fd8
leaq 0xc8(%rsp), %rdi
callq 0x2df6
movl %ebx, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r14
retq
movq 0xa862(%rip), %rdi      # 0xcff0
leaq 0x593d(%rip), %rsi      # 0x80d2
callq 0x21b0
movq 0xa84f(%rip), %rdi      # 0xcff0
leaq 0x5943(%rip), %rsi      # 0x80eb
callq 0x21b0
movl 0x68(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa828(%rip), %rdi      # 0xcff0
leaq 0x592f(%rip), %rsi      # 0x80fe
callq 0x21b0
movl 0x6c(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa801(%rip), %rdi      # 0xcff0
leaq 0x591b(%rip), %rsi      # 0x8111
callq 0x21b0
movl 0x70(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa7da(%rip), %rdi      # 0xcff0
leaq 0x5907(%rip), %rsi      # 0x8124
callq 0x21b0
movl 0x78(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa7b3(%rip), %rdi      # 0xcff0
leaq 0x58f3(%rip), %rsi      # 0x8137
callq 0x21b0
movl 0x74(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa78c(%rip), %rdi      # 0xcff0
leaq 0x58df(%rip), %rsi      # 0x814a
callq 0x21b0
movl 0x7c(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa765(%rip), %rdi      # 0xcff0
callq 0x20c0
movq 0xa759(%rip), %rdi      # 0xcff0
leaq 0x58bf(%rip), %rsi      # 0x815d
callq 0x21b0
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x40b0
movq %rbx, %rdi
callq 0x2320
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x20c0
jmp 0x2756
movq %rax, %rbx
jmp 0x28f5
movq %rax, %rbx
jmp 0x28ff
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x20b0
jmp 0x290c
movq %rax, %rbx
jmp 0x290c
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x4b34
leaq 0x20(%rsp), %rdi
callq 0x3fd8
leaq 0xc8(%rsp), %rdi
callq 0x2df6
movq %rbx, %rdi
callq 0x2380