// File: sun98[P]Mini-DFS/datanode.cpp
// Function: DataServer::put()
void DataServer::put()
{
    int start = 0;
    std::ofstream os;
    while (start < bufSize)
    {
        int offset = start / chunkSize;
        std::string filePath = name_ + "/" + std::to_string(fid) + " " + std::to_string(offset);
        os.open(filePath);
        if (!os)
            std::cerr << "Failed in creating file in data server: " << filePath << std::endl;
        os.write(&buf[start], std::min(chunkSize, bufSize - start));
        start += chunkSize;
        os.close();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x320, %rsp            # imm = 0x320
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movl $0x0, -0xc(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3500
movq -0x2f8(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0xa4(%rcx), %eax
jge 0x3e1c
movq -0x2f8(%rbp), %rsi
movl -0xc(%rbp), %eax
movl 0x137c5(%rip), %ecx     # 0x172f8
cltd
idivl %ecx
movl %eax, -0x214(%rbp)
leaq 0xc4eb(%rip), %rdx      # 0x1002e
leaq -0x298(%rbp), %rdi
callq 0x4ba0
jmp 0x3b51
movq -0x2f8(%rbp), %rax
movl 0xa0(%rax), %esi
leaq -0x2c8(%rbp), %rdi
callq 0x4c20
jmp 0x3b6c
leaq -0x278(%rbp), %rdi
leaq -0x298(%rbp), %rsi
leaq -0x2c8(%rbp), %rdx
callq 0x4a80
jmp 0x3b88
leaq 0xc686(%rip), %rdx      # 0x10215
leaq -0x258(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x4b50
jmp 0x3ba4
movl -0x214(%rbp), %esi
leaq -0x2e8(%rbp), %rdi
callq 0x4c20
jmp 0x3bb8
leaq -0x238(%rbp), %rdi
leaq -0x258(%rbp), %rsi
leaq -0x2e8(%rbp), %rdx
callq 0x4a80
jmp 0x3bd4
leaq -0x2e8(%rbp), %rdi
callq 0x3210
leaq -0x258(%rbp), %rdi
callq 0x3210
leaq -0x278(%rbp), %rdi
callq 0x3210
leaq -0x2c8(%rbp), %rdi
callq 0x3210
leaq -0x298(%rbp), %rdi
callq 0x3210
leaq -0x210(%rbp), %rdi
leaq -0x238(%rbp), %rsi
movl $0x10, %edx
callq 0x31b0
jmp 0x3c2a
movq -0x210(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x210(%rbp,%rax), %rdi
callq 0x3190
movb %al, -0x2f9(%rbp)
jmp 0x3c4a
movb -0x2f9(%rbp), %al
testb $0x1, %al
jne 0x3c59
jmp 0x3d88
movq 0x13390(%rip), %rdi     # 0x16ff0
leaq 0xc3c9(%rip), %rsi      # 0x10030
callq 0x3300
movq %rax, -0x308(%rbp)
jmp 0x3c75
movq -0x308(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x32d0
movq %rax, -0x310(%rbp)
jmp 0x3c91
movq -0x310(%rbp), %rdi
movq 0x13309(%rip), %rsi     # 0x16fa8
callq 0x3330
jmp 0x3ca6
jmp 0x3d88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
jmp 0x3e31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
jmp 0x3d54
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
jmp 0x3d48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
jmp 0x3d3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
jmp 0x3d30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x3210
leaq -0x258(%rbp), %rdi
callq 0x3210
leaq -0x278(%rbp), %rdi
callq 0x3210
leaq -0x2c8(%rbp), %rdi
callq 0x3210
leaq -0x298(%rbp), %rdi
callq 0x3210
jmp 0x3e31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2a0(%rbp)
movl %eax, -0x2a4(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x3210
jmp 0x3e31
movq -0x2f8(%rbp), %rax
movq 0xb0(%rax), %rdx
movslq -0xc(%rbp), %rsi
movl %esi, %ecx
addq %rsi, %rdx
movq %rdx, -0x320(%rbp)
movl 0xa4(%rax), %eax
subl %ecx, %eax
movl %eax, -0x2ec(%rbp)
leaq 0x1353d(%rip), %rdi     # 0x172f8
leaq -0x2ec(%rbp), %rsi
callq 0x4d40
movq %rax, -0x318(%rbp)
jmp 0x3dd0
movq -0x320(%rbp), %rsi
movq -0x318(%rbp), %rax
movslq (%rax), %rdx
leaq -0x210(%rbp), %rdi
callq 0x33d0
jmp 0x3def
movl 0x13503(%rip), %ecx     # 0x172f8
movl -0xc(%rbp), %eax
addl %ecx, %eax
movl %eax, -0xc(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3430
jmp 0x3e0b
leaq -0x238(%rbp), %rdi
callq 0x3210
jmp 0x3b0d
leaq -0x210(%rbp), %rdi
callq 0x3470
addq $0x320, %rsp            # imm = 0x320
popq %rbp
retq
leaq -0x210(%rbp), %rdi
callq 0x3470
movq -0x2a0(%rbp), %rdi
callq 0x3560
nopl (%rax)