// File: /workspace/github_cpp_makefile_star2_O1/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 $0x160, %rsp            # imm = 0x160
cmpl $0x4, %edi
jne 0x26f2
movq %rsi, %rbx
movq 0x8(%rsi), %r14
movq 0x10(%rsi), %rdi
callq 0x22f0
movl %eax, %ebp
movq 0x18(%rbx), %rbx
leaq 0x10(%rsp), %rdi
leaq 0x98(%rsp), %rdx
movq %r14, %rsi
callq 0x2b24
subq $0x8, %rsp
xorl %eax, %eax
leaq 0xe8(%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 0x2fdc
addq $0x20, %rsp
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2670
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21e0
leaq 0x10(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
movl %ebp, %edx
callq 0x49d0
leaq 0x98(%rsp), %rdi
leaq 0x10(%rsp), %rcx
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %r8d
callq 0x54ac
leaq 0x10(%rsp), %rdi
callq 0x4ac8
movl %eax, %ebp
testl %eax, %eax
je 0x2714
movq 0xb939(%rip), %rdi      # 0xdff0
leaq 0x6972(%rip), %rsi      # 0x9030
movl $0x26, %edx
callq 0x2230
movq 0xb921(%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 0x28a5
movq 0xb8f7(%rip), %rdi      # 0xdff0
leaq 0x6904(%rip), %rsi      # 0x9004
movl $0x2b, %edx
callq 0x2230
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x28e1
leaq 0x98(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x573a
movl %eax, %ebp
testl %eax, %eax
je 0x276d
movq 0xb8be(%rip), %rdi      # 0xdff0
leaq 0x691e(%rip), %rsi      # 0x9057
movl $0x24, %edx
callq 0x2230
movq 0xb8a6(%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 0x28a5
movq 0xb87c(%rip), %r14      # 0xdff0
leaq 0x6901(%rip), %rsi      # 0x907c
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 0xb84a(%rip), %rdi      # 0xdff0
callq 0x2040
movq %rax, %rdi
callq 0x2130
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x2d36
leaq 0x98(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x6ed2
movl %eax, %ebx
leaq 0x70(%rsp), %rdi
callq 0x2dc2
testl %ebx, %ebx
je 0x2834
movq 0xb807(%rip), %rdi      # 0xdff0
leaq 0x689c(%rip), %rsi      # 0x908c
movl $0x25, %edx
callq 0x2230
movq 0xb7ef(%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 0x284c
movq 0xb7b5(%rip), %rdi      # 0xdff0
leaq 0x6870(%rip), %rsi      # 0x90b2
movl $0x11, %edx
callq 0x2230
leaq 0x98(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x5956
movl %eax, %ebx
testl %eax, %eax
je 0x28ef
movq 0xb781(%rip), %rdi      # 0xdff0
leaq 0x684e(%rip), %rsi      # 0x90c4
movl $0x25, %edx
callq 0x2230
movq 0xb769(%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 0x98(%rsp), %rdi
callq 0x5588
leaq 0x10(%rsp), %rdi
callq 0x4a00
leaq 0xe0(%rsp), %rdi
callq 0x357c
movl %ebx, %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x10(%rsp), %rdi
callq 0x4a38
movl %eax, %ebx
testl %eax, %eax
je 0x2934
movq 0xb6ea(%rip), %rdi      # 0xdff0
leaq 0x67dd(%rip), %rsi      # 0x90ea
movl $0x25, %edx
callq 0x2230
movq 0xb6d2(%rip), %rdi      # 0xdff0
movl %ebx, %esi
callq 0x2360
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x20c0
jmp 0x28bd
movq 0xb6b5(%rip), %rdi      # 0xdff0
leaq 0x67ce(%rip), %rsi      # 0x9110
movl $0x18, %edx
callq 0x2230
movq 0xb69d(%rip), %rdi      # 0xdff0
leaq 0x67cf(%rip), %rsi      # 0x9129
movl $0x12, %edx
callq 0x2230
movl 0x58(%rsp), %esi
movq 0xb681(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb66d(%rip), %rdi      # 0xdff0
leaq 0x67b2(%rip), %rsi      # 0x913c
movl $0x12, %edx
callq 0x2230
movl 0x5c(%rsp), %esi
movq 0xb651(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb63d(%rip), %rdi      # 0xdff0
leaq 0x6795(%rip), %rsi      # 0x914f
movl $0x12, %edx
callq 0x2230
movl 0x60(%rsp), %esi
movq 0xb621(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb60d(%rip), %rdi      # 0xdff0
leaq 0x6778(%rip), %rsi      # 0x9162
movl $0x12, %edx
callq 0x2230
movl 0x68(%rsp), %esi
movq 0xb5f1(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb5dd(%rip), %rdi      # 0xdff0
leaq 0x675b(%rip), %rsi      # 0x9175
movl $0x12, %edx
callq 0x2230
movl 0x64(%rsp), %esi
movq 0xb5c1(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb5ad(%rip), %rdi      # 0xdff0
leaq 0x673e(%rip), %rsi      # 0x9188
movl $0x12, %edx
callq 0x2230
movl 0x6c(%rsp), %esi
movq 0xb591(%rip), %rdi      # 0xdff0
callq 0x2120
movq %rax, %rdi
callq 0x20c0
movq 0xb57d(%rip), %rdi      # 0xdff0
callq 0x20c0
movq 0xb571(%rip), %rdi      # 0xdff0
leaq 0x6715(%rip), %rsi      # 0x919b
movl $0x12, %edx
callq 0x2230
leaq 0x10(%rsp), %rdi
callq 0x4aea
movq 0xb54f(%rip), %rdi      # 0xdff0
callq 0x2310
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x20c0
jmp 0x28bd
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2dc2
jmp 0x2af8
jmp 0x2af5
movq %rax, %rbx
jmp 0x2b05
movq %rax, %rbx
jmp 0x2b0f
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b1c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2b1c
movq %rax, %rbx
jmp 0x2b1c
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x5588
leaq 0x10(%rsp), %rdi
callq 0x4a00
leaq 0xe0(%rsp), %rdi
callq 0x357c
movq %rbx, %rdi
callq 0x2370