// File: /workspace/github_cpp_makefile_star2_O2/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 $0x178, %rsp            # imm = 0x178
cmpl $0x4, %edi
jne 0x269c
movq %rsi, %rbx
movq 0x8(%rsi), %r14
movq 0x10(%rsi), %rdi
callq 0x2300
movl %eax, %ebp
movq 0x18(%rbx), %rax
movb (%rax), %al
andb $-0x21, %al
xorl %ebx, %ebx
cmpb $0x44, %al
sete %r15b
leaq 0x28(%rsp), %rdi
leaq 0x88(%rsp), %rdx
movq %r14, %rsi
callq 0x29b8
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2dd4
leaq 0x28(%rsp), %rdi
callq 0x20b0
leaq 0x28(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
movl %ebp, %edx
callq 0x4398
leaq 0x88(%rsp), %rdi
leaq 0x28(%rsp), %rcx
pushq $0x1
popq %r8
xorl %esi, %esi
xorl %edx, %edx
callq 0x4e44
leaq 0x28(%rsp), %rdi
callq 0x447a
movl %eax, %ebp
testl %eax, %eax
je 0x26a6
movq 0xa962(%rip), %rdi      # 0xcff0
leaq 0x59a3(%rip), %rsi      # 0x8038
callq 0x21b0
jmp 0x26d0
callq 0x25ac
pushq $-0x1
popq %rbx
jmp 0x2709
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x50ba
movl %eax, %ebp
testl %eax, %eax
je 0x2719
movq 0xa92c(%rip), %rdi      # 0xcff0
leaq 0x5994(%rip), %rsi      # 0x805f
callq 0x21b0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2370
movq %rax, %rdi
callq 0x20c0
pushq $-0x1
popq %rbx
leaq 0x88(%rsp), %rdi
callq 0x4f20
leaq 0x28(%rsp), %rdi
callq 0x43c4
leaq 0xf8(%rsp), %rdi
callq 0x31e2
movl %ebx, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xa8d0(%rip), %rdi      # 0xcff0
leaq 0x595d(%rip), %rsi      # 0x8084
callq 0x21b0
movq %rax, %rdi
callq 0x20c0
leaq 0xd0(%rsp), %rdi
callq 0x2a8c
movb %r15b, %bl
movq 0xa885(%rip), %rsi      # 0xcfd0
leaq 0x88(%rsp), %rdi
movl %ebx, %edx
callq 0x6b3e
movl %eax, %ebx
testl %eax, %eax
je 0x2787
movq 0xa889(%rip), %rdi      # 0xcff0
leaq 0x5926(%rip), %rsi      # 0x8094
callq 0x21b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x2370
movq %rax, %rdi
callq 0x20c0
jmp 0x279a
movq 0xa862(%rip), %rdi      # 0xcff0
leaq 0x5916(%rip), %rsi      # 0x80ab
callq 0x21b0
leaq 0x88(%rsp), %rdi
leaq 0x24(%rsp), %rsi
callq 0x52ca
movl %eax, %ebx
testl %eax, %eax
je 0x27c7
movq 0xa837(%rip), %rdi      # 0xcff0
leaq 0x58fe(%rip), %rsi      # 0x80be
callq 0x21b0
jmp 0x27ea
leaq 0x28(%rsp), %rdi
callq 0x43f8
movl %eax, %ebx
testl %eax, %eax
je 0x2811
movq 0xa812(%rip), %rdi      # 0xcff0
leaq 0x58ff(%rip), %rsi      # 0x80e4
callq 0x21b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x2370
movq %rax, %rdi
callq 0x20c0
pushq $-0x1
popq %rbx
leaq 0xd0(%rsp), %rdi
callq 0x2c36
jmp 0x26e5
movq 0xa7d8(%rip), %rdi      # 0xcff0
leaq 0x58eb(%rip), %rsi      # 0x810a
callq 0x21b0
movq 0xa7c5(%rip), %rdi      # 0xcff0
leaq 0x58f1(%rip), %rsi      # 0x8123
callq 0x21b0
movl 0x70(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa79e(%rip), %rdi      # 0xcff0
leaq 0x58dd(%rip), %rsi      # 0x8136
callq 0x21b0
movl 0x74(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa777(%rip), %rdi      # 0xcff0
leaq 0x58c9(%rip), %rsi      # 0x8149
callq 0x21b0
movl 0x78(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa750(%rip), %rdi      # 0xcff0
leaq 0x58b5(%rip), %rsi      # 0x815c
callq 0x21b0
movl 0x80(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa726(%rip), %rdi      # 0xcff0
leaq 0x589e(%rip), %rsi      # 0x816f
callq 0x21b0
movl 0x7c(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa6ff(%rip), %rdi      # 0xcff0
leaq 0x588a(%rip), %rsi      # 0x8182
callq 0x21b0
movl 0x84(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa6d5(%rip), %rdi      # 0xcff0
callq 0x20c0
movq 0xa6c9(%rip), %rdi      # 0xcff0
leaq 0x5867(%rip), %rsi      # 0x8195
callq 0x21b0
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x449c
movq %rbx, %rdi
callq 0x2320
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x20c0
jmp 0x27ff
jmp 0x2989
movq %rax, %rbx
jmp 0x2999
movq %rax, %rbx
jmp 0x29a3
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x20b0
jmp 0x29b0
movq %rax, %rbx
jmp 0x29b0
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x2c36
jmp 0x298c
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x4f20
leaq 0x28(%rsp), %rdi
callq 0x43c4
leaq 0xf8(%rsp), %rdi
callq 0x31e2
movq %rbx, %rdi
callq 0x2380