// File: cpottamus[P]btree_lab/readdisk.cc
// Function: main
int main(int argc, char *argv[])
{
  if (argc<4) { 
    usage();
    exit(-1);
  }
  SIZE_T blocknum=atoi(argv[2]);
  SIZE_T numblocks=atoi(argv[3]);
  double reqtime;

  DiskSystem disk(argv[1]);

  vector<Block> b;

  ERROR_T rc= disk.Read(blocknum, numblocks, b, reqtime);

  if (rc!=ERROR_NOERROR) { 
    cerr << "Error "<< rc << " occured.\n";
    return -1;
  } else {
    cerr << "Read took "<<reqtime<<" milliseconds\n";
    for (vector<Block>::const_iterator i=b.begin();i!=b.end();++i) {
      // cerr << (*i);
      for (SIZE_T j=0;j<(*i).length;j++) { 
	cout << (*i).data[j];
      }
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x4, -0x8(%rbp)
jge 0x262e
callq 0x25e0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2290
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2350
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2350
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x128(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x23b0
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
callq 0x2970
jmp 0x268c
movq %rsp, %rax
movl $0x0, 0x10(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, (%rax)
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
xorl %r9d, %r9d
xorps %xmm2, %xmm2
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x3160
jmp 0x26cd
leaq -0xc0(%rbp), %rdi
callq 0x2100
leaq -0xc1(%rbp), %rdi
callq 0x2220
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x2a20
movq -0x138(%rbp), %rcx
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
leaq -0xa0(%rbp), %rdi
leaq -0x20(%rbp), %r8
callq 0x45c0
movl %eax, -0x12c(%rbp)
jmp 0x271d
movl -0x12c(%rbp), %eax
movl %eax, -0xf4(%rbp)
cmpl $0x0, -0xf4(%rbp)
je 0x280a
movq 0x68b3(%rip), %rdi      # 0x8ff0
leaq 0x38f4(%rip), %rsi      # 0x6038
callq 0x21b0
movq %rax, -0x140(%rbp)
jmp 0x2752
movq -0x140(%rbp), %rdi
movl -0xf4(%rbp), %esi
callq 0x2390
movq %rax, -0x148(%rbp)
jmp 0x276d
movq -0x148(%rbp), %rdi
leaq 0x38c4(%rip), %rsi      # 0x603f
callq 0x21b0
jmp 0x2782
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0xf8(%rbp)
jmp 0x2938
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x27ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x2100
leaq -0xc1(%rbp), %rdi
callq 0x2220
jmp 0x295c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x2b60
leaq -0xa0(%rbp), %rdi
callq 0x39d0
jmp 0x295c
movq 0x67df(%rip), %rdi      # 0x8ff0
leaq 0x3832(%rip), %rsi      # 0x604a
callq 0x21b0
movq %rax, -0x150(%rbp)
jmp 0x2826
movq -0x150(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
callq 0x23e0
movq %rax, -0x158(%rbp)
jmp 0x2840
movq -0x158(%rbp), %rdi
leaq 0x3807(%rip), %rsi      # 0x6055
callq 0x21b0
jmp 0x2855
leaq -0xf0(%rbp), %rdi
callq 0x2a40
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x2a70
leaq -0xf0(%rbp), %rdi
callq 0x2af0
movq %rax, -0x110(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x2ab0
testb $0x1, %al
jne 0x28a7
jmp 0x2925
movl $0x0, -0x114(%rbp)
movl -0x114(%rbp), %eax
movl %eax, -0x15c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x2b20
movq %rax, %rcx
movl -0x15c(%rbp), %eax
cmpl 0x10(%rcx), %eax
jae 0x2912
leaq -0x100(%rbp), %rdi
callq 0x2b20
movq 0x8(%rax), %rax
movl -0x114(%rbp), %ecx
movzbl (%rax,%rcx), %esi
movq 0x66d8(%rip), %rdi      # 0x8fd0
callq 0x2320
jmp 0x28ff
jmp 0x2901
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x28b1
jmp 0x2914
leaq -0x100(%rbp), %rdi
callq 0x2b40
jmp 0x287b
jmp 0x2927
movl $0x0, -0x4(%rbp)
movl $0x1, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x2b60
leaq -0xa0(%rbp), %rdi
callq 0x39d0
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0x23a0
nopl (%rax,%rax)