// File: /workspace/github_cpp_makefile_star2_O1/cpottamus[P]btree_lab/disksystem.cc
// Function: DiskSystem::Read(unsigned int, unsigned int, std::vector<Block, std::allocator<Block>>&, double&)
ERROR_T DiskSystem::Read(const SIZE_T   inoffblock,
			 const SIZE_T   numblock,
			 vector<Block> &blocks,
			 double        &reqtime)
{
  reqtime=0;

  if (inoffblock+numblock > numblocks) { 
    cerr << "DiskSystem::Read: Attempt to read blocks "<<inoffblock<<" to "<<(inoffblock+numblock-1)<<", but maxmimum block is only "<<(numblocks-1)<<endl;
    return ERROR_NOSPACE;
  }

  reqtime=ModelAccess(inoffblock,numblock);

  for (SIZE_T i=0;i<numblock;i++) { 
    Block b(blocksize);
    if (!IsBlockAllocated(inoffblock+i)) { 
      if (PRINT_DISKSYSTEM_ALLOCATION_ERRORS) {
	cerr <<"DiskSystem::Read: reading unallocated block "<<(i+inoffblock)<<endl;
      }
    }
    if (myread(datafilefd,offset+(inoffblock+i)*blocksize,b.data,blocksize,true)!=blocksize) { 
      cerr << "DiskSystem::Read: myread has failed"<<endl;
      return ERROR_IMPLBUG;
    }
    blocks.push_back(b);
  }

  return ERROR_NOERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, 0x8(%rsp)
movl %edx, %r12d
movl %esi, %r14d
movq %rdi, %rbx
movq $0x0, (%r8)
leal (%r12,%r14), %r15d
cmpl 0x4c(%rdi), %r15d
jbe 0x3e90
movq 0xa1fc(%rip), %r12      # 0xdff0
leaq 0x55b6(%rip), %rsi      # 0x93b1
movl $0x29, %edx
movq %r12, %rdi
callq 0x2230
movl %r14d, %esi
movq %r12, %rdi
callq 0x2120
movq %rax, %r14
leaq 0x55be(%rip), %rsi      # 0x93db
movl $0x4, %edx
movq %rax, %rdi
callq 0x2230
decl %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movq %rax, %r14
leaq 0x559e(%rip), %rsi      # 0x93e0
movl $0x1d, %edx
movq %rax, %rdi
callq 0x2230
movl 0x4c(%rbx), %esi
decl %esi
movq %r14, %rdi
callq 0x2120
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
movl $0xfffffff9, %eax       # imm = 0xFFFFFFF9
jmp 0x3f67
movq %r8, %r13
movq (%rbx), %rax
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq *(%rax)
movsd %xmm0, (%r13)
xorl %eax, %eax
testl %r12d, %r12d
je 0x3f67
leaq 0x10(%rsp), %r13
movl 0x50(%rbx), %esi
movq %r13, %rdi
callq 0x2c80
movq 0x10(%rbx), %rdi
movl 0x50(%rbx), %ecx
movl %ecx, %esi
imull %r14d, %esi
addl 0x48(%rbx), %esi
movq 0x18(%rsp), %rdx
movl $0x1, %r8d
callq 0x3c3e
movl %eax, %r15d
movl 0x50(%rbx), %ebp
cmpl %ebp, %eax
jne 0x3efb
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x4602
jmp 0x3f45
movl $0x23, %edx
movq 0xa0e9(%rip), %rdi      # 0xdff0
leaq 0x54f0(%rip), %rsi      # 0x93fe
callq 0x2230
movq 0xa0d6(%rip), %rcx      # 0xdff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq 0xa0b8(%rip), %rdi      # 0xdff0
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %r13, %rdi
callq 0x2e22
cmpl %ebp, %r15d
jne 0x3f62
incl %r14d
decl %r12d
jne 0x3eb7
xorl %eax, %eax
jmp 0x3f67
movl $0xfffffff5, %eax       # imm = 0xFFFFFFF5
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2e22
movq %rbx, %rdi
callq 0x2370
nop