// File: /workspace/github_cpp_makefile_star2_O3/cpottamus[P]btree_lab/writedisk.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]);
  SIZE_T blocksize = disk.GetBlockSize();

  vector<Block> b;

  for (unsigned i=0;i<numblocks;i++) { 
    Block block(blocksize);
    for (unsigned j=0;j<blocksize;j++) { 
      cin >> block.data[j];
    }
    b.push_back(block);
  }


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

  if (rc!=ERROR_NOERROR) { 
    cerr << "Error "<< rc << " occured.\n";
    return -1;
  } else {
    cerr << "Your data was successfully written.\n";
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
cmpl $0x3, %edi
jle 0x26cc
movq %rsi, %r14
movq 0x10(%rsi), %rdi
callq 0x22a0
movl %eax, 0xc(%rsp)
movq 0x18(%r14), %rdi
callq 0x22a0
movl %eax, 0x8(%rsp)
movq 0x8(%r14), %rsi
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x2738
subq $0x8, %rsp
xorl %eax, %eax
leaq 0x60(%rsp), %rdi
leaq 0x30(%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 0x2eec
addq $0x20, %rsp
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x25a8
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x58(%rsp), %rdi
callq 0x4074
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0x8(%rsp)
je 0x2627
movl %eax, %r14d
movl %eax, %ebx
xorl %r12d, %r12d
leaq 0x28(%rsp), %r15
movq 0x59fa(%rip), %r13      # 0x7fd8
movq %r15, %rdi
movl %r14d, %esi
callq 0x2b50
testl %r14d, %r14d
je 0x2608
xorl %ebp, %ebp
movq 0x30(%rsp), %rsi
addq %rbp, %rsi
movq %r13, %rdi
callq 0x2230
incq %rbp
cmpq %rbp, %rbx
jne 0x25f0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x2776
movq %r15, %rdi
callq 0x2cf2
incl %r12d
cmpl 0x8(%rsp), %r12d
jne 0x25de
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rcx
leaq 0x50(%rsp), %r8
movl 0xc(%rsp), %esi
movl 0x8(%rsp), %edx
callq 0x3e54
movl %eax, %ebx
testl %eax, %eax
je 0x268a
movq 0x59a0(%rip), %rdi      # 0x7ff0
leaq 0x29e2(%rip), %rsi      # 0x5039
movl $0x6, %edx
callq 0x21d0
movq 0x5988(%rip), %rdi      # 0x7ff0
movl %ebx, %esi
callq 0x2300
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x29c5(%rip), %rsi      # 0x5040
movl $0xa, %edx
movq %rax, %rdi
callq 0x21d0
jmp 0x26a4
xorl %ebx, %ebx
movq 0x595d(%rip), %rdi      # 0x7ff0
leaq 0x29b1(%rip), %rsi      # 0x504b
movl $0x24, %edx
callq 0x21d0
leaq 0x10(%rsp), %rdi
callq 0x27a2
leaq 0x58(%rsp), %rdi
callq 0x348c
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x24fc
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2200
movq %rax, %rbx
jmp 0x2725
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x272f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x272f
movq %rax, %rbx
jmp 0x272f
jmp 0x2709
jmp 0x270e
movq %rax, %rbx
jmp 0x271b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2cf2
leaq 0x10(%rsp), %rdi
callq 0x27a2
leaq 0x58(%rsp), %rdi
callq 0x348c
movq %rbx, %rdi
callq 0x2310
nop