// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1e8, %rsp            # imm = 0x1E8
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq -0x118(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x7255(%rip), %rsi      # 0x13a8d
leaq 0x7251(%rip), %rdx      # 0x13a90
leaq -0x128(%rbp), %rdi
callq 0xa592
leaq -0x210(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x11a50
movq -0x128(%rbp), %rdi
cmpq %r12, %rdi
je 0xc86f
callq 0x4360
leaq -0x210(%rbp), %rdi
callq 0x11e44
leaq -0xf8(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x108(%rbp), %rdi
callq 0x56fa
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
movl $0xc70f6907, %edx       # imm = 0xC70F6907
callq 0x40c0
movq %rax, %r12
movl %r12d, %eax
imulq $0x10624dd3, %rax, %rax # imm = 0x10624DD3
shrq $0x26, %rax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %r12d
movq -0x108(%rbp), %rdi
cmpq %r13, %rdi
je 0xc8df
callq 0x4360
movq %r14, %rdi
movl %r12d, %esi
callq 0xba82
movl %eax, %r12d
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x56fa
leaq -0xd8(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xe8(%rbp), %rdi
callq 0x56fa
leaq -0x68(%rbp), %rdx
leaq -0xe8(%rbp), %rcx
movq %r14, %rdi
movl %r12d, %esi
callq 0xbb0a
movq -0xe8(%rbp), %rdi
cmpq %r13, %rdi
je 0xc950
callq 0x4360
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xc962
callq 0x4360
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x48(%rbp), %rdi
callq 0x56fa
leaq -0xb8(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xc8(%rbp), %rdi
callq 0x56fa
leal 0x1(%r12), %esi
leaq -0x48(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
movq %r14, %rdi
callq 0xbb0a
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0xc9c7
callq 0x4360
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xc9d9
callq 0x4360
leaq -0x98(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %rdi
callq 0x56fa
leaq -0x78(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x56fa
addl $0x2, %r12d
leaq -0xa8(%rbp), %rdx
leaq -0x88(%rbp), %rcx
movq %r14, %rdi
movl %r12d, %esi
callq 0xbb0a
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0xca46
callq 0x4360
movq -0xa8(%rbp), %rdi
cmpq %r13, %rdi
je 0xca57
callq 0x4360
leaq -0x210(%rbp), %rdi
callq 0x11ee0
movq 0xc556(%rip), %rdi      # 0x18fc0
leaq 0x715c(%rip), %rsi      # 0x13bcd
movl $0x5, %edx
callq 0x43f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xc537(%rip), %rdi      # 0x18fc0
callq 0x43f0
movq %rax, %rbx
leaq 0x6ff9(%rip), %rsi      # 0x13a91
movl $0xa, %edx
movq %rax, %rdi
callq 0x43f0
leaq -0x210(%rbp), %rdi
callq 0x11f98
cvtss2sd 0x34(%rax), %xmm0
movq %rbx, %rdi
callq 0x4560
movq %rax, %rbx
leaq 0x6fd4(%rip), %rsi      # 0x13a9c
movl $0x3, %edx
movq %rax, %rdi
callq 0x43f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
leaq -0x210(%rbp), %rdi
callq 0x11a94
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0xcb33
callq 0x4360
jmp 0xcb33
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
cmpq %r13, %rdi
jne 0xcb8a
jmp 0xcbbd
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0xcb5a
callq 0x4360
jmp 0xcb5a
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
jmp 0xcb85
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
cmpq %r13, %rdi
je 0xcb7d
callq 0x4360
jmp 0xcb7d
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xcbbd
callq 0x4360
jmp 0xcbbd
jmp 0xcbba
movq %rax, %rdi
callq 0xa583
jmp 0xcbba
jmp 0xcbba
movq %rax, %rbx
movq -0x128(%rbp), %rdi
cmpq %r12, %rdi
je 0xcbc9
callq 0x4360
jmp 0xcbc9
movq %rax, %rbx
jmp 0xcbc9
movq %rax, %rbx
leaq -0x210(%rbp), %rdi
callq 0x11a94
movq %rbx, %rdi
callq 0x4630
nop