// File: 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
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rsi, -0x240(%rbp)
movq %rdx, -0x238(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x46b0
movq -0x228(%rbp), %rdx
leaq 0xaa55(%rip), %rsi      # 0x1ca76
leaq -0x120(%rbp), %rdi
callq 0x4510
jmp 0x1202f
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x1b130
jmp 0x12044
leaq -0x120(%rbp), %rdi
callq 0x42a0
leaq -0x121(%rbp), %rdi
callq 0x4430
leaq -0x100(%rbp), %rdi
callq 0x1b5b0
jmp 0x1206a
movq -0x238(%rbp), %rsi
leaq -0x158(%rbp), %rdi
callq 0x41e0
jmp 0x1207f
leaq -0x158(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x10600
movq -0x250(%rbp), %rdi
movl %eax, -0x248(%rbp)
callq 0x42a0
movl -0x248(%rbp), %eax
movq -0x230(%rbp), %rdi
movl %eax, -0x138(%rbp)
movl -0x138(%rbp), %esi
callq 0x11010
movl %eax, -0x244(%rbp)
jmp 0x120ca
movq -0x240(%rbp), %rsi
movl -0x244(%rbp), %eax
movl %eax, -0x15c(%rbp)
movl -0x15c(%rbp), %eax
movl %eax, -0x254(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x41e0
jmp 0x120f7
movq -0x238(%rbp), %rsi
leaq -0x1a0(%rbp), %rdi
callq 0x41e0
jmp 0x1210c
movl -0x254(%rbp), %esi
movq -0x230(%rbp), %rdi
leaq -0x180(%rbp), %rdx
leaq -0x1a0(%rbp), %rcx
callq 0x110b0
movb %al, -0x255(%rbp)
jmp 0x12134
leaq -0x1a0(%rbp), %rdi
callq 0x42a0
leaq -0x180(%rbp), %rdi
callq 0x42a0
movb -0x255(%rbp), %al
movq -0x240(%rbp), %rsi
andb $0x1, %al
movb %al, -0x15d(%rbp)
movl -0x15c(%rbp), %eax
incl %eax
movl %eax, -0x25c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x41e0
jmp 0x1217d
movq -0x238(%rbp), %rsi
leaq -0x1e0(%rbp), %rdi
callq 0x41e0
jmp 0x12192
movl -0x25c(%rbp), %esi
movq -0x230(%rbp), %rdi
leaq -0x1c0(%rbp), %rdx
leaq -0x1e0(%rbp), %rcx
callq 0x110b0
movb %al, -0x25d(%rbp)
jmp 0x121ba
movb -0x25d(%rbp), %al
andb $0x1, %al
movb %al, -0x15d(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x42a0
leaq -0x1c0(%rbp), %rdi
callq 0x42a0
movq -0x240(%rbp), %rsi
movl -0x15c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x264(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x41e0
jmp 0x12204
movq -0x238(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x41e0
jmp 0x12219
movl -0x264(%rbp), %esi
movq -0x230(%rbp), %rdi
leaq -0x200(%rbp), %rdx
leaq -0x220(%rbp), %rcx
callq 0x110b0
movb %al, -0x265(%rbp)
jmp 0x12241
movb -0x265(%rbp), %al
andb $0x1, %al
movb %al, -0x15d(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x42a0
leaq -0x200(%rbp), %rdi
callq 0x42a0
leaq -0x100(%rbp), %rdi
callq 0x1b640
jmp 0x12275
movq 0x14d44(%rip), %rdi     # 0x26fc0
leaq 0xa933(%rip), %rsi      # 0x1cbb6
callq 0x43f0
movq %rax, -0x270(%rbp)
jmp 0x12291
movq -0x238(%rbp), %rsi
movq -0x270(%rbp), %rdi
callq 0x4370
movq %rax, -0x278(%rbp)
jmp 0x122ad
movq -0x278(%rbp), %rdi
leaq 0xa7bf(%rip), %rsi      # 0x1ca7a
callq 0x43f0
movq %rax, -0x280(%rbp)
jmp 0x122c9
leaq -0x100(%rbp), %rdi
callq 0x1b760
movq %rax, -0x288(%rbp)
jmp 0x122de
movq -0x280(%rbp), %rdi
movq -0x288(%rbp), %rax
movss 0x34(%rax), %xmm0
callq 0x42e0
movq %rax, -0x290(%rbp)
jmp 0x122ff
movq -0x290(%rbp), %rdi
leaq 0xa778(%rip), %rsi      # 0x1ca85
callq 0x43f0
movq %rax, -0x298(%rbp)
jmp 0x1231b
movq -0x298(%rbp), %rdi
movq 0x14c7f(%rip), %rsi     # 0x26fa8
callq 0x4410
jmp 0x12330
leaq -0x100(%rbp), %rdi
callq 0x1b1c0
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x12377
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x42a0
leaq -0x121(%rbp), %rdi
callq 0x4430
jmp 0x12469
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x1245d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x123d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x42a0
leaq -0x180(%rbp), %rdi
callq 0x42a0
jmp 0x1245d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x12411
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x42a0
leaq -0x1c0(%rbp), %rdi
callq 0x42a0
jmp 0x1245d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x12451
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x42a0
leaq -0x200(%rbp), %rdi
callq 0x42a0
leaq -0x100(%rbp), %rdi
callq 0x1b1c0
movq -0x130(%rbp), %rdi
callq 0x46a0
nopw %cs:(%rax,%rax)