// File: /workspace/github_cpp_makefile_star2_O2/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::put(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void FileSystem::put(std::string localFile, std::string remoteFile)
{
    // hashing function to find the machine/s where to store the file;

    ChronoCpu chrono("cpu");
    
    chrono.tic();
    int fileKey = hashString(remoteFile);
    int position = findPositionByKey(fileKey);

    // cout<<"put "<<localFile<<" "<<fileKey<<" to "<<position<<" "<<virtualRing[position].ip_str<<" "<<virtualRing[position].key<<endl;

    bool attempt = putToNode( position, localFile, remoteFile );
    
    attempt = putToNode( position+1, localFile, remoteFile );
    
    attempt = putToNode( position+2, localFile, remoteFile );

    chrono.tac();

    std::cout << "File " << remoteFile << " added in " << chrono.getElapsedStats().lastTime_ms << " ms" << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x5517(%rip), %rsi      # 0xfa65
leaq -0x110(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4170
leaq -0x218(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xe1a4
leaq -0x110(%rbp), %rdi
callq 0x41b0
leaq -0x218(%rbp), %rdi
callq 0xe4c6
leaq -0x130(%rbp), %rdi
movq %rbx, %rsi
callq 0x4450
leaq -0x130(%rbp), %r12
movq %r12, %rdi
callq 0x95d4
movl %eax, %r13d
movq %r12, %rdi
callq 0x41b0
movq %r14, %rdi
movl %r13d, %esi
callq 0x9c12
movl %eax, %r12d
leaq -0xf0(%rbp), %rdi
movq %r15, %rsi
callq 0x4450
leaq -0xd0(%rbp), %rdi
movq %rbx, %rsi
callq 0x4450
leaq -0xf0(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
movq %r14, %rdi
movl %r12d, %esi
callq 0x9c80
leaq -0xd0(%rbp), %rdi
callq 0x41b0
leaq -0xf0(%rbp), %rdi
callq 0x41b0
leaq -0xb0(%rbp), %rdi
movq %r15, %rsi
callq 0x4450
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
callq 0x4450
leal 0x1(%r12), %esi
leaq -0xb0(%rbp), %rdx
leaq -0x90(%rbp), %rcx
movq %r14, %rdi
callq 0x9c80
leaq -0x90(%rbp), %rdi
callq 0x41b0
leaq -0xb0(%rbp), %rdi
callq 0x41b0
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x4450
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x4450
addl $0x2, %r12d
leaq -0x70(%rbp), %rdx
leaq -0x50(%rbp), %rcx
movq %r14, %rdi
movl %r12d, %esi
callq 0x9c80
leaq -0x50(%rbp), %rdi
callq 0x41b0
leaq -0x70(%rbp), %rdi
callq 0x41b0
leaq -0x218(%rbp), %rdi
callq 0xe538
movq 0xb90c(%rip), %rdi      # 0x15fc0
leaq 0x54ea(%rip), %rsi      # 0xfba5
callq 0x4370
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4300
leaq 0x5397(%rip), %rsi      # 0xfa69
movq %rax, %rdi
callq 0x4370
movq %rax, %rbx
leaq -0x218(%rbp), %rdi
callq 0xe5c6
movss 0x34(%rax), %xmm0
movq %rbx, %rdi
callq 0x4270
leaq 0x5377(%rip), %rsi      # 0xfa74
movq %rax, %rdi
callq 0x4370
movq %rax, %rdi
callq 0x41d0
leaq -0x218(%rbp), %rdi
callq 0xe1e4
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x41b0
jmp 0xa73c
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
jmp 0xa77a
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x41b0
jmp 0xa756
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
jmp 0xa77a
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x41b0
jmp 0xa773
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x41b0
jmp 0xa7a0
jmp 0xa79d
jmp 0xa79d
jmp 0xa79d
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x41b0
jmp 0xa7ac
movq %rax, %rbx
jmp 0xa7ac
movq %rax, %rbx
leaq -0x218(%rbp), %rdi
callq 0xe1e4
movq %rbx, %rdi
callq 0x45d0