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

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

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

  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;
    if ((rc=btree.Delete(KEY_T(key)))!=ERROR_NOERROR) { 
      cerr <<"Can't delete from index due to error "<<rc<<endl;
    } else {
      cerr <<"Delete 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 %r14
pushq %rbx
subq $0x170, %rsp            # imm = 0x170
cmpl $0x4, %edi
jne 0x2691
movq %rsi, %rbx
movq 0x8(%rsi), %r14
movq 0x10(%rsi), %rdi
callq 0x2300
movl %eax, %ebp
movq 0x18(%rbx), %rbx
leaq 0x20(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
movq %r14, %rsi
callq 0x2992
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
leaq 0xf0(%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 0x2dac
leaq 0x20(%rsp), %rdi
callq 0x20b0
leaq 0x20(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
movl %ebp, %edx
callq 0x4370
leaq 0xa8(%rsp), %rdi
leaq 0x20(%rsp), %rcx
pushq $0x1
popq %r8
xorl %esi, %esi
xorl %edx, %edx
callq 0x4e1c
leaq 0x20(%rsp), %rdi
callq 0x4452
movl %eax, %ebp
testl %eax, %eax
je 0x269e
movq 0xa970(%rip), %rdi      # 0xcff0
leaq 0x59a9(%rip), %rsi      # 0x8030
callq 0x21b0
jmp 0x27aa
callq 0x25ac
pushq $-0x1
popq %rbx
jmp 0x27e3
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5092
movl %eax, %ebp
testl %eax, %eax
je 0x26cd
movq 0xa934(%rip), %rdi      # 0xcff0
leaq 0x5994(%rip), %rsi      # 0x8057
callq 0x21b0
jmp 0x27aa
movq 0xa91c(%rip), %rdi      # 0xcff0
leaq 0x59a1(%rip), %rsi      # 0x807c
callq 0x21b0
movq %rax, %rdi
callq 0x20c0
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x2b8c
leaq 0xa8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x660a
movl %eax, %ebx
leaq 0x80(%rsp), %rdi
callq 0x2c0e
testl %ebx, %ebx
je 0x2747
movq 0xa8c9(%rip), %rdi      # 0xcff0
leaq 0x595e(%rip), %rsi      # 0x808c
callq 0x21b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x2370
movq %rax, %rdi
callq 0x20c0
jmp 0x275a
movq 0xa8a2(%rip), %rdi      # 0xcff0
leaq 0x595d(%rip), %rsi      # 0x80b2
callq 0x21b0
leaq 0xa8(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0x52a2
movl %eax, %ebp
testl %eax, %eax
je 0x2787
movq 0xa877(%rip), %rdi      # 0xcff0
leaq 0x5944(%rip), %rsi      # 0x80c4
callq 0x21b0
jmp 0x27aa
leaq 0x20(%rsp), %rdi
callq 0x43d0
movl %eax, %ebp
testl %eax, %eax
je 0x27f1
movq 0xa852(%rip), %rdi      # 0xcff0
leaq 0x5945(%rip), %rsi      # 0x80ea
callq 0x21b0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2370
movq %rax, %rdi
callq 0x20c0
pushq $-0x1
popq %rbx
leaq 0xa8(%rsp), %rdi
callq 0x4ef8
leaq 0x20(%rsp), %rdi
callq 0x439c
leaq 0xf0(%rsp), %rdi
callq 0x31ba
movl %ebx, %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbx
popq %r14
popq %rbp
retq
movq 0xa7f8(%rip), %rdi      # 0xcff0
leaq 0x5911(%rip), %rsi      # 0x8110
callq 0x21b0
movq 0xa7e5(%rip), %rdi      # 0xcff0
leaq 0x5917(%rip), %rsi      # 0x8129
callq 0x21b0
movl 0x68(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa7be(%rip), %rdi      # 0xcff0
leaq 0x5903(%rip), %rsi      # 0x813c
callq 0x21b0
movl 0x6c(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa797(%rip), %rdi      # 0xcff0
leaq 0x58ef(%rip), %rsi      # 0x814f
callq 0x21b0
movl 0x70(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa770(%rip), %rdi      # 0xcff0
leaq 0x58db(%rip), %rsi      # 0x8162
callq 0x21b0
movl 0x78(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa749(%rip), %rdi      # 0xcff0
leaq 0x58c7(%rip), %rsi      # 0x8175
callq 0x21b0
movl 0x74(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa722(%rip), %rdi      # 0xcff0
leaq 0x58b3(%rip), %rsi      # 0x8188
callq 0x21b0
movl 0x7c(%rsp), %esi
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xa6fb(%rip), %rdi      # 0xcff0
callq 0x20c0
movq 0xa6ef(%rip), %rdi      # 0xcff0
leaq 0x5893(%rip), %rsi      # 0x819b
callq 0x21b0
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4474
movq %rbx, %rdi
callq 0x2320
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x20c0
jmp 0x27bf
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x2c0e
jmp 0x2966
jmp 0x2963
movq %rax, %rbx
jmp 0x2973
movq %rax, %rbx
jmp 0x297d
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x20b0
jmp 0x298a
movq %rax, %rbx
jmp 0x298a
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x4ef8
leaq 0x20(%rsp), %rdi
callq 0x439c
leaq 0xf0(%rsp), %rdi
callq 0x31ba
movq %rbx, %rdi
callq 0x2380