// File: /workspace/github_cpp_makefile_star2_O3/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 0x68ad(%rip), %rsi      # 0x13a8d
leaq 0x68a9(%rip), %rdx      # 0x13a90
leaq -0x138(%rbp), %rdi
callq 0xa592
leaq -0x220(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x11a50
movq -0x138(%rbp), %rdi
cmpq %r14, %rdi
je 0xd217
callq 0x4360
leaq -0x220(%rbp), %rdi
callq 0x11e44
leaq -0x108(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x118(%rbp), %rdi
callq 0x56fa
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 0xd287
callq 0x4360
movq -0x30(%rbp), %rdi
movl %r12d, %esi
callq 0xba82
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 0x56fa
leaq -0xc8(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xd8(%rbp), %rdi
callq 0x56fa
leaq -0xf8(%rbp), %rdx
leaq -0xd8(%rbp), %rcx
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xc2d4
movl %eax, %r13d
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0xd309
callq 0x4360
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd31a
callq 0x4360
movb $0x1, %r12b
testb %r13b, %r13b
jne 0xd510
movq 0xbc93(%rip), %r13      # 0x18fc0
leaq 0x6796(%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 0xbc60(%rip), %rdi      # 0x18fc0
callq 0x4040
movq %rax, %rdi
callq 0x4260
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x58(%rbp), %rdi
callq 0x56fa
leaq -0xa8(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xb8(%rbp), %rdi
callq 0x56fa
movq -0x38(%rbp), %rax
leal 0x1(%rax), %esi
leaq -0x58(%rbp), %rdx
leaq -0xb8(%rbp), %rcx
movq -0x30(%rbp), %rdi
callq 0xc2d4
movl %eax, %r13d
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd3d8
callq 0x4360
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xd3ea
callq 0x4360
testb %r13b, %r13b
jne 0xd510
movq 0xbbc6(%rip), %r13      # 0x18fc0
leaq 0x66c9(%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 0xbb93(%rip), %rdi      # 0x18fc0
callq 0x4040
movq %rax, %rdi
callq 0x4260
leaq -0x88(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %rdi
callq 0x56fa
leaq -0x68(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %rdi
callq 0x56fa
movq -0x38(%rbp), %rsi
addl $0x2, %esi
leaq -0x98(%rbp), %rdx
leaq -0x78(%rbp), %rcx
movq -0x30(%rbp), %rdi
callq 0xc2d4
movl %eax, %r14d
movq -0x78(%rbp), %rdi
cmpq %r15, %rdi
je 0xd4a2
callq 0x4360
movq -0x98(%rbp), %rdi
cmpq %r13, %rdi
je 0xd4b3
callq 0x4360
testb %r14b, %r14b
jne 0xd510
movq 0xbb01(%rip), %rdi      # 0x18fc0
leaq 0x6611(%rip), %rsi      # 0x13ad7
movl $0x11, %edx
callq 0x43f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xbae2(%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
xorl %r12d, %r12d
leaq -0x220(%rbp), %rdi
callq 0x11ee0
testb %r12b, %r12b
je 0xd5b0
movq 0xba94(%rip), %rdi      # 0x18fc0
leaq 0x669a(%rip), %rsi      # 0x13bcd
movl $0x5, %edx
callq 0x43f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xba75(%rip), %rdi      # 0x18fc0
callq 0x43f0
movq %rax, %rbx
leaq 0x658f(%rip), %rsi      # 0x13ae9
movl $0xd, %edx
movq %rax, %rdi
callq 0x43f0
leaq -0x220(%rbp), %rdi
callq 0x11f98
cvtss2sd 0x34(%rax), %xmm0
movq %rbx, %rdi
callq 0x4560
movq %rax, %rbx
leaq 0x6512(%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 0xd636
movq 0xba09(%rip), %rdi      # 0x18fc0
leaq 0x660f(%rip), %rsi      # 0x13bcd
movl $0x5, %edx
callq 0x43f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xb9ea(%rip), %rdi      # 0x18fc0
callq 0x43f0
movq %rax, %rbx
leaq 0x6512(%rip), %rsi      # 0x13af7
movl $0x1f, %edx
movq %rax, %rdi
callq 0x43f0
leaq -0x220(%rbp), %rdi
callq 0x11f98
cvtss2sd 0x34(%rax), %xmm0
movq %rbx, %rdi
callq 0x4560
movq %rax, %rbx
leaq 0x6487(%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 0x11a94
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x78(%rbp), %rdi
cmpq %r15, %rdi
je 0xd67d
callq 0x4360
jmp 0xd67d
movq %rax, %rbx
movq -0x98(%rbp), %rdi
cmpq %r13, %rdi
jne 0xd6db
jmp 0xd70e
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd6a7
callq 0x4360
jmp 0xd6a7
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
jne 0xd6db
jmp 0xd70e
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r12, %rdi
je 0xd6cf
callq 0x4360
jmp 0xd6cf
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0xd70e
callq 0x4360
jmp 0xd70e
jmp 0xd70b
movq %rax, %rdi
callq 0xa583
jmp 0xd70b
jmp 0xd70b
movq %rax, %rbx
movq -0x138(%rbp), %rdi
cmpq %r14, %rdi
je 0xd71a
callq 0x4360
jmp 0xd71a
movq %rax, %rbx
jmp 0xd71a
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
callq 0x11a94
movq %rbx, %rdi
callq 0x4630