// File: /workspace/github_cpp_makefile_star2_O1/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 0x711b(%rip), %rsi      # 0x13a8d
leaq 0x7117(%rip), %rdx      # 0x13a90
leaq -0x128(%rbp), %rdi
callq 0xa686
leaq -0x210(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x11bb4
movq -0x128(%rbp), %rdi
cmpq %r12, %rdi
je 0xc9a9
callq 0x4360
leaq -0x210(%rbp), %rdi
callq 0x11fa8
leaq -0xf8(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x108(%rbp), %rdi
callq 0x570a
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 0xca19
callq 0x4360
movq %r14, %rdi
movl %r12d, %esi
callq 0xbbbc
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 0x570a
leaq -0xd8(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xe8(%rbp), %rdi
callq 0x570a
leaq -0x68(%rbp), %rdx
leaq -0xe8(%rbp), %rcx
movq %r14, %rdi
movl %r12d, %esi
callq 0xbc44
movq -0xe8(%rbp), %rdi
cmpq %r13, %rdi
je 0xca8a
callq 0x4360
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xca9c
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 0x570a
leaq -0xb8(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xc8(%rbp), %rdi
callq 0x570a
leal 0x1(%r12), %esi
leaq -0x48(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
movq %r14, %rdi
callq 0xbc44
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0xcb01
callq 0x4360
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xcb13
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 0x570a
leaq -0x78(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x570a
addl $0x2, %r12d
leaq -0xa8(%rbp), %rdx
leaq -0x88(%rbp), %rcx
movq %r14, %rdi
movl %r12d, %esi
callq 0xbc44
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0xcb80
callq 0x4360
movq -0xa8(%rbp), %rdi
cmpq %r13, %rdi
je 0xcb91
callq 0x4360
leaq -0x210(%rbp), %rdi
callq 0x12044
movq 0xc41c(%rip), %rdi      # 0x18fc0
leaq 0x7022(%rip), %rsi      # 0x13bcd
movl $0x5, %edx
callq 0x43f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xc3fd(%rip), %rdi      # 0x18fc0
callq 0x43f0
movq %rax, %rbx
leaq 0x6ebf(%rip), %rsi      # 0x13a91
movl $0xa, %edx
movq %rax, %rdi
callq 0x43f0
leaq -0x210(%rbp), %rdi
callq 0x120fc
cvtss2sd 0x34(%rax), %xmm0
movq %rbx, %rdi
callq 0x4560
movq %rax, %rbx
leaq 0x6e9a(%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 0x11bf8
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 0xcc6d
callq 0x4360
jmp 0xcc6d
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
cmpq %r13, %rdi
jne 0xccc4
jmp 0xccf7
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0xcc94
callq 0x4360
jmp 0xcc94
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
jmp 0xccbf
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
cmpq %r13, %rdi
je 0xccb7
callq 0x4360
jmp 0xccb7
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xccf7
callq 0x4360
jmp 0xccf7
jmp 0xccf4
movq %rax, %rdi
callq 0xa677
jmp 0xccf4
jmp 0xccf4
movq %rax, %rbx
movq -0x128(%rbp), %rdi
cmpq %r12, %rdi
je 0xcd03
callq 0x4360
jmp 0xcd03
movq %rax, %rbx
jmp 0xcd03
movq %rax, %rbx
leaq -0x210(%rbp), %rdi
callq 0x11bf8
movq %rbx, %rdi
callq 0x4630
nop