// File: /workspace/github_cpp_makefile_star2_O1/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::get(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::get(std::string localFile, std::string remoteFile)
{
    //https://gitlab-beta.engr.illinois.edu/remis2/MP3-FileSystem.git
    // hashing function to find the machine where to ask for the file;

    ChronoCpu chrono("cpu");
    
    chrono.tic();

    int fileKey = hashString(remoteFile);
    int position = findPositionByKey(fileKey);

    // cout<<"get "<<localFile<<" "<<fileKey<<" from "<<position<<" "<<virtualRing[position].ip_str<<" "<<virtualRing[position].key<<endl;

    bool attempt = getFromNode( position, localFile, remoteFile );
    if(!attempt)
    {
        std::cout << "Retrying... " << std::endl;
        attempt = getFromNode( position+1, localFile, remoteFile );
    }
    if(!attempt)
    {
        std::cout << "Retrying... " << std::endl;
        attempt = getFromNode( position+2, localFile, remoteFile );
    }

    if (!attempt)
    {
        std::cout << "Error retrieving " << remoteFile << std::endl;
    }

    chrono.tac();
    if(attempt)
        std::cout << "File " << remoteFile << " received in " << chrono.getElapsedStats().lastTime_ms << " ms" << std::endl;
    else
        std::cout << "File " << remoteFile << " cannot be found. returning 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, -0x30(%rbp)
leaq -0x128(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x676f(%rip), %rsi      # 0x13a8d
leaq 0x676b(%rip), %rdx      # 0x13a90
leaq -0x138(%rbp), %rdi
callq 0xa686
leaq -0x220(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x11bb4
movq -0x138(%rbp), %rdi
cmpq %r14, %rdi
je 0xd355
callq 0x4360
leaq -0x220(%rbp), %rdi
callq 0x11fa8
leaq -0x108(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x118(%rbp), %rdi
callq 0x570a
movq -0x118(%rbp), %rdi
movq -0x110(%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 -0x118(%rbp), %rdi
cmpq %r14, %rdi
je 0xd3c5
callq 0x4360
movq -0x30(%rbp), %rdi
movl %r12d, %esi
callq 0xbbbc
movq %rax, -0x38(%rbp)
leaq -0xe8(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0xf8(%rbp), %rdi
callq 0x570a
leaq -0xc8(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xd8(%rbp), %rdi
callq 0x570a
leaq -0xf8(%rbp), %rdx
leaq -0xd8(%rbp), %rcx
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xc40e
movl %eax, %r13d
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0xd447
callq 0x4360
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd458
callq 0x4360
testb %r13b, %r13b
jne 0xd52e
movq 0xbb58(%rip), %r13      # 0x18fc0
leaq 0x665b(%rip), %rsi      # 0x13aca
movl $0xc, %edx
movq %r13, %rdi
callq 0x43f0
movq (%r13), %rax
addq -0x18(%rax), %r13
movq %r13, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq 0xbb25(%rip), %rdi      # 0x18fc0
callq 0x4040
movq %rax, %rdi
callq 0x4260
leaq -0xa8(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0xb8(%rbp), %rdi
callq 0x570a
leaq -0x88(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %rdi
callq 0x570a
movq -0x38(%rbp), %rax
leal 0x1(%rax), %esi
leaq -0xb8(%rbp), %rdx
leaq -0x98(%rbp), %rcx
movq -0x30(%rbp), %rdi
callq 0xc40e
movl %eax, %r13d
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0xd51d
callq 0x4360
movq -0xb8(%rbp), %rdi
cmpq %r12, %rdi
je 0xd52e
callq 0x4360
testb %r13b, %r13b
jne 0xd5ec
movq 0xba82(%rip), %r13      # 0x18fc0
leaq 0x6585(%rip), %rsi      # 0x13aca
movl $0xc, %edx
movq %r13, %rdi
callq 0x43f0
movq (%r13), %rax
addq -0x18(%rax), %r13
movq %r13, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq 0xba4f(%rip), %rdi      # 0x18fc0
callq 0x4040
movq %rax, %rdi
callq 0x4260
leaq -0x68(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %rdi
callq 0x570a
leaq -0x48(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x58(%rbp), %rdi
callq 0x570a
movq -0x38(%rbp), %rsi
addl $0x2, %esi
leaq -0x78(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq -0x30(%rbp), %rdi
callq 0xc40e
movl %eax, %r13d
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0xd5de
callq 0x4360
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0xd5ec
callq 0x4360
testb %r13b, %r13b
jne 0xd646
movq 0xb9c8(%rip), %rdi      # 0x18fc0
leaq 0x64d8(%rip), %rsi      # 0x13ad7
movl $0x11, %edx
callq 0x43f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xb9a9(%rip), %rdi      # 0x18fc0
callq 0x43f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
leaq -0x220(%rbp), %rdi
callq 0x12044
testb %r13b, %r13b
je 0xd6e6
movq 0xb95e(%rip), %rdi      # 0x18fc0
leaq 0x6564(%rip), %rsi      # 0x13bcd
movl $0x5, %edx
callq 0x43f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xb93f(%rip), %rdi      # 0x18fc0
callq 0x43f0
movq %rax, %rbx
leaq 0x6459(%rip), %rsi      # 0x13ae9
movl $0xd, %edx
movq %rax, %rdi
callq 0x43f0
leaq -0x220(%rbp), %rdi
callq 0x120fc
cvtss2sd 0x34(%rax), %xmm0
movq %rbx, %rdi
callq 0x4560
movq %rax, %rbx
leaq 0x63dc(%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
jmp 0xd76c
movq 0xb8d3(%rip), %rdi      # 0x18fc0
leaq 0x64d9(%rip), %rsi      # 0x13bcd
movl $0x5, %edx
callq 0x43f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xb8b4(%rip), %rdi      # 0x18fc0
callq 0x43f0
movq %rax, %rbx
leaq 0x63dc(%rip), %rsi      # 0x13af7
movl $0x1f, %edx
movq %rax, %rdi
callq 0x43f0
leaq -0x220(%rbp), %rdi
callq 0x120fc
cvtss2sd 0x34(%rax), %xmm0
movq %rbx, %rdi
callq 0x4560
movq %rax, %rbx
leaq 0x6351(%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 -0x220(%rbp), %rdi
callq 0x11bf8
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0xd7b3
callq 0x4360
jmp 0xd7b3
movq %rax, %rbx
movq -0x78(%rbp), %rdi
jmp 0xd7d9
movq %rax, %rbx
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0xd7d2
callq 0x4360
jmp 0xd7d2
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
cmpq %r12, %rdi
jne 0xd805
jmp 0xd838
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0xd7f9
callq 0x4360
jmp 0xd7f9
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd838
callq 0x4360
jmp 0xd838
jmp 0xd835
movq %rax, %rdi
callq 0xa677
jmp 0xd835
jmp 0xd835
movq %rax, %rbx
movq -0x138(%rbp), %rdi
cmpq %r14, %rdi
je 0xd844
callq 0x4360
jmp 0xd844
movq %rax, %rbx
jmp 0xd844
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
callq 0x11bf8
movq %rbx, %rdi
callq 0x4630