// File: sun98[P]Mini-DFS/datanode.cpp
// Function: DataServer::fetch()
void DataServer::fetch()
{
    buf = new char[chunkSize];
    std::string filePath = name_ + "/" + std::to_string(fid) + " " + std::to_string(offset);
    std::ifstream is(filePath);
    // file not found in this server.
    if (!is)
    {
        delete[] buf;
        bufSize = 0;
    }
    else
    {
        is.read(buf, std::min(chunkSize, bufSize - chunkSize * offset));
        bufSize = is.tellg();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x300(%rbp)
movslq 0x12ed7(%rip), %rdi     # 0x172f8
testq %rdi, %rdi
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x3030
movq -0x300(%rbp), %rsi
movq %rax, 0xb0(%rsi)
leaq 0xbbe5(%rip), %rdx      # 0x1002e
leaq -0x88(%rbp), %rdi
callq 0x4ba0
movq -0x300(%rbp), %rax
movl 0xa0(%rax), %esi
leaq -0xa8(%rbp), %rdi
callq 0x4c20
jmp 0x4470
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x4a80
jmp 0x4489
leaq 0xbd85(%rip), %rdx      # 0x10215
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x4b50
jmp 0x449f
movq -0x300(%rbp), %rax
movl 0xa8(%rax), %esi
leaq -0xd8(%rbp), %rdi
callq 0x4c20
jmp 0x44ba
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0x4a80
jmp 0x44d0
leaq -0xd8(%rbp), %rdi
callq 0x3210
leaq -0x48(%rbp), %rdi
callq 0x3210
leaq -0x68(%rbp), %rdi
callq 0x3210
leaq -0xa8(%rbp), %rdi
callq 0x3210
leaq -0x88(%rbp), %rdi
callq 0x3210
leaq -0x2e0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x8, %edx
callq 0x34c0
jmp 0x451d
movq -0x2e0(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x2e0(%rbp,%rax), %rdi
callq 0x3190
movb %al, -0x301(%rbp)
jmp 0x453d
movb -0x301(%rbp), %al
testb $0x1, %al
jne 0x454c
jmp 0x4660
movq -0x300(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x310(%rbp)
cmpq $0x0, %rax
je 0x4573
movq -0x310(%rbp), %rdi
callq 0x33b0
movq -0x300(%rbp), %rax
movl $0x0, 0xa4(%rax)
jmp 0x472e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x4615
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x4609
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x4600
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x45f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3210
leaq -0x48(%rbp), %rdi
callq 0x3210
leaq -0x68(%rbp), %rdi
callq 0x3210
leaq -0xa8(%rbp), %rdi
callq 0x3210
leaq -0x88(%rbp), %rdi
callq 0x3210
jmp 0x4755
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x474c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x30e0
jmp 0x474c
movq -0x300(%rbp), %rdx
movq 0xb0(%rdx), %rax
movq %rax, -0x320(%rbp)
leaq 0x12c7c(%rip), %rdi     # 0x172f8
movl 0x12c76(%rip), %ecx     # 0x172f8
movl 0xa4(%rdx), %eax
movl 0xa8(%rdx), %edx
imull %edx, %ecx
subl %ecx, %eax
movl %eax, -0x2e4(%rbp)
leaq -0x2e4(%rbp), %rsi
callq 0x4d40
movq %rax, -0x318(%rbp)
jmp 0x46ae
movq -0x320(%rbp), %rsi
movq -0x318(%rbp), %rax
movslq (%rax), %rdx
leaq -0x2e0(%rbp), %rdi
callq 0x3390
jmp 0x46cd
leaq -0x2e0(%rbp), %rdi
callq 0x3540
movq %rdx, -0x330(%rbp)
movq %rax, -0x328(%rbp)
jmp 0x46e9
movq -0x330(%rbp), %rax
movq -0x328(%rbp), %rcx
movq %rcx, -0x2f8(%rbp)
movq %rax, -0x2f0(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x4d80
movq %rax, -0x338(%rbp)
jmp 0x471a
movq -0x300(%rbp), %rax
movq -0x338(%rbp), %rcx
movl %ecx, 0xa4(%rax)
leaq -0x2e0(%rbp), %rdi
callq 0x30e0
leaq -0x28(%rbp), %rdi
callq 0x3210
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x3210
movq -0xb0(%rbp), %rdi
callq 0x3560
nopw %cs:(%rax,%rax)